Hello
I am struggling with the following problem. I have an ELRO switch with 4 positions On and Off. With this switch I want to switch on 4 different scenes. I have already tried it in different ways but they don't work or they influence each other. I am probably using the wrong structure. Who can help me on my way.
return {
on = {
devices = {
'Switch1_1',
'Switch1_2',
'Switch1_3',
'Switch1_4'
}
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when script is OK
marker = 'Slkmr_switch',
},
execute = function(dz, device, triggerInfo)
local Automaat = dz.devices('Automaat')
local Slapen = dz.devices('Slapen')
if(Automaat.state=='On') then
if ( device . name == 'Switch1_1' and device .name. state=='On') then
dz.scenes('sc_bedverlichting_100').switchOn()
end
if ( device . name == 'Switch1_2' and device .name. state=='On') then
dz.scenes('sc_bedverlichting_50').switchOn()
end
if ( device . name == 'Switch1_3' and device .name. state=='On') then
dz.scenes('sc_bedverlichting_10').switchOn()
end
if ( device . name == 'Switch1_4' and device .name. state=='On') then
dz.scenes('sc_bedverlichting_tv').switchOn()
end
if ( device . name == 'Switch1_1' and device .name. state=='Off') then
dz.scenes('sc_bedverlichting_uit').switchOn()
end
end
end
}
kroonp wrote: ↑Thursday 10 December 2020 22:01
Hello
I am struggling with the following problem. I have an ELRO switch with 4 positions On and Off. With this switch I want to switch on 4 different scenes. I have already tried it in different ways but they don't work or they influence each other. I am probably using the wrong structure. Who can help me on my way.
I don't know if the syntax errors were the only reason but can you try below script?
If not yet OK then please include log of the execution and show what you expected and what actually happened.
return
{
on =
{
devices =
{
'Switch1_*',
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when script is OK
marker = 'Slkmr_switch',
},
execute = function(dz, device)
local Automaat = dz.devices('Automaat')
local Slapen = dz.devices('Slapen')
if Automaat.state == 'On' then
if device.name == 'Switch1_1' and device.state == 'On' then
dz.scenes('sc_bedverlichting_100').switchOn()
elseif device.name == 'Switch1_2' and device.state == 'On' then
dz.scenes('sc_bedverlichting_50').switchOn()
elseif device.name == 'Switch1_3' and device.state == 'On' then
dz.scenes('sc_bedverlichting_10').switchOn()
elseif device.name == 'Switch1_4' and device.state == 'On' then
dz.scenes('sc_bedverlichting_tv').switchOn()
elseif device.name == 'Switch1_1' and device.state == 'Off' then
dz.scenes('sc_bedverlichting_uit').switchOn()
end
end
end
}
Hello waaren
Thank you very much for the quick answer. Your solution works fine. (As always). I have learned a lot again. Thank you for doing this work to help people move forward.
Have a nice day.
Peter