How to control with a Selector Switch (zigbee device) [Solved]
Moderator: leecollings
-
- Posts: 200
- Joined: Thursday 20 December 2018 11:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
How to control with a Selector Switch (zigbee device)
Hi,
I recently bought a zigbee TuYa wireless wall switch (2 buttons).
The domoticz-zigbee2mqtt-plug-in has created a Selector Switch with 6 levels (1_single, 1_double, 1_hold, 2_single, 2_double, 2_hold)
Each button has 3 actions (single click, double click and long press)
I want create a script which e.g. clicking "1_single", turns a group or device ON and clicking "1_double" turns this group or device OFF
Does anyone has an example ho to approach this?
I recently bought a zigbee TuYa wireless wall switch (2 buttons).
The domoticz-zigbee2mqtt-plug-in has created a Selector Switch with 6 levels (1_single, 1_double, 1_hold, 2_single, 2_double, 2_hold)
Each button has 3 actions (single click, double click and long press)
I want create a script which e.g. clicking "1_single", turns a group or device ON and clicking "1_double" turns this group or device OFF
Does anyone has an example ho to approach this?
- waltervl
- Posts: 5859
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: How to control a Selector Switch (zigbee device)
It is easier to toggle the group with only 1_single.
You can do this with a dzvents script. It can check the status of the group and then toggle it on or off.
See for example viewtopic.php?t=25062
You can do this with a dzvents script. It can check the status of the group and then toggle it on or off.
See for example viewtopic.php?t=25062
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Re: How to control a Selector Switch (zigbee device)
I had to add 4 Selector Levels (per switch): Off, Click, Hold, Release. Then in the event handler you can check the level
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: How to control a Selector Switch (zigbee device)
Below script could be a solution for thisgschmidt wrote: ↑Monday 14 December 2020 19:49 The domoticz-zigbee2mqtt-plug-in has created a Selector Switch with 6 levels (1_single, 1_double, 1_hold, 2_single, 2_double, 2_hold)
I want create a script which e.g. clicking "1_single", turns a group or device ON and clicking "1_double" turns this group or device OFF
Does anyone has an example how to approach this?
Code: Select all
local ZSelector = 'Zigbee selector' -- change to name of your selector
return
{
on =
{
devices =
{
ZSelector,
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all OK
marker = ZSelector,
},
execute = function(dz, item)
-- enter your devices and controls below this line
local group_1 = dz.groups('testGroup1')
local device_2 = dz.devices('testDevice2')
local Z =
{-- levelname targetDevice, action, delay, level -- delay and level are optional
['1_single'] = { group_1, 'On' },
['1_double'] = { group_1, 'Off' },
['1_hold'] = {group_1, 'Off', 30 },
['2_single'] = { device_2, 'On' },
['2_double'] = { device_2, 'dimTo', 12, 60 },
['2_hold'] = { device_2, 'dimTo', 0, 10 } -- when level is set and no delay the delay should be set to 0
}
-- No changes required below this line
local function switch(object, action, delay, level)
object.cancelQueuedCommands()
if action == 'Off' then object.switchOff().afterSec(delay)
elseif action == 'On' then object.switchOn().afterSec(delay)
elseif action == 'dimTo' and object.isDevice then object.dimTo(level).afterSec(delay) -- dimTo not available to groups
else
dz.log('unknown action (' .. action ..') please report.', dz.LOG_ERROR)
end
end
local row = Z[item.levelName]
switch(row[1], row[2], ( row[3] or 0 ), row[4] )
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
-
- Posts: 200
- Joined: Thursday 20 December 2018 11:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to control a Selector Switch (zigbee device)
Thanx for the example script!waaren wrote: ↑Monday 14 December 2020 21:12Below script could be a solution for thisgschmidt wrote: ↑Monday 14 December 2020 19:49 The domoticz-zigbee2mqtt-plug-in has created a Selector Switch with 6 levels (1_single, 1_double, 1_hold, 2_single, 2_double, 2_hold)
I want create a script which e.g. clicking "1_single", turns a group or device ON and clicking "1_double" turns this group or device OFF
Does anyone has an example how to approach this?
However, the following error is repeatedly shown (also when no action is performed) in the LOG:
Code: Select all
2020-12-14 22:16:34.803 Error: dzVents: Error: (3.0.18) error loading module 'Script #1' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/Script #1.lua':
2020-12-14 22:16:34.803 ...domoticz/scripts/dzVents/generated_scripts/Script #1.lua:28: '}' expected (to close '{' at line 27) near '_single'
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: How to control a Selector Switch (zigbee device)
OK, my bad.. Lua does not like the keys to start with a number. Can you try again after changing the Z table declaration togschmidt wrote: ↑Monday 14 December 2020 22:25 However, the following error is repeatedly shown (also when no action is performed) in the LOG:Code: Select all
2020-12-14 22:16:34.803 Error: dzVents: Error: (3.0.18) error loading module 'Script #1' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/Script #1.lua': 2020-12-14 22:16:34.803 ...domoticz/scripts/dzVents/generated_scripts/Script #1.lua:28: '}' expected (to close '{' at line 27) near '_single'
Code: Select all
local Z =
{-- levelname targetDevice, action, delay, level -- delay and level are optional
['1_single'] = { group_1, 'On' },
['1_double'] = { group_1, 'Off' },
['1_hold'] = {group_1, 'Off', 30 },
['2_single'] = { device_2, 'On' },
['2_double'] = { device_2, 'dimTo', 12, 60 },
['2_hold'] = { device_2, 'dimTo', 0, 10 } -- when level is set and no delay the delay should be set to 0
}
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
-
- Posts: 200
- Joined: Thursday 20 December 2018 11:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to control a Selector Switch (zigbee device)
Works like a charm (only a small error you forgot the () after switchOn)waaren wrote: ↑Monday 14 December 2020 22:30OK, my bad.. Lua does not like the keys to start with a number. Can you try again after changing the Z table declaration togschmidt wrote: ↑Monday 14 December 2020 22:25 However, the following error is repeatedly shown (also when no action is performed) in the LOG:Code: Select all
2020-12-14 22:16:34.803 Error: dzVents: Error: (3.0.18) error loading module 'Script #1' from file '/home/pi/domoticz/scripts/dzVents/generated_scripts/Script #1.lua': 2020-12-14 22:16:34.803 ...domoticz/scripts/dzVents/generated_scripts/Script #1.lua:28: '}' expected (to close '{' at line 27) near '_single'
Code: Select all
local Z = {-- levelname targetDevice, action, delay, level -- delay and level are optional ['1_single'] = { group_1, 'On' }, ['1_double'] = { group_1, 'Off' }, ['1_hold'] = {group_1, 'Off', 30 }, ['2_single'] = { device_2, 'On' }, ['2_double'] = { device_2, 'dimTo', 12, 60 }, ['2_hold'] = { device_2, 'dimTo', 0, 10 } -- when level is set and no delay the delay should be set to 0 }
Code: Select all
elseif action == 'On' then object.switchOn.afterSec(delay)
-
- Posts: 200
- Joined: Thursday 20 December 2018 11:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to control with a Selector Switch (zigbee device)
If my device is a RGBW dimmer what functions need to be added to control the Color and White?
So lets say under ['1_hold'] I want to set the RGB color to setRGB(255,0,0) and dimto level 70
Code: Select all
local function switch(object, action, delay, level)
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: How to control with a Selector Switch (zigbee device)
Can you test this one?
Code: Select all
local ZSelector = 'Zigbee selector' -- change to name of your selector
return
{
on =
{
devices =
{
ZSelector,
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all OK
marker = ZSelector,
},
execute = function(dz, item)
-- enter your devices and controls below this line
local group_1 = dz.groups('testGroup1')
local device_2 = dz.devices('testDevice2')
local Z =
{-- levelname targetDevice, action, delay, value -- delay and value are optional
['1_single'] = { group_1, 'On' },
['1_double'] = { group_1, 'Off' },
-- R, G, B, dimlevel
['1_hold'] = {device_2, 'setColor', 0, { 255, 0, 0, 70 } },
['2_single'] = { device_2, 'On' },
['2_double'] = { device_2, 'dimTo', 12, 60 },
['2_hold'] = { device_2, 'dimTo', 0, 10 } -- when level is set and no delay the delay should be set to 0
}
-- No changes required below this line
local function switch(object, action, delay, value)
object.cancelQueuedCommands()
if action == 'Off' then object.switchOff().afterSec(delay)
elseif action == 'On' then object.switchOn().afterSec(delay)
elseif action == 'dimTo' and object.isDevice then object.dimTo(value).afterSec(delay) -- dimTo not available to groups
elseif action == 'setColor' and object.isDevice then object.setColor(value[1], value[2], value[3], value[4]).afterSec(delay)
else
dz.log('unknown action (' .. action ..') for object ' .. object.name .. ' ( a ' .. object.baseType ..'). Please report.', dz.LOG_ERROR)
end
end
local row = Z[item.levelName]
switch(row[1], row[2], ( row[3] or 0 ), row[4] ) -- object (device / group), action, delay, value
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
-
- Posts: 200
- Joined: Thursday 20 December 2018 11:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to control with a Selector Switch (zigbee device)
Thanx man, this script is working (I have changed the order of the selector buttons a bit, and set the color to green):
Code: Select all
local ZSelector = 'Woonkamer_Switch' -- change to name of your selector
return
{
on =
{
devices =
{
ZSelector,
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all OK
marker = ZSelector,
},
execute = function(dz, item)
-- enter your devices and controls below this line
local group_1 = dz.groups('Kerstverlichting')
local device_2 = dz.devices('Woonkamer_Licht')
local Z =
{-- levelname targetDevice, action, delay, value -- delay and value are optional
['1_single'] = { group_1, 'On' },
['1_double'] = { group_1, 'Off' },
['1_hold'] = {group_1, 'Off', 30 },
['2_single'] = { device_2, 'On' },
['2_double'] = { device_2, 'Off' },
-- R, G, B, dimlevel
['2_hold'] = {device_2, 'setColor', 0, { 0, 255, 0, 70 } },
}
-- No changes required below this line
local function switch(object, action, delay, value)
object.cancelQueuedCommands()
if action == 'Off' then object.switchOff().afterSec(delay)
elseif action == 'On' then object.switchOn().afterSec(delay)
elseif action == 'dimTo' and object.isDevice then object.dimTo(value).afterSec(delay) -- dimTo not available to groups
elseif action == 'setColor' and object.isDevice then object.setColor(value[1], value[2], value[3], value[4]).afterSec(delay)
else
dz.log('unknown action (' .. action ..') for object ' .. object.name .. ' ( a ' .. object.baseType ..'). Please report.', dz.LOG_ERROR)
end
end
local row = Z[item.levelName]
switch(row[1], row[2], ( row[3] or 0 ), row[4] ) -- object (device / group), action, delay, value
end
}
Code: Select all
2020-12-16 20:02:23.161 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-12-16 20:02:30.049 Status: dzVents: Info: Handling events for: "Woonkamer_Switch", value: "2_hold"
2020-12-16 20:02:30.049 Status: dzVents: Info: Woonkamer_Switch: ------ Start internal script: Script #1: Device: "Woonkamer_Switch (Zigbee2MQTT)", Index: 527
2020-12-16 20:02:30.050 Status: dzVents: Debug: Woonkamer_Switch: Processing device-adapter for Kerstverlichting: Group device adapter
2020-12-16 20:02:30.051 Status: dzVents: Debug: Woonkamer_Switch: Processing device-adapter for Woonkamer_Licht: RGB(W) device adapter
2020-12-16 20:02:30.051 Status: dzVents: Debug: Woonkamer_Switch: Processing device-adapter for Woonkamer_Licht: Switch device adapter
2020-12-16 20:02:30.051 Status: dzVents: Debug: Woonkamer_Switch: OpenURL: url = http://127.0.0.1:9090/json.htm?type=command¶m=setcolbrightnessvalue&idx=534&brightness=70&color={"m":3,"t":0,"cw":0,"ww":0,"r":0,"g":255,"b":0}
2020-12-16 20:02:30.051 Status: dzVents: Debug: Woonkamer_Switch: OpenURL: method = GET
2020-12-16 20:02:30.051 Status: dzVents: Debug: Woonkamer_Switch: OpenURL: post data = nil
2020-12-16 20:02:30.051 Status: dzVents: Debug: Woonkamer_Switch: OpenURL: headers = nil
2020-12-16 20:02:30.051 Status: dzVents: Debug: Woonkamer_Switch: OpenURL: callback = nil
2020-12-16 20:02:30.051 Status: dzVents: Info: Woonkamer_Switch: ------ Finished Script #1
2020-12-16 20:02:30.053 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
2020-12-16 20:02:30.066 Status: setcolbrightnessvalue: ID: 216, bri: 70, color: '{m: 3, RGB: 00ff00, CWWW: 0000, CT: 0}
Code: Select all
2020-12-16 20:02:30.066 Status: setcolbrightnessvalue: ID: 216, bri: 70, color: '{m: 3, RGB: 00ff00, CWWW: 0000, CT: 0}
When I manually change the WW color temperature of the "dz.devices('Woonkamer_Licht')" to the value I want, the log show this:
Code: Select all
2020-12-16 19:49:52.450 Status: setcolbrightnessvalue: ID: 216, bri: 61, color: '{m: 2, RGB: 000000, CWWW: 59a6, CT: 166}'
-
- Posts: 200
- Joined: Thursday 20 December 2018 11:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to control with a Selector Switch (zigbee device)
I already figured it out myself...half...
Just added the extra attributes
color temp change is working.....only dimlevel is not working
Just added the extra attributes
color temp change is working.....only dimlevel is not working
Code: Select all
local ZSelector = 'Woonkamer_Switch' -- change to name of your selector
return
{
on =
{
devices =
{
ZSelector,
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all OK
marker = ZSelector,
},
execute = function(dz, item)
-- enter your devices and controls below this line
local group_1 = dz.groups('Kerstverlichting')
local device_2 = dz.devices('Woonkamer_Licht')
local Z =
{-- levelname targetDevice, action, delay, value -- delay and value are optional
['1_single'] = { group_1, 'On' },
['1_double'] = { group_1, 'Off' },
['1_hold'] = {group_1, 'Off', 30 },
['2_single'] = { device_2, 'On' },
['2_double'] = { device_2, 'Off' },
-- setColor(r, g, b, br, cw, ww, m, t, dimlevel)
['2_hold'] = {device_2, 'setColor', 0, { 0, 0, 0, 50, 119, 225, 2, 225, 10 } },
}
-- No changes required below this line
local function switch(object, action, delay, value)
object.cancelQueuedCommands()
if action == 'Off' then object.switchOff().afterSec(delay)
elseif action == 'On' then object.switchOn().afterSec(delay)
elseif action == 'dimTo' and object.isDevice then object.dimTo(value).afterSec(delay) -- dimTo not available to groups
elseif action == 'setColor' and object.isDevice then object.setColor(value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8], value[9]).afterSec(delay)
else
dz.log('unknown action (' .. action ..') for object ' .. object.name .. ' ( a ' .. object.baseType ..'). Please report.', dz.LOG_ERROR)
end
end
local row = Z[item.levelName]
switch(row[1], row[2], ( row[3] or 0 ), row[4] ) -- object (device / group), action, delay, value
end
}
-
- Posts: 200
- Joined: Thursday 20 December 2018 11:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to control with a Selector Switch (zigbee device)
Ah stupid.....the 'br' attribute is the brightness....so dimto() is not needed if 'br' is set
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: How to control with a Selector Switch (zigbee device)
m is the colormode. Here set to 2 ; see the
the method setColor accepts more parms (see the API wiki and the dzVents wiki
If I understand you correctly you could try with
Code: Select all
local ZSelector = 'Woonkamer_Switch' -- change to name of your selector
return
{
on =
{
devices =
{
ZSelector,
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all OK
marker = ZSelector,
},
execute = function(dz, item)
-- enter your devices and controls below this line
local group_1 = dz.groups('Kerstverlichting')
local device_2 = dz.devices('Woonkamer_Licht')
local Z =
{-- levelname targetDevice, action, delay, value -- delay and value are optional
['1_single'] = { group_1, 'On' },
['1_double'] = { group_1, 'Off' },
['1_hold'] = {group_1, 'Off', 30 },
['2_single'] = { device_2, 'On' },
['2_double'] = { device_2, 'Off' },
-- R, G, B, dimlevel, cw, ww, m, t (dimlevel, cw, ww, m and t are optional)
['2_hold'] = {device_2, 'setColor', 0, { 0, 255, 0, 70, 89, 166, 2, 166 } },
}
-- No changes required below this line
local function switch(object, action, delay, value)
object.cancelQueuedCommands()
if action == 'Off' then object.switchOff().afterSec(delay)
elseif action == 'On' then object.switchOn().afterSec(delay)
elseif action == 'dimTo' and object.isDevice then object.dimTo(value).afterSec(delay) -- dimTo not available to groups
elseif action == 'setColor' and object.isDevice then object.setColor(value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8]).afterSec(delay)
else
dz.log('unknown action (' .. action ..') for object ' .. object.name .. ' ( a ' .. object.baseType ..'). Please report.', dz.LOG_ERROR)
end
end
local row = Z[item.levelName]
switch(row[1], row[2], ( row[3] or 0 ), row[4] ) -- object (device / group), action, delay, value
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
-
- Posts: 200
- Joined: Thursday 20 December 2018 11:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to control with a Selector Switch (zigbee device)
I already figured it out myself....like this: (br = dimLevel)waaren wrote: ↑Wednesday 16 December 2020 21:07m is the colormode. Here set to 2 ; see the
the method setColor accepts more parms (see the API wiki and the dzVents wiki
If I understand you correctly you could try with
Code: Select all
local ZSelector = 'Woonkamer_Switch' -- change to name of your selector return { on = { devices = { ZSelector, }, }, logging = { level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all OK marker = ZSelector, }, execute = function(dz, item) -- enter your devices and controls below this line local group_1 = dz.groups('Kerstverlichting') local device_2 = dz.devices('Woonkamer_Licht') local Z = {-- levelname targetDevice, action, delay, value -- delay and value are optional ['1_single'] = { group_1, 'On' }, ['1_double'] = { group_1, 'Off' }, ['1_hold'] = {group_1, 'Off', 30 }, ['2_single'] = { device_2, 'On' }, ['2_double'] = { device_2, 'Off' }, -- R, G, B, dimlevel, cw, ww, m, t (dimlevel, cw, ww, m and t are optional) ['2_hold'] = {device_2, 'setColor', 0, { 0, 255, 0, 70, 89, 166, 2, 166 } }, } -- No changes required below this line local function switch(object, action, delay, value) object.cancelQueuedCommands() if action == 'Off' then object.switchOff().afterSec(delay) elseif action == 'On' then object.switchOn().afterSec(delay) elseif action == 'dimTo' and object.isDevice then object.dimTo(value).afterSec(delay) -- dimTo not available to groups elseif action == 'setColor' and object.isDevice then object.setColor(value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8]).afterSec(delay) else dz.log('unknown action (' .. action ..') for object ' .. object.name .. ' ( a ' .. object.baseType ..'). Please report.', dz.LOG_ERROR) end end local row = Z[item.levelName] switch(row[1], row[2], ( row[3] or 0 ), row[4] ) -- object (device / group), action, delay, value end }
Code: Select all
local ZSelector = 'Woonkamer_Switch' -- Script for wall switch to control RGBWW devices
return
{
on =
{
devices =
{
ZSelector,
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all OK
marker = ZSelector,
},
execute = function(dz, item)
-- enter your devices and controls below this line
local group_1 = dz.groups('Kerstverlichting')
local device_2 = dz.devices('Woonkamer_Licht')
local Z =
{-- levelname targetDevice, action, delay, value -- delay and value are optional
['1_single'] = { group_1, 'On' },
['1_double'] = { group_1, 'Off' },
['1_hold'] = {group_1, 'Off', 30 },
-- setColor attributes (r, g, b, br, cw, ww, m, t)
['2_single'] = {device_2, 'setColor', 0, { 0, 0, 0, 70, 119, 180, 2, 180 } },
['2_double'] = { device_2, 'Off' },
['2_hold'] = {device_2, 'setColor', 0, { 0, 0, 0, 2, 119, 180, 2, 180 } },
}
-- No changes required below this line
local function switch(object, action, delay, value)
object.cancelQueuedCommands()
if action == 'Off' then object.switchOff().afterSec(delay)
elseif action == 'On' then object.switchOn().afterSec(delay)
elseif action == 'dimTo' and object.isDevice then object.dimTo(value).afterSec(delay) -- dimTo not available to groups
elseif action == 'setColor' and object.isDevice then object.setColor(value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8]).afterSec(delay)
else
dz.log('unknown action (' .. action ..') for object ' .. object.name .. ' ( a ' .. object.baseType ..'). Please report.', dz.LOG_ERROR)
end
end
local row = Z[item.levelName]
switch(row[1], row[2], ( row[3] or 0 ), row[4] ) -- object (device / group), action, delay, value
end
}
-
- Posts: 200
- Joined: Thursday 20 December 2018 11:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to control with a Selector Switch (zigbee device)
Hi,
I am using this dzVents Wall Switch script for a while now.
But I was wondering if it is possible to turn off this group:
and at the same time silently dimTo(80) device_1?
device_1 is a dimmer switch (dimming a group of zigbee bulbs) which, is part of group_1
I also voice control this dimmer switch but it remembers the last dimming level when turned on with Google Home voice.
Now if the Wall_Switch turns off group_1, after ['1_hold'] was selected (which dimTo(30) device_1), Google Home remembers the last dimming level 30. Therefor I want to Turn Off group_1 and silently dimTo(80) device_1
I am using this dzVents Wall Switch script for a while now.
Code: Select all
local ZSelector = 'Woonkamer_Switch' -- Script for wall switch to control RGBWW devices
return
{
on =
{
devices =
{
ZSelector,
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all OK
marker = ZSelector,
},
execute = function(dz, item)
-- enter your devices and controls below this line
local group_1 = dz.groups('Woonkamer Lampen')
local device_1 = dz.devices('Woonkamer_Licht')
local device_2 = dz.devices('Tafel_Lamp')
local Z =
{
-- levelname targetDevice, action, delay, value -- delay and value are optional
['1_single'] = { group_1, 'On' },
['1_double'] = { group_1, 'Off' },
['1_hold'] = { device_1, 'setColor', 0, { 0, 0, 0, 30, 0, 180, 2, 180 } },
-- setColor attributes (r, g, b, br, cw, ww, m, t) -- m:3 is RGB & m:2 WW mode
['2_single'] = { device_2, 'dimTo', 0, 15 },
['2_double'] = { device_2, 'Off' },
['2_hold'] = { device_2, 'dimTo', 0, 70 },
}
-- No changes required below this line
local function switch(object, action, delay, value)
object.cancelQueuedCommands()
if action == 'Off' then object.switchOff().afterSec(delay)
elseif action == 'On' then object.switchOn().afterSec(delay)
elseif action == 'dimTo' and object.isDevice then object.dimTo(value).afterSec(delay) -- dimTo not available to groups
elseif action == 'setColor' and object.isDevice then object.setColor(value[1], value[2], value[3], value[4], value[5], value[6], value[7], value[8]).afterSec(delay)
else
dz.log('unknown action (' .. action ..') for object ' .. object.name .. ' ( a ' .. object.baseType ..'). Please report.', dz.LOG_ERROR)
end
end
local row = Z[item.levelName]
switch(row[1], row[2], ( row[3] or 0 ), row[4] ) -- object (device / group), action, delay, value
end
}
Code: Select all
['1_double'] = { group_1, 'Off' },
device_1 is a dimmer switch (dimming a group of zigbee bulbs) which, is part of group_1
I also voice control this dimmer switch but it remembers the last dimming level when turned on with Google Home voice.
Now if the Wall_Switch turns off group_1, after ['1_hold'] was selected (which dimTo(30) device_1), Google Home remembers the last dimming level 30. Therefor I want to Turn Off group_1 and silently dimTo(80) device_1
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: How to control with a Selector Switch (zigbee device)
The dimTo(80) will switch device-1 to On with dimlevel 80. The option silent will only prevent any subsequent script from being triggered.gschmidt wrote: ↑Monday 29 March 2021 20:50 But I was wondering if it is possible to turn off this group:and at the same time silently dimTo(80) device_1?Code: Select all
['1_double'] = { group_1, 'Off' },
Would it be possible to change the google Home command from switchOn() to dimTo(30) ?
The dimTo(30) is also an implicit switchOn()
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
-
- Posts: 200
- Joined: Thursday 20 December 2018 11:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: How to control with a Selector Switch (zigbee device) [Solved]
Okay I get it.waaren wrote: ↑Monday 29 March 2021 21:25The dimTo(80) will switch device-1 to On with dimlevel 80. The option silent will only prevent any subsequent script from being triggered.gschmidt wrote: ↑Monday 29 March 2021 20:50 But I was wondering if it is possible to turn off this group:and at the same time silently dimTo(80) device_1?Code: Select all
['1_double'] = { group_1, 'Off' },
Would it be possible to change the google Home command from switchOn() to dimTo(30) ?
The dimTo(30) is also an implicit switchOn()
I can add group_1 (which dims device_1 to 80) also to Google Home (wih Controlicz), so that would be my second option.
The only thing I need to do is rename the Room name in Google or the dz Group Name (they are now equal: "Woonkamer"), which confuses google.
I was trying avoid that but now I have to.
thanx!
[update] already working
Who is online
Users browsing this forum: No registered users and 1 guest