Page 1 of 1

if something is not equal to something then

Posted: Friday 10 January 2020 17:11
by snellejellep
i have a question, i want a script to take an action if a switch is activated, the switch has a couple of possible states but i want to take the same action for every possible state except off. so is it possible to say something like: "if switch is not equal to off then..."?

i hope this is possible. thanks to the solution in advance!

Re: if something is not equal to something then  [Solved]

Posted: Friday 10 January 2020 17:54
by waaren
snellejellep wrote: Friday 10 January 2020 17:11 i have a question, i want a script to take an action if a switch is activated, the switch has a couple of possible states but i want to take the same action for every possible state except off. so is it possible to say something like: "if switch is not equal to off then..."?

i hope this is possible. thanks to the solution in advance!
Yes Lua uses == for equal and ~= for unequal so code would look like

Code: Select all

if domoticz.devices('switchName').state ~= 'Off' then 

Re: if something is not equal to something then

Posted: Friday 10 January 2020 20:45
by snellejellep
waaren wrote: Friday 10 January 2020 17:54
Yes Lua uses == for equal and ~= for unequal so code would look like

Code: Select all

if domoticz.devices('switchName').state ~= 'Off' then 
great! could not find that anywhere.

Re: if something is not equal to something then

Posted: Saturday 11 January 2020 8:41
by waaren
snellejellep wrote: Friday 10 January 2020 20:45 great! could not find that anywhere.
first hit on Google "Lua not equal"