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!
if something is not equal to something then [Solved]
Moderator: leecollings
-
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
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
- 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]
Yes Lua uses == for equal and ~= for unequal so code would look likesnellejellep 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!
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
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
great! could not find that anywhere.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
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
- 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
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: No registered users and 1 guest