Skip to content

Instantly share code, notes, and snippets.

@joshp23
Last active February 21, 2022 00:34
Show Gist options
  • Save joshp23/770bb214b5c905c467ec2172340c7067 to your computer and use it in GitHub Desktop.
Save joshp23/770bb214b5c905c467ec2172340c7067 to your computer and use it in GitHub Desktop.
Homeassistant: Zone Notification enter and leave via XMPP
blueprint:
name: Zone Notification - xmpp
description: Send a notification via xmpp_jp when a person leaves or arrives at a specific zone.
domain: automation
source_url: https://gist.github.com/joshp23/770bb214b5c905c467ec2172340c7067
input:
person_entity:
name: Person
selector:
entity:
domain: person
zone_entity:
name: Zone
selector:
entity:
domain: zone
trigger:
platform: state
entity_id: !input person_entity
variables:
zone_entity: !input zone_entity
zone_state: "{{ states[zone_entity].name }}"
person_entity: !input person_entity
person_name: "{{ states[person_entity].name }}"
condition:
condition: template
value_template: "{{ zone_entity == 'zone.home' and trigger.to_state.state == 'home' and trigger.from_state.state != 'home' or zone_entity == 'zone.home' and trigger.from_state.state == 'home' and trigger.to_state.state != 'home' or trigger.to_state.state == zone_state and trigger.from_state.state != zone_state or trigger.from_state.state == zone_state and trigger.to_state.state != zone_state}}"
action:
## Change this to your configured XMPP service -> https://www.home-assistant.io/integrations/xmpp/
- service: notify.xmpp_XXX
data:
message: |
{% if trigger.event == 'enter' %}
'{{ states[trigger.entity_id].name}} has arrived at {{ trigger.zone.attributes.friendly_name }}'
{% else %}
'{{ states[trigger.entity_id].name}} has left {{ trigger.zone.attributes.friendly_name }}'
{% endif %}
@joshp23
Copy link
Author

joshp23 commented Feb 21, 2022

This will send an XMPP notification when an identified person enters or leaves a particular zone

Notes:

  1. This requires the XMPP integration to be configured, instructions here
  2. I have not figured out how to make the xmpp service configurable, so it currently has to be hard coded into the blueprint after importing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment