Trigger Switch A only when B changes state from On to off  [Solved]

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

Moderator: leecollings

Post Reply
superczar
Posts: 65
Joined: Wednesday 14 January 2015 12:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: India
Contact:

Trigger Switch A only when B changes state from On to off

Post by superczar »

TL;DR : I have a use-case which requires me to set Switch A to off when switch B switches off
However , I want this to happen only when switch B changes state from On to off i.e. if I switch A back On while B is off, it shouldn't be triggered off again.

Real life scenario - We get frequent powercuts, up to 2-3 a week
We have a DG backup that takes between a minute to two to start

When the utility power goes off, I have a ping switch that switches off and comes back on when utility power is back on
In such an event, I want my harmony hub to switch off my TV/AVR etc (which are on a UPS)
However, once the DG backup comes back on and if I switch the TV/AVR on again, standard blockly If-Do will trigger it back off unless the mains power is back again

I was hoping that I could trigger the harmony switch to off only when the ping switch changes state from on to off
For anything else (stays off or goes from off to on) , the harmony switch is not triggered

PS: Sorry if I missing something fundamental
I did read through the dzvents commented sample script but could not figure this out
snellejellep
Posts: 241
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Neterlands
Contact:

Re: Trigger Switch A only when B changes state from On to off  [Solved]

Post by snellejellep »

you could just put in the off action box in your switches properties a command like this:
http://127.0.0.1:8080/json.htm?type=com ... tchcmd=Off

edit the 200 after idx= to your switch a idx and put the command in the off action box in switch b

make sure you have whitelisted 127.0.0.* in the local networks in the settings menu
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
superczar
Posts: 65
Joined: Wednesday 14 January 2015 12:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: India
Contact:

Re: Trigger Switch A only when B changes state from On to off

Post by superczar »

Thanks - That was so simple and elegant
I feel stupid now :)
snellejellep
Posts: 241
Joined: Tuesday 16 May 2017 13:05
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: The Neterlands
Contact:

Re: Trigger Switch A only when B changes state from On to off

Post by snellejellep »

superczar wrote: Wednesday 22 May 2019 21:30 Thanks - That was so simple and elegant
I feel stupid now :)
don't be, we are all here to help each other and learn new things.
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest