if something is not equal to something then  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
snellejellep
Posts: 241
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Neterlands
Contact:

if something is not equal to something then

Post 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!
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

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

Post 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 
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
snellejellep
Posts: 241
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Neterlands
Contact:

Re: if something is not equal to something then

Post 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.
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: if something is not equal to something then

Post by waaren »

snellejellep wrote: Friday 10 January 2020 20:45 great! could not find that anywhere.
first hit on Google "Lua not equal"
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest