I have python script with list of online radio stations.
Python script takes one argument, like so: "python_script.py OnlineRadioStationName".
This works fine when executed in shell, but I have a problem linking this script to domoticz.
Here is the domoticz lua script:
Code: Select all
commandArray = {}
if (devicechanged['OnlineRadio'] == 'Off') then
os.execute ("killall mplayer")
elseif (devicechanged['OnlineRadio']) then
uservariables['OdabranaStanica'] = devicechanged['OnlineRadio'];
--os.execute ("runuser -l pi -c \'python /home/pi/online_radio.py Otvoreni' &> /dev/null")
os.execute ("runuser -l pi -c \'python /home/pi/online_radio.py" ..OdabranaStanica.. "'&> /dev/null")
end
return commandArray
10- Off
20- RadioStation1
30- RadioStaion2
40- etc..
I can make script work by manually typing IF loop for each radiostation like so:
os.execute ("runuser -l pi -c \'python /home/pi/online_radio.py RadioStation1' &> /dev/null")
etc.
And this works!
However, I want more elegent way where RasioStationName argument will be variable which is populated from the status of dummy selector switch.
So, how to use variable in this case?
Script is triggered as Device, and then I get this error: 12: attempt to concatenate a nil value (global 'OdabranaStanica')
I can change trigger to User Variable, then there is no error, but also no response from the python script, it doesn't play radio station.