Temperatures difference calculation / Delta T
Moderator: leecollings
-
- Posts: 41
- Joined: Saturday 01 November 2014 13:51
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Temperatures difference calculation / Delta T
Hi all,
For some hours i’ve been looking to find a script or scripts to adapt to my own use but i can’t seem to figure it out.
What i want to achieve:
I have two temperature sensor for measuring water temperature going into my floorheating and the temperature coming back from the floorheating.
I want to calculate the temperature difference what is also called delta T.
The values are pushed to Domoticz every minute from ESPEasy module.
I have a script now which triggers on devicechanged but i have the idea that it consumes cpu and memory of the RPI without any use.
I was thinking of checking the value and let it run the complete script if the previous value is 0.2 or 0.3 higher or lower.
Anybody able to help me out?
For some hours i’ve been looking to find a script or scripts to adapt to my own use but i can’t seem to figure it out.
What i want to achieve:
I have two temperature sensor for measuring water temperature going into my floorheating and the temperature coming back from the floorheating.
I want to calculate the temperature difference what is also called delta T.
The values are pushed to Domoticz every minute from ESPEasy module.
I have a script now which triggers on devicechanged but i have the idea that it consumes cpu and memory of the RPI without any use.
I was thinking of checking the value and let it run the complete script if the previous value is 0.2 or 0.3 higher or lower.
Anybody able to help me out?
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Temperatures difference calculation / Delta T
From what you post here I would say that you would be better of if you change the script to become time triggered. Can you share the script so someone can help you modifying ?MaikelK wrote: ↑Sunday 13 January 2019 20:05 I want to calculate the temperature difference what is also called delta T.
I have a script now which triggers on devicechanged but i have the idea that it consumes cpu and memory of the RPI without any use.
I was thinking of checking the value and let it run the complete script if the previous value is 0.2 or 0.3 higher or lower.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 41
- Joined: Saturday 01 November 2014 13:51
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Temperatures difference calculation / Delta T
Herewith my current code:
Code: Select all
--Functie round aanroepen
function Round(num, idp)
return tonumber(string.format("%." ..(idp or 0).. "f", num))
end
--Declareren van sensornamen, dit is makkelijk om het script te kopieeren dan hoef je het alleen hier aan te passen
sensor1 = 'CV uit'; --Deze sensor Temp bevatten
sensor2 = 'CV in'; -- Deze sensor Temp bevatten
commandArray = {}
--devicechanged is een standaard functie, als de sensor "update" dan runt hij de script
if devicechanged[sensor1] then --and devicechanged[sensor2] then
--Haal info van sensor 1 op, specifiek per data punt. Dit is in decimale (wordt van een string onttrokken met tonumber)
local_sensor1_temp = tonumber(otherdevices_temperature[sensor1]);
--Haal info van sensor 2 op
local_sensor2_temp = tonumber(otherdevices_temperature[sensor2]);
--Zet aan voor debug
--print('Temp_sensor1:' .. ' ' .. local_sensor1_temp)
--print('Temp_sensor2:' .. ' ' .. local_sensor2_temp)
--Berekening 1 (delta temperatuur):
delta = (local_sensor1_temp-local_sensor2_temp);
--Getal afronden naar 1 decimaal
delta = Round(delta, 1);
--print('CV delta:' .. ' ' .. delta)
--Schrijf berekening 1 naar dummy sensor3
commandArray[1] = {['UpdateDevice'] = 469 .. '|0|' .. delta}
end
return commandArray
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Temperatures difference calculation / Delta T
When not yet familiar with dzVents please start with reading the quick start of the wikiMaikelK wrote: ↑Sunday 13 January 2019 20:05 I want to calculate the temperature difference what is also called delta T.
I have a script now which triggers on devicechanged but i have the idea that it consumes cpu and memory of the RPI without any use.
I was thinking of checking the value and let it run the complete script if the previous value is 0.2 or 0.3 higher or lower.
Before implementing.
With special attention please for
"In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents disabled' is not checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
Thx
Code: Select all
--[[
When not yet familiar with dzVents please start with reading
https://www.domoticz.com/wiki/DzVents:_next_generation_LUA_scripting#Using_dzVents_with_Domoticz
Before implementing. Special attention please for
"In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents disabled' is not checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
]]--
return {
on = { timer = { "every 2 minutes" }}, -- Change to your liking to 1,2,3,4,5,6,10,12,15 or 20
execute = function(dz, item)
local deltaTemperatureCV = dz.devices(469)
local inTemperatureCV = dz.devices("CV in").temperature
local uitTemperatureCV = dz.devices("CV uit").temperature
deltaTemperatureCV.updateTemperature(dz.utils.round(inTemperatureCV - uitTemperatureCV,2)) -- Rounded to two decimals
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 41
- Joined: Saturday 01 November 2014 13:51
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Temperatures difference calculation / Delta T
Thanks, this offcourse works. I changed the local values to temphigh, templow and delta, just to make it easier for all my devices and i only need to changes the names and idx of the delta devices.
But i would rather have it to run only if one of the sensors has a temp difference of 0.2 degrees. Then as long as a changed value is pushed with a difference of 0.2 degrees higher of lower the script gets processed.
But i would rather have it to run only if one of the sensors has a temp difference of 0.2 degrees. Then as long as a changed value is pushed with a difference of 0.2 degrees higher of lower the script gets processed.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Temperatures difference calculation / Delta T
This is not how the event system in domoticz works. You can trigger a script based on a timer or on a group, scene, security state, device or variable update. The logic of determining how much or to what any of these changed has to be done inside the triggered script.MaikelK wrote: ↑Monday 14 January 2019 11:06 Thanks, this offcourse works. I changed the local values to temphigh, templow and delta, just to make it easier for all my devices and i only need to changes the names and idx of the delta devices.
But i would rather have it to run only if one of the sensors has a temp difference of 0.2 degrees. Then as long as a changed value is pushed with a difference of 0.2 degrees higher of lower the script gets processed.
Is this what you try to achieve ?
Code: Select all
return {
on = { devices = { "temphigh", "templow" }},
data = { temphigh = { initial = 0 },
templow = { initial = 0 }},
execute = function(dz)
local deltaTemperatureCV = dz.devices("delta")
local inTemperatureCV = dz.devices("temphigh").temperature
local outTemperatureCV = dz.devices("templow").temperature
if math.abs(inTemperatureCV - dz.data.temphigh) > 0.2 or math.abs(outTemperatureCV - dz.data.temphigh) > 0.2 then
deltaTemperatureCV.updateTemperature(math.abs(dz.utils.round(inTemperatureCV - outTemperatureCV,2))) -- Rounded to two decimals
dz.data.temphigh = inTemperatureCV
dz.data.templow = outTemperatureCV
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 41
- Joined: Saturday 01 November 2014 13:51
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Temperatures difference calculation / Delta T
Would this reduce needed calculation power? Altough it probably already wasnt using much?
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Temperatures difference calculation / Delta T
The difference between the time based script compared to the deviceChanged based - is not measurable on my RPI -3.
They both take on average about 8 milliseconds clock time. So it depends solely on the amount of temperature updates the templow and temphigh do get. If that's more then once every 2 minutes and you have no reason to limit the number of updates to your delta device other than saving cpu cycles, I would definitely go for the time based one and just update the delta device every cycle.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Re: Temperatures difference calculation / Delta T
My lua script ended up like this:
return
{
on = {
timer = { "every minute" }
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'Vloerverwarming Tdelta calculation',
},
execute = function(domoticz)
local X1 = domoticz.devices("Vloerverwarming_Tin").temperature
local X2 = domoticz.devices("Vloerverwarming_Tuit").temperature
local Y1 = X1 - X2
domoticz.log('Value_X1: ' .. X1, domoticz.LOG_DEBUG)
domoticz.log('Value_X2: ' .. X2, domoticz.LOG_DEBUG)
domoticz.log('Value_Y1: ' .. Y1, domoticz.LOG_DEBUG)
domoticz.devices('Vloerverwarming_Tdelta').updateTemperature(Y1)
end
}
return
{
on = {
timer = { "every minute" }
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'Vloerverwarming Tdelta calculation',
},
execute = function(domoticz)
local X1 = domoticz.devices("Vloerverwarming_Tin").temperature
local X2 = domoticz.devices("Vloerverwarming_Tuit").temperature
local Y1 = X1 - X2
domoticz.log('Value_X1: ' .. X1, domoticz.LOG_DEBUG)
domoticz.log('Value_X2: ' .. X2, domoticz.LOG_DEBUG)
domoticz.log('Value_Y1: ' .. Y1, domoticz.LOG_DEBUG)
domoticz.devices('Vloerverwarming_Tdelta').updateTemperature(Y1)
end
}
Who is online
Users browsing this forum: No registered users and 1 guest