Well, you need to read the current switch status first with something like:simon_rb wrote:This is my script. It turns the switch off every minute, even if I don't change it. What do I have to add for the If device changes you mentioned earlier and that it only turns it off. Doesn't actually change the percentage on the device. Appreciate all your help with this!
Code: Select all
commandArray = {} json = (loadfile '/home/pi/domoticz/scripts/lua/json.lua')() file = assert(io.popen('curl \'http://192.168.1.26:9000/jsonrpc.js\' --data-binary \'{"id":1,"method":"slim.request","params":["00:04:20:23:88:36",["status","-","1",""]]}\'')) raw = file:read('*all') file:close() deviceinfo = json:decode(raw) volume = deviceinfo.result["mixer volume"] print(tostring(volume)) commandArray['UpdateDevice'] = '265|0|' .. volume return commandArray
Code: Select all
switchvolume = otherdevices_svalues['Switch Name']
Code: Select all
if tonumber(switchvolume) ~= tonumber(volume) then
your command here
end