I use a virtual selector that changes the real devices.
But when the real devices are switched outside domoticz I want that the selector got the correct state.
I try that with this script but running into:
2016-07-02 15:43:00.430 Error: EventSystem: in script_device_Tv: [string "commandArray = {}..."]:5: attempt to index global 'devicechanged' (a nil value)
Code: Select all
commandArray = {}
-- from selector to real devices
if devicechanged['TV'] == 'Ziggo' and otherdevices['$Harmony_TV'] ~= 'Off' then
commandArray['$Harmony_TV']='On'
print('selector gaat op tv en harmony stond <> Off')
elseif devicechanged['TV']== 'Kodi' and otherdevices['$Harmony_Kodi'] ~= 'On' then
commandArray['$Harmony_Kodi']='On'
print('selector gaat op Kodi en harmony stond <> kodi=aan')
elseif devicechanged['TV'] == 'Ps3' and otherdevices['$Harmony_Ps3'] ~= 'On' then
commandArray['$Harmony_Ps3']='On'
print('selector gaat op Ps3 en harmony stond <> PS3=aan')
elseif devicechanged['TV']=='Smart-tv' and otherdevices['$Harmony_Smart-tv'] ~= 'On' then
commandArray['$Harmony_Smart-tv']='On'
print('selector gaat op Smart-tv en harmony stond <> Smart-tv=aan')
elseif devicechanged['TV']=='Off' and otherdevices['$Harmony_PowerOffTV'] == 'Off' then
commandArray['$Harmony_PowerOffTV']='On'
print('selector gaat uit en harmoney stond al uit Off')
end
-- from realdevices to selector
if devicechanged['$Harmony_TV']=='On' and otherdevices['TV'] ~= 'Ziggo' then
commandArray['TV'] = 'Set Level 10'
elseif devicechanged['$Harmony_Kodi'] =='On' and otherdevices['TV'] ~= 'Kodi' then
commandArray['TV'] = 'Set Level 20'
elseif devicechanged['$Harmony_Ps3'] == 'On' and otherdevices['TV'] ~= 'Ps3' then
commandArray['TV'] = 'Set Level 30'
elseif devicechanged['$Smart-tv'] == 'On' and otherdevices['TV'] ~= 'Smart-tv' then
commandArray['TV'] = 'Set Level 40'
elseif devicechanged['$Harmony_PowerOffTV']=='On' and otherdevices['TV'] ~= 'Off' then
commandArray['TV'] = 'Set Level 0'
end
return commandArray