Question regarding dzvents triggers

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
dzdm
Posts: 12
Joined: Monday 05 February 2018 14:24
Target OS: Linux
Domoticz version:
Contact:

Question regarding dzvents triggers

Post by dzdm »

Hi all,

I have some questions regarding dzvents triggers:

(TestDev is a Switch)

1. Will a on = { devices = { 'TestDev' } } be triggered when the device is on and a state change on->on occurs (yes, on to on)?

The background is, that I have a device which can be on or off. Additionally, it sends periodic status reports, so it is possible that there will be a on->on state change.

2. Does a domoticz switch item have a lastState flag?

3. changed: Boolean. True if the device was changed -> When exactly will this be set?


Thank you :)
SweetPants

Re: Question regarding dzvents triggers

Post by SweetPants »

dzdm wrote: Thursday 20 September 2018 14:42
1. Will a on = { devices = { 'TestDev' } } be triggered when the device is on and a state change on->on occurs (yes, on to on)?
As far as I know yes. I use a dummy switch for each phone detected and reset a lastupdate timer for each phone if it is (re)detected again.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Question regarding dzvents triggers

Post by waaren »

dzdm wrote: Thursday 20 September 2018 14:42 I have some questions regarding dzvents triggers:

(TestDev is a Switch)
1. Will a on = { devices = { 'TestDev' } } be triggered when the device is on and a state change on->on occurs (yes, on to on)?
2. Does a domoticz switch item have a lastState flag?
3. changed: Boolean. True if the device was changed -> When exactly will this be set?
1. Yes (see test script below)
2. No. Previous states of switches are only kept in the history tables. dzVents can store it in persistent data (see test script below)
nb. a dimmer does store it's last dimlevel
3. Not sure what you mean here. Please elaborate a bit on the case where you want it for.

Code: Select all

return {
    on = { devices = { "TestDev"}}  ,

    data    =   { previousState = { initial = "initialized" } },

    execute = function(dz, item)

        dz.log(item.name .. " ==>  state:  " .. item.state .. "; previous state: " .. dz.data.previousState)
        dz.data.previousState = item.state
        
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest