feature request: SwitchOnifOff/SwitchOffifOn [Solved]
Moderator: leecollings
feature request: SwitchOnifOff/SwitchOffifOn
Hi,
Sometimes you only want to switch states if the switch has the opposite state, is this possible to implement?
like:
if (domoticz.devices('Camera Woonkamer').state == 'Off') then
domoticz.devices('Camera Woonkamer').switchOn()
end
When using 'timed' scripts, this prevents unnecessary triggering if switch already has the right state
Or is there another way to do this?
Regards, Harry
Sometimes you only want to switch states if the switch has the opposite state, is this possible to implement?
like:
if (domoticz.devices('Camera Woonkamer').state == 'Off') then
domoticz.devices('Camera Woonkamer').switchOn()
end
When using 'timed' scripts, this prevents unnecessary triggering if switch already has the right state
Or is there another way to do this?
Regards, Harry
-
- Posts: 32
- Joined: Saturday 25 February 2017 18:42
- Target OS: Linux
- Domoticz version: 2021.1
- Location: Milano, Italy
- Contact:
Re: feature request: SwitchOnifOff/SwitchOffifOn
Hi SweetPants, you've read in my mind ... I'm searching in the forum for the same functinality!!!!!
Due to the fact that sometimes I I need to switch off a very amount of devices , and I don't want to fill the zwave queue with a lot of unnecessary command, I need to use this code :
As you, I wonder if there is a function that send zwave On / Off commands only if they are needed!!!
Due to the fact that sometimes I I need to switch off a very amount of devices , and I don't want to fill the zwave queue with a lot of unnecessary command, I need to use this code :
Code: Select all
if domoticz.devices(DISPOSITIVO).state ~= 'Off' then domoticz.devices(DISPOSITIVO).switchOff();end
As you, I wonder if there is a function that send zwave On / Off commands only if they are needed!!!
Sorry for any spelling mistake, English is not my native language.
DomoticZ running on Ubuntu 20.04 LTS , dzVents Version: 3.1.7 , Python Version: 3.8.5
DomoticZ running on Ubuntu 20.04 LTS , dzVents Version: 3.1.7 , Python Version: 3.8.5
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: feature request: SwitchOnifOff/SwitchOffifOn [Solved]
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 32
- Joined: Saturday 25 February 2017 18:42
- Target OS: Linux
- Domoticz version: 2021.1
- Location: Milano, Italy
- Contact:
Re: feature request: SwitchOnifOff/SwitchOffifOn
I'm on mobile phone and can't read the docs right now.... but this function ( due to the naming convention) seems a fuction to turn switch on if is off and viceversa ( this night I promise to read the docs) .... I need a function that when you ask for turn a device off , before call zwave stack check if the device is already off ( and in that case do nothig).
Inviato dal mio SM-G920F utilizzando Tapatalk
Inviato dal mio SM-G920F utilizzando Tapatalk
Sorry for any spelling mistake, English is not my native language.
DomoticZ running on Ubuntu 20.04 LTS , dzVents Version: 3.1.7 , Python Version: 3.8.5
DomoticZ running on Ubuntu 20.04 LTS , dzVents Version: 3.1.7 , Python Version: 3.8.5
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: feature request: SwitchOnifOff/SwitchOffifOn
Ah okay. Guess I didn't read it well myself
It's not that hard to add this I just want it to be elegant. Perhaps something like this:
Will only switch it off for 5 minutes when it is not already Off.
It's not that hard to add this I just want it to be elegant. Perhaps something like this:
Code: Select all
mywitch.switchOff().forMin(5).check()
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Re: feature request: SwitchOnifOff/SwitchOffifOn
Or just mywitch.switchOff().check() or a mix
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: feature request: SwitchOnifOff/SwitchOffifOn
That's what I was saying actually.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 32
- Joined: Saturday 25 February 2017 18:42
- Target OS: Linux
- Domoticz version: 2021.1
- Location: Milano, Italy
- Contact:
Re: feature request: SwitchOnifOff/SwitchOffifOn
I've tried to find out the documentation about the .check() instruction but I was not able to find it.
Also, I've tried to put this code in my dzVents script :
But it give me this error :
Can someone help me ?
Also, I've tried to put this code in my dzVents script :
Code: Select all
domoticz.devices('DEVICE NAME').switchOn().check()
Code: Select all
Error: dzVents: Error: ...domoticz/scripts/dzVents/generated_scripts/AAA_CHECK.lua:32: attempt to call field 'check' (a nil value)
Sorry for any spelling mistake, English is not my native language.
DomoticZ running on Ubuntu 20.04 LTS , dzVents Version: 3.1.7 , Python Version: 3.8.5
DomoticZ running on Ubuntu 20.04 LTS , dzVents Version: 3.1.7 , Python Version: 3.8.5
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: feature request: SwitchOnifOff/SwitchOffifOn
Dude.. it was only a suggestion for implementation 

Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 32
- Joined: Saturday 25 February 2017 18:42
- Target OS: Linux
- Domoticz version: 2021.1
- Location: Milano, Italy
- Contact:
Re: feature request: SwitchOnifOff/SwitchOffifOn
Ops ..... as in sign .... Sorry for any spelling mistake, English is not my native language






Sorry for any spelling mistake, English is not my native language.
DomoticZ running on Ubuntu 20.04 LTS , dzVents Version: 3.1.7 , Python Version: 3.8.5
DomoticZ running on Ubuntu 20.04 LTS , dzVents Version: 3.1.7 , Python Version: 3.8.5
-
- Posts: 116
- Joined: Friday 20 December 2013 7:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: feature request: SwitchOnifOff/SwitchOffifOn
Is it possible that dzVents checks the state of a device before it send a switchOn(), switchOff(), dimTo(), etc. command? Now I have to check the state of a device before I send a command.
Example:
This script runs every minute. And every minute the Security Panel gets the command Armed Home.
It could be nice if dzVents checks the state, in this example, the Security Panel and if it has already has the state "Armed Home", it does nothing and if it has another state, it will send the command.
Is this possible?
Example:
Code: Select all
if (domoticz.devices("Switch A").state == "On" and domoticz.devices("Switch B").state == "On") then
-- Armed Home
if (domoticz.devices("Switch A").lastUpdate.minutesAgo <= 5) then
domoticz.devices("Security Panel").disarm()
else
domoticz.devices("Security Panel").armHome()
end
end
It could be nice if dzVents checks the state, in this example, the Security Panel and if it has already has the state "Armed Home", it does nothing and if it has another state, it will send the command.
Is this possible?
-
- Posts: 32
- Joined: Saturday 25 February 2017 18:42
- Target OS: Linux
- Domoticz version: 2021.1
- Location: Milano, Italy
- Contact:
Re: feature request: SwitchOnifOff/SwitchOffifOn
Maybe you want something like this :
or
It is ok ?
Code: Select all
if domoticz.devices('Domoticz Security Panel').state == 'Armed Away' then
Code: Select all
if domoticz.devices('Domoticz Security Panel').state == 'Armed Home' then
Sorry for any spelling mistake, English is not my native language.
DomoticZ running on Ubuntu 20.04 LTS , dzVents Version: 3.1.7 , Python Version: 3.8.5
DomoticZ running on Ubuntu 20.04 LTS , dzVents Version: 3.1.7 , Python Version: 3.8.5
Who is online
Users browsing this forum: No registered users and 1 guest