Generic zone interaction

Introduction

This blueprint, allows you to easily define a sequence of actions, that are executed when a person enters or leaves a specific zone.
Even though this can be done relatively easily with a regular automation, I much prefer the blueprint interface to manage my automations.

Blueprint code

blueprint:
  name: Zone interaction action
  description: Perform an action when a person leaves or enters a specific zone
  domain: automation
  input:
    person_entity:
      name: Person
      description: The person you want to track
      selector:
        entity:
          domain: person
    zone_entity:
      name: Zone
      description: The zone you want to monitor
      selector:
        entity:
          domain: zone
    entering_action:
      name: Action(s) when entering
      description: The action(s) to trigger when the person enters the zone
      default: []
      selector:
        action:
    leaving_action:
      name: Action(s) when leaving
      description: The action(s) to trigger when the person leaves the zone
      default: []
      selector:
        action:

trigger:
  - platform: zone
    entity_id: !input person_entity
    zone: !input zone_entity
    event: leave
  - platform: zone
    entity_id: !input person_entity
    zone: !input zone_entity
    event: enter

action:
  - choose:
      # IF entering zone
      - conditions: >
          {{ trigger.event == 'enter' }}
        sequence: !input entering_action
      # ELIF leaving zone
      - conditions: >
          {{ trigger.event == 'leave' }}
        sequence: !input leaving_action
    # ELSE other zone state changed
    default: []

Plan for updates

  • Allow for multiple person entities (if and when blueprint selectors will allow multiple entities)
5 Likes

Looks good, will test it out, thanks!

Thanks Tom, I installed it and I love it. It works perfectly and does exactly what I was looking for. I love the flexibility of it as well. Some might complain that it doesn’t force you to do only notifications but in my case I like that I can choose to do a notification or something else or even multiple things. The conditions allow for actions on either “enter” or “leave”. I couldn’t have made it better myself!