1 Button for scenes. Qubino ZMNHDD1 i3

Moderator: leecollings

Post Reply
nickgosling
Posts: 33
Joined: Wednesday 06 January 2016 10:51
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

1 Button for scenes. Qubino ZMNHDD1 i3

Post by nickgosling »

So this is my first attempt with LUA. I haven't done any programming scripts since university and that is going back some years. But it works. I forgot how satisfying it is when a script runs correctly but it works anyway. All I wanted to do was set a scene with 1 button on a Qubino module, cycle through a few scenes and then turn everything Off. This works but I'm wondering if there is a simpler way to achieve it

So this is my script:

commandArray = {}
if (devicechanged['motion sensor'] == 'On' and otherdevices['Dummy 1'] == 'Off' and otherdevices['Dummy 2'] == 'Off') then
commandArray['Scene:Scene 1']='On'
commandArray['Dummy 1']='On'
end
if (devicechanged['motion sensor'] == 'On' and otherdevices['Dummy 1'] == 'On' and otherdevices['Dummy 2'] == 'Off') then
commandArray['Scene:Scene 2']='On'
commandArray['Dummy 2']='On'
commandArray['Dummy 1']='Off'
end
if (devicechanged['motion sensor'] == 'On' and otherdevices['Dummy 1'] == 'Off' and otherdevices['Dummy 2'] == 'On') then
commandArray['Scene:All off']='On'
commandArray['Dummy 2']='Off'
commandArray['Dummy 1']='Off'

end
return commandArray

As I'm new to the language if there are any language housekeeping things that would make this simpler then I would be keen to know them. Obviously my first issue is that if I change any names in Domoticz I will need to re write the scripts. The other thing would be I'm going to have a lot of Dummy switches to make this work throughout my house for all of the other rooms.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest