Hi all
Looking to monitor the rate of change of a temperature sensor. I would assume you would deduct current temperature reading from previous reading, and then write to a variable But not quite sure how to achieve this is dzvents. Still quite new to scripting.
Thanks in advance
Dave
Rate of change
Moderator: leecollings
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Rate of change
Something like below?
Code: Select all
return
{
on =
{
devices =
{
'tRate', -- your temperature sensor
},
},
data =
{
lTemperature =
{
initial = 0,
},
tDelta =
{
history = true,
maxHours = 10,
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'temperature_rate',
},
execute = function(dz, item)
dz.data.lTemperature = ( item.temperature - dz.data.lTemperature ) / item.lastUpdate.secondsAgo
dz.data.tDelta.add(dz.data.lTemperature)
local cstRate = dz.devices(1366) -- custom sensor with X-is label °C / minute
local rate = dz.utils.round( dz.data.tDelta.avgSince('00:30:00', 0 ), 2 )
dz.log('Rate is now ' .. rate .. ' °C / minute over the last 30 minutes.', dz.LOG_DEBUG)
cstRate.updateCustomSensor( rate )
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: 6
- Joined: Thursday 28 January 2016 16:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Rate of change
Looks good working away this week will look when i get back thank you.
-
- Posts: 6
- Joined: Thursday 28 January 2016 16:39
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Rate of change
This is working fine thank you. Is there any way to show if the change is negative or positive?
Who is online
Users browsing this forum: No registered users and 1 guest