Please move this topic somewhere else if you feel it is in the wrong place.
OK so my situation is that I have a remote switch that has 2 code wheels - House: A-P and Unit 1-16. It supports the old style of Byron/Homeeasy sockets that have the code wheel but not the new style learning sockets. I have the remote switch in a public area in the cafe but I do not want it to switch on the light during the day - eg prevent the public switching the light on.
First I created a virtual device called "v_Daytime" which Domoticz controls using a timer. ON 2 hours AFTER sunrise and OFF 2 hours BEFORE sunset (this copes with dark/overcast mornings and dark/overcast evenings)
Next the remote switch is called "CafeSwitch" and has a 15 minute timer on it.
The light is called "CafeLight" and is a standard on/off device with no timer.
My script is called "script_device_CafeLightSwitch.lua"
Code: Select all
commandArray = {}
if (devicechanged['CafeSwitch'] == 'On' and otherdevices['CafeLight'] == 'Off' and otherdevices['v_Daytime'] == 'Off') then
commandArray['CafeLight']='On'
print('CafeLight was switched ON')
end
if (devicechanged['CafeSwitch'] == 'Off') then
commandArray['CafeLight']='Off'
print('CafeLight was switched OFF')
end
if (devicechanged['CafeSwitch'] == 'On' and otherdevices['v_Daytime'] == 'On') then
commandArray['CafeSwitch']='Off'
print('CafeLight was switched ON but it\'s daytime!')
end
return commandArray
if the switch is turned off - day or night, the light is turned off
if the switch is turned on when it's night time - the light is turned on (and domoticz will turn it off after 15 minutes because of the timer on the switch)
Hope this helps someone get to grips with the LUA system.