Is it possible to differentiate manual toggle and by automation?

Hi, I have set up home assistant under venv on my raspi. I have set up basic automation and it works. Now i want something a little bit advanced. I have automation rule “A” that turn off a switch after it’s been turned on for 25mins. I want this automation only apply when the switch is turned on manually by physical button.

I have another automation rules that turns the switch on at 7.30 AM and 4.30 PM. second rules turns off at 8.20 AM and 5.20 PM. The automation rule “A” should not execute for the aforementioned rule.

That being said, is there anyway to differentiate switch state change either by physically press or as a result of automation execution? Thanks in advance…

It’s possible if it comes from an automation I believe. But it’s no easy task if you aren’t familiar with the state object.

This may work out of the box if you add this condition.

- condition: template
  value_template: >
    {% set domain, object_id = trigger.entity_id.split('.') %}
    {{ states[domain][object_id].context.parent_id == None }}
1 Like