Page 1 of 1
no trigger when a selector is switched off
Posted: Saturday 14 March 2020 19:57
by hestia
hello
I have a dummy selector
0 Off
10 Level1
20 Level2
30 Level3
and this script
Code: Select all
local SELECTOR_ID = 1039
return {
active = true,
logging = {
level = domoticz.LOG_DEBUG,
},
on = {
devices = {SELECTOR_ID},
},
execute = function(dz, device)
_G.logMarker = _G.moduleLabel
dz.log("SELECTOR " .. device.state .. " " .. tostring(device.level) .. " actif: " .. tostring(device.active), LOG_LEVEL)
end
}
1/
When I click Level2, the bulb in the widget switches on and the script is triggered: normal and ok for me
When I click the bulb is the widget, the bulb in the widget switches off but the script is NOT triggered
So I don't know the device is off.
Is this normal?... for me not!
2/
In any case the device is active, even when I select 0 Off
Is this normal? ... for me not!
Version: 4.11605
Build Hash: 7de1f368f
Compile Date: 2020-01-08 23:12:15
dzVents Version: 2.5.5
Re: no trigger when a selector is switched off [Solved]
Posted: Sunday 15 March 2020 9:12
by waaren
hestia wrote: Saturday 14 March 2020 19:57
When I click the bulb is the widget, the bulb in the widget switches off but the script is NOT triggered
I don't see this behavior in V4.11777. Can you please execute below amended script and share the relevant log lines ?
In any case the device is active, even when I select 0 Off
Again I don't see this behavior in V4.11784
the attribute 'active' is primarily meant for Boolean type devices with opposite states like "On - Off', 'Open - Close', etc. For other types, including selectors, it should return false.
Code: Select all
return
{
on =
{
devices =
{
1039,
},
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'selector',
},
execute = function(dz, item)
dz.log(item.name .. " state: " .. item.state , dz.LOG_DEBUG)
dz.log(item.name .. " level: " .. item.level , dz.LOG_DEBUG)
dz.log(item.name .. " levelName: " .. item.levelName , dz.LOG_DEBUG)
dz.log(item.name .. " nValue: " .. item.nValue, dz.LOG_DEBUG)
end
}
Re: no trigger when a selector is switched off
Posted: Sunday 15 March 2020 12:18
by hestia
thanks for your reply
the log of the test
- Spoiler: show
-
20-03-15 10:58:23.042 Status: User: xxxxx initiated a switch command (1039/test/Set Level)
2020-03-15 10:58:23.215 Status: dzVents: Info: selector: ------ Start internal script: zSelectorw: Device: "test (Dummy1)", Index: 1039
2020-03-15 10:58:23.215 Status: dzVents: Debug: selector: test state: Level3
2020-03-15 10:58:23.215 Status: dzVents: Debug: selector: test level: 30
2020-03-15 10:58:23.215 Status: dzVents: Debug: selector: test levelName: Level3
2020-03-15 10:58:23.215 Status: dzVents: Debug: selector: test nValue: 2
2020-03-15 10:58:23.215 Status: dzVents: Info: selector: ------ Finished zSelectorw
2020-03-15 10:58:49.605 Status: User: xxxxx initiated a switch command (1039/test/Off)
2020-03-15 10:58:49.798 Status: dzVents: Info: selector: ------ Start internal script: zSelectorw: Device: "test (Dummy1)", Index: 1039
2020-03-15 10:58:49.798 Status: dzVents: Debug: selector: test state: Level3
2020-03-15 10:58:49.798 Status: dzVents: Debug: selector: test level: 30
2020-03-15 10:58:49.799 Status: dzVents: Debug: selector: test levelName: Level3
2020-03-15 10:58:49.799 Status: dzVents: Debug: selector: test nValue: 0
2020-03-15 10:58:49.799 Status: dzVents: Info: selector: ------ Finished zSelectorw
2020-03-15 10:59:07.023 Status: User: xxxxx initiated a switch command (1039/test/Set Level)
2020-03-15 10:59:07.125 Status: dzVents: Info: selector: ------ Start internal script: zSelectorw: Device: "test (Dummy1)", Index: 1039
2020-03-15 10:59:07.125 Status: dzVents: Debug: selector: test state: Level2
2020-03-15 10:59:07.125 Status: dzVents: Debug: selector: test level: 20
2020-03-15 10:59:07.125 Status: dzVents: Debug: selector: test levelName: Level2
2020-03-15 10:59:07.125 Status: dzVents: Debug: selector: test nValue: 2
2020-03-15 10:59:07.125 Status: dzVents: Info: selector: ------ Finished zSelectorw
2020-03-15 10:59:13.125 Status: User: xxxxx initiated a switch command (1039/test/Set Level)
2020-03-15 10:59:13.288 Status: dzVents: Info: selector: ------ Start internal script: zSelectorw: Device: "test (Dummy1)", Index: 1039
2020-03-15 10:59:13.288 Status: dzVents: Debug: selector: test state: Off
2020-03-15 10:59:13.288 Status: dzVents: Debug: selector: test level: 0
2020-03-15 10:59:13.288 Status: dzVents: Debug: selector: test levelName: Off
2020-03-15 10:59:13.289 Status: dzVents: Debug: selector: test nValue: 0
2020-03-15 10:59:13.289 Status: dzVents: Info: selector: ------ Finished zSelectorw
So I made a mistake yesterday, because when the bulb in the widget switches off, the script is actually triggered (I went back to yesterday's log and saw it!). I think I missed it because the log were the same with the "active" attribute and I didn't look very well the line "User: xxxxx initiated a switch command (1039/test/Off)"
Even though the attribute 'active' is not available, with nValue I could do what I need
Thanks again
