Page 26 of 37
Re: ClimateDataCalculation
Posted: Sun Sep 13, 2015 8:55 am
by Mastiff
I am going to incorporate the logging in the same script that does the temperature control and temperature alarms (for too hot fridge/freezer) for the house. So using "Copy as Python" I get this:
Code: Select all
eg.plugins.ClimateDataCalculation.TempDataCapture(u'Ute', u'60160', 1, 20.0, 5, False, 2.0, False, u'equal-less-greater')
How much of the info has to be there? I don't need anything else than the device ID, which will be the room numbrer (as discussed in the RFXtrx thread). I don't use desired/target value, hysteresis or rules in this, only logging of the temperature and creating of the graphs every hour. Would it be possible to only have for instance:
Code: Select all
eg.plugins.ClimateDataCalculation.TempDataCapture(u'Ute')
Or is there another way to shorten this? I don't dare to try it out in fear of messing with my collected data.

Re: ClimateDataCalculation
Posted: Sun Sep 13, 2015 3:24 pm
by krambriw
You have to keep the syntax as is. Only thing you shall change is '60160'
So the following could work for a room id 'livingroom':
Code: Select all
eg.plugins.ClimateDataCalculation.TempDataCapture(u'Living room', u'livingroom', 1, 20.0, 5, False, 2.0, False, u'equal-less-greater')
Re: ClimateDataCalculation
Posted: Sat Sep 19, 2015 9:26 am
by sintei
krambriw wrote:If you would like to try, you could modify the code in the CreateComboHtml.py file. In the current implementation I insert a 'null' when an expected data point is missing. This will then be presented as a gap (or broken line) in the graph, this is how HighCharts is handling this and I think it is good in general.
In this case where you are sampling only once per hour, it will however not look so good. The idea here is to fill the gaps with last known value instead of the 'null'
If you look at the code (the part below starting from line 188) you see the part that is looping through your data points and appending found values to the data that is going to be used in the graph. If a data point is expected but missing, a 'null' is inserted.
If we instead would insert the last known value, the code could look like this:
Code: Select all
for row in rows:
rd = float("%.2f" % row[pos])
if bFirstDone:
rd_old = float("%.2f" % row_old[pos])
diff, d = days_hours_minutes(
datetime.strptime(str(row[0][:-3]), '%Y-%m-%d %H:%M') -
datetime.strptime(str(row_old[0][:-3]), '%Y-%m-%d %H:%M')
)
if diff > 0:
for i in range(diff-1):
data.append(rd_old)
diff = 0
if rd == 0.0:
data.append('null')
else:
data.append(rd)
else:
s, d = days_hours_minutes(
d1 -
datetime.strptime(str(rows[0][0][:-3]), '%Y-%m-%d %H:%M')
)
if sedt[0] - s > 0:
for i in range(sedt[0] - s):
data.append('null')
data.append(rd)
bFirstDone = True
row_old = row
If you change, please note that this modification needs be repeated for all chart types you would like to behave like this (MakeChart. MakeChart_10 etc...)
BR
I will look into this. Just moved everything from a win 7 32bit to a win 7 64bit machine so some tweaking has to be done

I did not see this before but that extra device that we added gives off its value in decimal form resulting in an error:
Exception in thread Thread-329:
Traceback (most recent call last):
File "threading.pyc", line 532, in __bootstrap_inner
File "threading.pyc", line 484, in run
File "C:\Program Files\EventGhost\plugins\climate\__init__.py", line 1529, in CaptureTemp
temperature = float("%.2f" % float(A[7]))
ValueError: invalid literal for float(): 17,5
Im pretty sure if I exchange float for int it will be fine. But could this cause side effects with anything else?
Also, I promised a beer. Look into your PM for details

Re: ClimateDataCalculation
Posted: Sat Sep 19, 2015 10:52 am
by krambriw
Im pretty sure if I exchange float for int it will be fine
No, that is not the way. We have to replace the ',' with '.'
So, basically, having a string like
we have to do
after, the float method will work fine
Re: ClimateDataCalculation
Posted: Sat Sep 19, 2015 11:06 am
by krambriw
I would assume this code should work. Please try and replace
Best regards, Walter
Code: Select all
if eg.event.suffix.find('.ZWave/')!= -1: #For Z-Wave
A = re.split(r'["]\s*', eg.event.payload)
B = re.split(r'[.]\s*', eg.event.suffix)[1].split('/')[1]
if B == deviceCode and A[3] == 'Sensor.Temperature':
addr = B
t = A[7].replace(',','.')
temperature = float("%.2f" % float(t))
print 'temperature:', temperature
Re: ClimateDataCalculation
Posted: Mon Sep 21, 2015 7:54 pm
by sintei
krambriw wrote:I would assume this code should work. Please try and replace
Best regards, Walter
Code: Select all
if eg.event.suffix.find('.ZWave/')!= -1: #For Z-Wave
A = re.split(r'["]\s*', eg.event.payload)
B = re.split(r'[.]\s*', eg.event.suffix)[1].split('/')[1]
if B == deviceCode and A[3] == 'Sensor.Temperature':
addr = B
t = A[7].replace(',','.')
temperature = float("%.2f" % float(t))
print 'temperature:', temperature
This is golden.
Did some edits and got everything going now.
Luminance is a little bit finnicky but overall I am a happy camper!
Thank you for your great support

Re: ClimateDataCalculation
Posted: Tue Sep 22, 2015 6:54 am
by krambriw
Modified support for z-wave devices (temperature)
Updated version uploaded
Re: ClimateDataCalculation
Posted: Tue Dec 15, 2015 7:45 am
by Mastiff
Hi, Krambriw! I get this every now and then:
Code: Select all
08:44:17 Exception in thread Thread-46873:
08:44:17 Traceback (most recent call last):
08:44:17 File "threading.pyc", line 532, in __bootstrap_inner
08:44:17 File "threading.pyc", line 484, in run
08:44:17 File "C:\Program Files (x86)\EventGhost\plugins\ClimaDataCalculation\__init__.py", line 1566, in CaptureTemp
08:44:17 rule
08:44:17 File "C:\Program Files (x86)\EventGhost\plugins\ClimaDataCalculation\__init__.py", line 624, in SaveTempData
08:44:17 saveTempThread.start()
08:44:17 File "threading.pyc", line 474, in start
08:44:17 error: can't start new thread
08:44:17
Any idea what that can be? I do understand that it's something with a thread, but thats where my "intelligence" stops...

Re: ClimateDataCalculation
Posted: Tue Dec 15, 2015 8:45 am
by krambriw
Hmm the thread is not able to start,,,could maybe be because it is already running due to an already ongoing save for another sensor. Need to check the code if this can happen.
Re: ClimateDataCalculation
Posted: Tue Dec 15, 2015 8:49 am
by Mastiff
OK, thanks!

Re: ClimateDataCalculation
Posted: Wed Dec 16, 2015 8:49 am
by krambriw
This might be tricky, eventually need to debug further...
Anyway, made a new version where I hope I have improved handling of locks between threads as well as 'recommended' method to lock the db when a write operation is needed' Let's see how this one works.
Kind regards, Walter
Re: ClimateDataCalculation
Posted: Wed Dec 16, 2015 9:51 am
by Mastiff
Thanks! I'll put it to work and let you know if I see anything funky.

Re: ClimateDataCalculation
Posted: Tue Dec 29, 2015 8:33 am
by Mastiff
I'm afraid it didn't help.

Log output:
Code: Select all
09:30:20
09:30:20 Exception in thread Thread-43669:
09:30:20 Traceback (most recent call last):
09:30:20 File "threading.pyc", line 532, in __bootstrap_inner
09:30:20 File "threading.pyc", line 484, in run
09:30:20 File "C:\Program Files (x86)\EventGhost\plugins\ClimaDataCalculation\__init__.py", line 1558, in CaptureTemp
09:30:20 rule
09:30:20 File "C:\Program Files (x86)\EventGhost\plugins\ClimaDataCalculation\__init__.py", line 617, in SaveTempData
09:30:20 saveTempThread.start()
09:30:20 File "threading.pyc", line 474, in start
09:30:20 error: can't start new thread
09:30:20
09:30:20 RFXtrx.Type: Viking 02811 id: 6144 ' temperature: +7.1 deg C signal: 5 battery: 9'
09:30:22 RFXtrx.Type: Viking 02811 id: 26368 ' temperature: +11.1 deg C signal: 5 battery: 9'
09:30:22 Biljardrom.: Temperatur: 11.1, termostattemperatur: 5, tidspunkt: Kl. 09:30, den 29.12.
09:30:22
09:30:23 RFXtrx.Type: Viking 02811 id: 57088 ' temperature: +17.9 deg C signal: 5 battery: 9'
09:30:23 Hjørnesoverom.: Temperatur: 17.9, termostattemperatur: 20, tidspunkt: Kl. 09:30, den 29.12.
09:30:23
09:30:23 Traceback (most recent call last) (1706):
09:30:23 File "C:\Program Files (x86)\EventGhost\eg\Classes\Scheduler.py", line 158, in MainLoop
09:30:23 Exception in thread Thread-43677:
09:30:23 func(*args, **kwargs)
09:30:23 Traceback (most recent call last):
09:30:23 File "C:\Program Files (x86)\EventGhost\eg\Classes\Scheduler.py", line 52, in LongTask
09:30:23 File "threading.pyc", line 532, in __bootstrap_inner
09:30:23 thrd.start()
09:30:23 File "threading.pyc", line 474, in start
09:30:23 error: can't start new thread
09:30:23 File "threading.pyc", line 484, in run
09:30:23 File "C:\Program Files (x86)\EventGhost\plugins\ClimaDataCalculation\__init__.py", line 1558, in CaptureTemp
09:30:23 rule
09:30:23 File "C:\Program Files (x86)\EventGhost\plugins\ClimaDataCalculation\__init__.py", line 617, in SaveTempData
09:30:23 saveTempThread.start()
09:30:23 File "threading.pyc", line 474, in start
09:30:23 error: can't start new thread
09:30:23
It's not related to long uptime either. I had a restart of the virtual machine yesterday evening.
Re: ClimateDataCalculation
Posted: Wed Dec 30, 2015 7:57 am
by krambriw
Hello,
I now know what the problem is, we are running out of resources, too may threads are open at the same time in the same python process (I read somewhere maximum is 32 in a Win7 64bit env running 32bit apps)
So just need to find a solution as well...
Best regards, Walter
Happy New Year
Re: ClimateDataCalculation
Posted: Wed Dec 30, 2015 8:01 am
by Mastiff
Brilliant, Walter! I knew you would diagnose it! And I have all the confidence in the world in you to find a solution. Happy new year, master!
