Check if value changed [Solved]
Moderator: leecollings
-
Jumper3126
- Posts: 105
- Joined: Thursday 31 December 2015 15:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Check if value changed
the lastupdate feature of DZventz is enormously handy, but for a new script I would like to know when a device (integer value) has changed. This specific devices is updated every minute but also if the value didn't change. Is this possible somehow or do i need to work with persistent data to store and compare?
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Check if value changed
Yes you need to work with persistent data or a domoticz uservariable to compare current state with a previous state if your device is not a dimmer or selector. For these types you can use the lastLevel attribute.Jumper3126 wrote: Thursday 10 September 2020 22:18 the lastupdate feature of DZventz is enormously handy, but for a new script I would like to know when a device (integer value) has changed. This specific devices is updated every minute but also if the value didn't change. Is this possible somehow or do i need to work with persistent data to store and compare?
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
-
Jumper3126
- Posts: 105
- Joined: Thursday 31 December 2015 15:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Check if value changed [Solved]
Thanks for that very quick respons waaren!
-
Patricen
- Posts: 121
- Joined: Tuesday 06 February 2018 18:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta rel
- Contact:
Re: Check if value changed
Hello,
This looks like it could solve my issue. I would like to trigger an event on sudden dewpoint rise. Do you have any example showing this?
using my algorithmic language it would look like
If sensor above stove's dewpoint rose more than 1°C since last update
Set cooker hood to "on"
Thanks
This looks like it could solve my issue. I would like to trigger an event on sudden dewpoint rise. Do you have any example showing this?
using my algorithmic language it would look like
If sensor above stove's dewpoint rose more than 1°C since last update
Set cooker hood to "on"
Thanks
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Check if value changed
Something like below ?Patricen wrote: Wednesday 23 September 2020 16:27 This looks like it could solve my issue. I would like to trigger an event on sudden dewpoint rise. Do you have any example showing this?
Code: Select all
return
{
on =
{
devices =
{
'myDewpointSensor', -- change to name of Sensor
},
},
data =
{
lastValue =
{
initial = 0,
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when script is tested and OK
marker = 'dewPoint-rise',
},
execute = function(dz, item)
cookerHood = dz.devices('cooker hood') -- change to name of Cooker Hood device
dz.log('\nDevicename: ' .. item.name .. ', nValue: ' .. item.nValue .. ', sValue: ' .. item.sValue ..
'\nDevicetype: ' .. item.deviceType .. ', deviceSubType: ' .. item.deviceSubType ..
'\nlastValue: ' .. dz.data.lastValue, dz.LOG_DEBUG )
if item.dewPoint >= dz.data.lastValue + 1 then
cookerHood.switchOn().checkFirst()
end
if dz.data.lastValue ~= item.dewPoint then
dz.data.lastValue = item.dewPoint
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
-
Patricen
- Posts: 121
- Joined: Tuesday 06 February 2018 18:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta rel
- Contact:
Re: Check if value changed
Thanks a lot, I'll try this and keep you updated
-
Patricen
- Posts: 121
- Joined: Tuesday 06 February 2018 18:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta rel
- Contact:
Re: Check if value changed
waaren wrote: Wednesday 23 September 2020 22:54Something like below ?Patricen wrote: Wednesday 23 September 2020 16:27 This looks like it could solve my issue. I would like to trigger an event on sudden dewpoint rise. Do you have any example showing this?
Code: Select all
return { on = { devices = { 'myDewpointSensor', -- change to name of Sensor }, }, data = { lastValue = { initial = 0, }, }, logging = { level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when script is tested and OK marker = 'dewPoint-rise', }, execute = function(dz, item) cookerHood = dz.devices('cooker hood') -- change to name of Cooker Hood device dz.log('\nDevicename: ' .. item.name .. ', nValue: ' .. item.nValue .. ', sValue: ' .. item.sValue .. '\nDevicetype: ' .. item.deviceType .. ', deviceSubType: ' .. item.deviceSubType .. '\nlastValue: ' .. dz.data.lastValue, dz.LOG_DEBUG ) if item.dewPoint >= dz.data.lastValue + 1 then cookerHood.switchOn().checkFirst() end if dz.data.lastValue ~= item.dewPoint then dz.data.lastValue = item.dewPoint end end }
Waahh!! Brilliant, this works like a charm, thanks!
Who is online
Users browsing this forum: No registered users and 1 guest