I've made a LUA script that updates a selector switch when I press the remote and domoticz notices that the switch has changed.
And if I press the selector switch, it will send the corresponding switch command to the harmony hub. WIth LUA I did this with the 'changeddevice' and 'otherdevice'
I am trying to update this script to dzVentz, but I'm stuck in a loop. Whenever I press a button on the remote, or on the selector switch, my system will turn off/on/off/on/etc.
This is my script. Can anyone point me to what I am doing wrong?
Code: Select all
return {
active = true,
on = {
devices = {
'Harmony Hub', -- selector switch level names: 'Uit', 'Media', 'TV', 'Spotify', 'Switch', 'Wii'
'$Harmony_PowerOff', -- harmony hub switch
'$Harmony_Mediacenter', -- harmony hub switch
'$Harmony_TV', -- harmony hub switch
'$Harmony_Spotify', -- harmony hub switch
'$Harmony_Switch', -- harmony hub switch
'$Harmony_Wii' -- harmony hub switch
},
},
execute = function(domoticz, devices)
if (domoticz.devices('Harmony Hub').state == 'Uit') and
(domoticz.devices('$Harmony_PowerOff').state == 'Off')
then domoticz.devices('$Harmony_PowerOff').switchOn().checkFirst()
elseif (domoticz.devices('$Harmony_PowerOff').state == 'On') and
(domoticz.devices('Harmony Hub').state ~= 'Uit')
then domoticz.devices('Harmony Hub').switchSelector('Uit')
end
if (domoticz.devices('Harmony Hub').state == 'Media') and
(domoticz.devices('$Harmony_Mediacenter').state == 'Off')
then domoticz.devices('$Harmony_Mediacenter').switchOn().checkFirst()
elseif (domoticz.devices('$Harmony_Mediacenter').state == 'On') and
(domoticz.devices('Harmony Hub').state ~= 'Media')
then domoticz.devices('Harmony Hub').switchSelector('Media')
end
end
}