#I want my Sonoff zbmini to turn off after 10min, but ONLY if it was turned on physically.

1 messages · Page 1 of 1 (latest)

short sage
#

Is this even possible? I have a ZBMiniR2 behind a wall plate out in my garage, and I have various automations for it based on times.

But what I also want to add is an auto-off timer that ONLY fires if the switch was toggled by hitting the actual physical switch that is connected.

Does this relay actually expose that information? I know it knows when the switch is toggled, but does it actually expose that as a state?

hasty venture
short sage
tulip fern
#

i have this in a couple of automations to set a variable which i then use in an if block as a condition within the automation to do different things depending on the source of the trigger.

  triggertype: |-
    {% set id = trigger.to_state.context.id %}
    {% set parent = trigger.to_state.context.parent_id %}
    {% set user = trigger.to_state.context.user_id %}
    {% set output = "default" %}
    {% if ((id!=None, parent, user) == (true, None, None)) %}
      {% set output = "Physical Switch" %}
    {% endif %}
    {% if ((id!=None, parent, user!=None) == (true, None, true)) %}
      {% set output = "HA Switch" %}
    {% endif %}
    {% if ((id!=None, parent!=None, user) == (true, true, None)) %}
      {% set output = "HA Auto" %}
    {% endif %}
    {{output}}
alias: Get Trigger Origin```

the `triggertype` will then be
`Physical Switch` if it was done by the switch, `HA Switch`if it was done by a dashboard button and `HA Auto`if it was done by an automation
#

there might be neater ways but this is what i got working a while ago and have reused it a few times

short sage
#

Thanks all. Y'all have pointed me towards some more docs. I love docs. 🤣