UserVariables not always set after Device Trigger Off[edit]

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

Moderator: leecollings

Freemann
Posts: 94
Joined: Thursday 24 November 2016 14:55
Target OS: Linux
Domoticz version: >=Béta
Location: Netherlands
Contact:

Re: UserVariables not always set after Device Trigger Off[edit]

Post by Freemann »

In de case of the Z-wave Off command, no change.
Domotica/graphs "freak" :)
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam

https://www.frijduurzaam.nl
Freemann
Posts: 94
Joined: Thursday 24 November 2016 14:55
Target OS: Linux
Domoticz version: >=Béta
Location: Netherlands
Contact:

Re: UserVariables not always set after Device Trigger Off[edit]

Post by Freemann »

Did some testing with the Z-Wave device and created an secundary script which triggers on the 2 UserVariable changes.
The original script to set the UserVariables send an email notification and the UserVariable change script also send a notification;
Screenshot - 30_01_2019 , 21_15_43.png
Screenshot - 30_01_2019 , 21_15_43.png (66.24 KiB) Viewed 609 times
The On command generates an email for both the UserVar's changes, the Off command not...
Domotica/graphs "freak" :)
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam

https://www.frijduurzaam.nl
Freemann
Posts: 94
Joined: Thursday 24 November 2016 14:55
Target OS: Linux
Domoticz version: >=Béta
Location: Netherlands
Contact:

Re: UserVariables not always set after Device Trigger Off[edit]

Post by Freemann »

Here's the script I use to test the UserVariables, no rocket science.:

Code: Select all

return {
	on = {
		variables = {'BadkVerwarmingOffTime','BadkVerwarmingOnTime'}
	},
    logging =   {  
        level     =   domoticz.LOG_DEBUG,       -- change to LOG_ERROR after you tested  the script
        marker    =   "Return::on::variables::" 
    },
	execute = function(dz, item, info )
        local function logWrite(str,level)             -- Support function for shorthand debug log statements
            dz.log(tostring(str),level or dz.LOG_DEBUG)
            dz.notify(tostring(str))
        end        
        logWrite('UserVarTestScript:'..item.name..' :: changed to:'..item.value)
	end
}
Here another test with the strange behaviour of the Z-Wave device and the expected behaviour of the "Badkamer verlichting2" dummy device;
Screenshot - 31_01_2019 , 08_58_02.png
Screenshot - 31_01_2019 , 08_58_02.png (51.92 KiB) Viewed 602 times
Domotica/graphs "freak" :)
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam

https://www.frijduurzaam.nl
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: UserVariables not always set after Device Trigger Off[edit]

Post by waaren »

Freemann wrote: Thursday 31 January 2019 8:53 Here's the script I use to test the UserVariables, no rocket science.:
Have to admit I am intrigued by this. Can you try and switch names of the Zwave and virtual device and check again ? This to see if the issue is caused by the name or by the different device types ?
TIA
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Freemann
Posts: 94
Joined: Thursday 24 November 2016 14:55
Target OS: Linux
Domoticz version: >=Béta
Location: Netherlands
Contact:

Re: UserVariables not always set after Device Trigger Off[edit]

Post by Freemann »

Looks like it has something to do with the lenght of the devicename;
Devicename "Badkamer verlichtin" is working is expected
Devicename "Badkamer verlichting" is not working as expected
Screenshot - 31_01_2019 , 13_41_46.png
Screenshot - 31_01_2019 , 13_41_46.png (64.79 KiB) Viewed 594 times
Domotica/graphs "freak" :)
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam

https://www.frijduurzaam.nl
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: UserVariables not always set after Device Trigger Off[edit]

Post by waaren »

Freemann wrote: Thursday 31 January 2019 13:46 Looks like it has something to do with the lenght of the devicename;
Devicename "Badkamer verlichtin" is working is expected
Devicename "Badkamer verlichting" is not working as expected
On my system the length of the devicename does not influence the behavior
Spoiler: show

Code: Select all

-- isDevice check

return {
    on =        {    devices  = { "isDevice Test with quite a very long name" }},  -- 433 is sensor / isDevice Test switch
                 
        logging =   {  
                        level     =   domoticz.LOG_DEBUG,       -- change to LOG_ERROR after you tested  the script
                        marker    =   "isDevice check" 
                    },
                 
    execute = function(dz, item, info )
      
        local function logWrite(str,level)             -- Support function for shorthand debug log statements
            dz.log(tostring(str),level or dz.LOG_DEBUG)
        end
        
        local trigger   = item.name
        local state     = item.state
        
        if info.trigger then 
            trigger = info.trigger 
            state   = "N/A"    
        end
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isDevice        " .. tostring(item.isDevice ))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isVariable      " .. tostring(item.isVariable ))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isScene         " .. tostring(item.isScene))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isGroup         " .. tostring(item.isGroup))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isTimer         " .. tostring(item.isTimer))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isSecurity      " .. tostring(item.isSecurity))
        logWrite("triggered by " .. trigger .. "; state: " .. state .. "; isHTTPResponse  " .. tostring(item.isHTTPResponse))
        if item.isDevice then
            if item.state == "Off" then 
                logWrite("triggered by " .. trigger .. "; state: " .. state )
                logWrite("setting uservar BadkVerwarmingOnTime to " .. os.time())  
                dz.variables("BadkVerwarmingOnTime").set(os.time())
            else
                logWrite("triggered by " .. trigger .. "; state: " .. state )
                logWrite("setting uservar BadkVerwarmingOffTime to " .. os.time())  
                dz.variables("BadkVerwarmingOffTime").set(os.time())
            end
        end
  
    end             
}

Code: Select all

2019-01-31 17:15:56.622  (Virtual2) Light/Switch (isDevice Test with quite a very long name)
2019-01-31 17:15:56.866  Status: dzVents: Info:  Handling events for: "isDevice Test with quite a very long name", value: "On"
2019-01-31 17:15:56.866  Status: dzVents: Info:  isDevice check: ------ Start external script: dumper103.lua: Device: "isDevice Test with quite a very long name (Virtual2)", Index: 1477
2019-01-31 17:15:56.868  Status: dzVents: Debug: isDevice check: triggered by isDevice Test with quite a very long name; state: On; isDevice        true
2019-01-31 17:15:56.869  Status: dzVents: Debug: isDevice check: triggered by isDevice Test with quite a very long name; state: On; isVariable      false
2019-01-31 17:15:56.869  Status: dzVents: Debug: isDevice check: triggered by isDevice Test with quite a very long name; state: On; isScene         false
2019-01-31 17:15:56.869  Status: dzVents: Debug: isDevice check: triggered by isDevice Test with quite a very long name; state: On; isGroup         false
2019-01-31 17:15:56.869  Status: dzVents: Debug: isDevice check: triggered by isDevice Test with quite a very long name; state: On; isTimer         false
2019-01-31 17:15:56.869  Status: dzVents: Debug: isDevice check: triggered by isDevice Test with quite a very long name; state: On; isSecurity      false
2019-01-31 17:15:56.869  Status: dzVents: Debug: isDevice check: triggered by isDevice Test with quite a very long name; state: On; isHTTPResponse  false
2019-01-31 17:15:56.869  Status: dzVents: Debug: isDevice check: triggered by isDevice Test with quite a very long name; state: On
2019-01-31 17:15:56.869  Status: dzVents: Debug: isDevice check: setting uservar BadkVerwarmingOffTime to 1548951356
2019-01-31 17:15:56.871  Status: dzVents: Info:  isDevice check: ------ Finished dumper103.lua
2019-01-31 17:15:56.883  Status: Set UserVariable BadkVerwarmingOffTime = 1548951356

2019-01-31 17:16:05.613  (Virtual2) Light/Switch (isDevice Test with quite a very long name)
2019-01-31 17:16:05.843  Status: dzVents: Info:  Handling events for: "isDevice Test with quite a very long name", value: "Off"
2019-01-31 17:16:05.843  Status: dzVents: Info:  isDevice check: ------ Start external script: dumper103.lua: Device: "isDevice Test with quite a very long name (Virtual2)", Index: 1477
2019-01-31 17:16:05.844  Status: dzVents: Debug: isDevice check: triggered by isDevice Test with quite a very long name; state: Off; isDevice        true
2019-01-31 17:16:05.844  Status: dzVents: Debug: isDevice check: triggered by isDevice Test with quite a very long name; state: Off; isVariable      false
2019-01-31 17:16:05.844  Status: dzVents: Debug: isDevice check: triggered by isDevice Test with quite a very long name; state: Off; isScene         false
2019-01-31 17:16:05.844  Status: dzVents: Debug: isDevice check: triggered by isDevice Test with quite a very long name; state: Off; isGroup         false
2019-01-31 17:16:05.844  Status: dzVents: Debug: isDevice check: triggered by isDevice Test with quite a very long name; state: Off; isTimer         false
2019-01-31 17:16:05.845  Status: dzVents: Debug: isDevice check: triggered by isDevice Test with quite a very long name; state: Off; isSecurity      false
2019-01-31 17:16:05.845  Status: dzVents: Debug: isDevice check: triggered by isDevice Test with quite a very long name; state: Off; isHTTPResponse  false
2019-01-31 17:16:05.845  Status: dzVents: Debug: isDevice check: triggered by isDevice Test with quite a very long name; state: Off
2019-01-31 17:16:05.845  Status: dzVents: Debug: isDevice check: setting uservar BadkVerwarmingOnTime to 1548951365
2019-01-31 17:16:05.846  Status: dzVents: Info:  isDevice check: ------ Finished dumper103.lua
2019-01-31 17:16:05.883  Status: Set UserVariable BadkVerwarmingOnTime = 1548951365
uservar set by isDevice test
uservar set by isDevice test
uservar.png (39.7 KiB) Viewed 591 times
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Freemann
Posts: 94
Joined: Thursday 24 November 2016 14:55
Target OS: Linux
Domoticz version: >=Béta
Location: Netherlands
Contact:

Re: UserVariables not always set after Device Trigger Off[edit]

Post by Freemann »

Don't known if its matter, but thats a virtual/dummy device and i'm using a Z-Wave device.

When I use a dummy device with the name "Badkamer verlichting3", then it's also working fine;
Screenshot - 31_01_2019 , 19_22_27.png
Screenshot - 31_01_2019 , 19_22_27.png (29.35 KiB) Viewed 589 times
And the strange thing is... When I add a * the the "on" trigger in the script; "Badkamer verlichting*" both
Z-wave "Badkamer verlichting"
and
Dummy "Badkamer verlichting3"
are working as expected...

So;

Code: Select all

return {
    on =        {      
        --timer = {"every minute"},
                     devices  = { 
                         --237,
                         "Badkamer verlichting*" 
                    }},  -- 433 is sensor / isDevice Test switch
 
Results in;
Screenshot - 31_01_2019 , 19_36_02.png
Screenshot - 31_01_2019 , 19_36_02.png (58.7 KiB) Viewed 586 times
Domotica/graphs "freak" :)
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam

https://www.frijduurzaam.nl
Freemann
Posts: 94
Joined: Thursday 24 November 2016 14:55
Target OS: Linux
Domoticz version: >=Béta
Location: Netherlands
Contact:

Re: UserVariables not always set after Device Trigger Off[edit]

Post by Freemann »

Any idea what's causing it?
Domotica/graphs "freak" :)
NUC8i3BEH(8gb/250gb),
Lubuntu 19.04,
Aeotec Z-Stick S2(Gen5)
HarmonyElite
HUE(5 bulbs, 2 blooms)
NetAtmo(complete setup)
MiLight iboxV6(2 MiLightBulbs)
IP-Cam

https://www.frijduurzaam.nl
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: UserVariables not always set after Device Trigger Off[edit]

Post by waaren »

Freemann wrote: Thursday 07 February 2019 18:48 Any idea what's causing it?
I am sorry but no. I cannot reproduce the issue even with the exact same names. Until now no other forum member reported a similar issue with zwave devices so not much to work on either. Maybe if you switch on debug mode in dzVents and log to an OS file to show all relevant lines we will see more.
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: Bing [Bot], habahabahaba and 1 guest