script error but can't find the fault. Nill device

Moderator: leecollings

Locked
User avatar
remb0
Posts: 499
Joined: Thursday 11 July 2013 22:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

script error but can't find the fault. Nill device

Post by remb0 »

what's wrong with my script? (script_device_Tv)
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
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: script error but can't find the fault. Nill device

Post by jvdz »

Is this an internal editor script and did you change the dropdown selection from All to Device under the LUA dropdown box?

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
remb0
Posts: 499
Joined: Thursday 11 July 2013 22:21
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: script error but can't find the fault. Nill device

Post by remb0 »

damn!!! I think that it! thank you. stupid that I didn't see that.
Locked

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest