Hello,
I have domoticz 2020.2 running in combination with zigbee2mqtt.
In dzevents I'm creating a simple script to control a group of lamp with a HUE switch (https://www.zigbee2mqtt.io/devices/324131092621.html) via zigbee2mqtt
However every time the you press a button on the Hue switch, the selector swith automaticly resets to level 0.
So each time 2 events are generated (the button you pressed + level 0 = off-press
For example, when you press the on button, the state of the selector switch changes to "on-press" and imeditatlly after is goes to state 0 "off-press"
So the script part of "off-press" is triggered always, and the lights go off after each trigger.
Can I change the behavior of the selector switch, so it does not automaticly resets to level 0?
The selector switch has the following levels:
-- off-press
-- off-press-double
-- off-press-triple
-- off-hold
-- off-hold-release
-- down-press
-- down-press-double
-- down-press-triple
-- down-hold
-- down-hold-release
-- up-press
-- up-press-double
-- up-press-triple
-- up-hold
-- up-hold-release
-- on-press
-- on-press-double
-- on-press-triple
-- on-hold
-- on-hold-release
[Solved] Hue selector switch automaticly resets to level 0
Moderator: leecollings
-
- Posts: 5
- Joined: Thursday 03 October 2019 16:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Contact:
[Solved] Hue selector switch automaticly resets to level 0
Last edited by klaasvaak on Tuesday 24 November 2020 19:20, edited 2 times in total.
Zigbee2MQTT, LAUNCHXL-CC26X2R1
-
- Posts: 5
- Joined: Thursday 03 October 2019 16:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Contact:
Re: Hue selector switch automaticly resets to level 0
I found a solution, by added an additional level 0 state which is not used by zigbee.
Added the following code in line 11 of ~/domoticz/plugins/zigbee2mqtt/adapters/philips/hue_dimmer_switch.py
Now it looks like:
Than deleted the selector switch and let domoticz add it automatically again.
Now my selector switch has "off" as level 0 and the problem is solved.
simple dzVents test script
Added the following code in line 11 of ~/domoticz/plugins/zigbee2mqtt/adapters/philips/hue_dimmer_switch.py
Code: Select all
self.switch.add_level('off', 'off')
Code: Select all
self.switch = SelectorSwitch(devices, 'dimmer', 'action')
self.switch.add_level('off', 'off')
self.switch.add_level('off-press', 'off-press')
self.switch.add_level('off-press-double', 'off-press-double')
Now my selector switch has "off" as level 0 and the problem is solved.
simple dzVents test script
Code: Select all
return {
on = {
devices = {
503 --Hue selector switch
}
},
--States selector switch:
-- off-press
-- off-press-double
-- off-press-triple
-- off-hold
-- off-hold-release
-- down-press
-- down-press-double
-- down-press-triple
-- down-hold
-- down-hold-release
-- up-press
-- up-press-double
-- up-press-triple
-- up-hold
-- up-hold-release
-- on-press
-- on-press-double
-- on-press-triple
-- on-hold
-- on-hold-release
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'Philips switch',
},
execute = function(domoticz, device)
--variabelen
knopid = 503 -- Hue selector switch
lampl = 'keukengroep' -- group of lights
-- wanneer op uit gedrukt
if domoticz.devices(knopid).state == 'off-press' then
domoticz.devices(lampl).dimTo(0)
-- up press
elseif domoticz.devices(knopid).state == 'up-press' then
domoticz.devices(lampl).dimTo(50)
-- down press
elseif domoticz.devices(knopid).state == 'down-press' then
domoticz.devices(lampl).dimTo(1)
-- on press
elseif domoticz.devices(knopid).state == 'on-press' then
domoticz.devices(lampl).dimTo(100)
elseif domoticz.devices(knopid).state == 'down-press-double' then
domoticz.devices(lampl).dimTo(1)
end
end
}
Zigbee2MQTT, LAUNCHXL-CC26X2R1
Who is online
Users browsing this forum: No registered users and 1 guest