Ignore events from automation

Hi!

Is there a way to distinguish events coming from a physical button press vs events triggered by automation?

I have Tasmota light switches which are communicating with Home Assistant via MQTT.
What I'm trying to do is to use of of the switches to turn all lights to on and off.
I also want this switch to represent the overall state of the switches.

Let's call the main switch the all_switch, it's not connected to the wiring, so I would use it for input and for it's LED indicator.
Then I have switch_1 and switch_2

I want to use all_switch to turn switch_1 and switch_2 on or off both at the same time.
Also, when I turn either switch_1 or switch_2 on then all_switch should also be on. This way I will know that some of the lights are still on and I can turn them off by pressing the all_switch.
On the other hand, when both switch_1 and switch_2 are off, all_switch should also be off.

The problem with implementing it is that once I detect that switch_1 is on I will want to turn all_switch on which in turn will trigger turning all of the lights on.

So is there a way to turn the switch on, but ignore subsequent on event from that switch, because I know it's coming from automation and not from the physical press?

Cheers,
Leonti

Welcome to the forum @Leonti

So we can understand better could you post the flow you currently have so we can see how you are handling the switches. Export just the nodes to do with the switch handling. See this post for how to post flows here - How to share code or flow json

you should be able to add another or different property to the messages from each source - eg topic from the button - which you could then use to tell them apart later in the flow.

Hi guys, thanks for your replies!
I'm attaching the flow in progress which exhibits the issue I'm trying to overcome.
So at the moment when "Study room" button is pressed I want to turn the "All lights" switch on. I only want it to switch on so the indicator would indicate that at least a single light in my apartment is on. That particular switch is not connected to any wiring (apart from the power).

When "All lights" switch is pressed I want to turn the light in a bathroom and living room, but only if it's physically pressed, not by automation.

So what's happening now is:

  1. I press the switch in the study room, which turns "All lights" on
  2. "All lights pressed" is being triggered and turns on other lights, which is not desirable, since I didn't actually press "All lights" button.

So in this situation, how to I detect whether "All lights pressed" event is coming from a physical press or whether it was triggered by another flow/subflow?


all_lights_flow.json (6.8 KB)

You had not mentioned that this is a Home Assistant question. Few here use HA, you might be better asking on a HA forum.

I didn't think it was HA-specific question. To me, it ultimately boils down to distinguishing whether event was coming externally (physical button press) or from automation (Node Red).
Where HA is concerned I will always be getting an 'on' event no matter how it was initiated.

What I was thinking about is some kind of pattern where you call a function, it sets a timestamp in some global variable and later when I receive "All lights pressed" I'd check current time against that timestamp and if the difference is less then say 200ms I know it came from automation, so I can just ignore it.

Maybe this kind of pattern is more common in HA, will ask there, thanks!

Change the dashboard switch settings so it doesn't pass through messages it receives, so when you get an event from the dashboard switch you know it is from the switch.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.