Skip to content

Instantly share code, notes, and snippets.

@bonzini
Last active November 30, 2022 17:44
Show Gist options
  • Save bonzini/431d97c9bafab429a5245f476eef926a to your computer and use it in GitHub Desktop.
Save bonzini/431d97c9bafab429a5245f476eef926a to your computer and use it in GitHub Desktop.
Home Assistant blueprints
blueprint:
name: Personal Zone Notification
description: Send a notification with a URL to a device when it enters a specific zone.
domain: automation
input:
zone:
name: Zone
description: Zone triggering the notification
selector:
entity:
domain: zone
android_devices:
name: Android devices to notify
description: Device needs to run the official Home Assistant app to receive notifications.
selector:
entity:
domain: device_tracker
multiple: true
ios_devices:
name: iOS devices to notify
description: Device needs to run the official Home Assistant app to receive notifications.
selector:
entity:
domain: device_tracker
multiple: true
title:
name: Title
description: Title of the notification
selector:
text:
message:
name: Message
description: Message of the notification
selector:
text:
url:
name: URL
description: URL for the notification
selector:
text:
variables:
zone_entity: !input zone
zone_state: "{{ states[zone_entity].name }}"
trigger:
- id: android
platform: state
entity_id: !input android_devices
- id: ios
platform: state
entity_id: !input ios_devices
condition:
- alias: Entered or left zone
condition: template
value_template: >-
{{ (trigger.from_state.state == zone_state) != (trigger.to_state.state ==
zone_state) }}
action:
- if:
- condition: template
value_template: "{{ trigger.to_state.state == zone_state }}"
alias: Entered zone
then:
- if:
- condition: trigger
id: ios
then:
- service: notify.mobile_app_{{trigger.entity_id.split('.')[-1]}}
data:
title: !input title
message: !input message
data:
clickAction: !input url
url: !input url
tag: !input zone
else:
- service: notify.mobile_app_{{trigger.entity_id.split('.')[-1]}}
data:
title: !input title
message: !input message
data:
clickAction: !input url
url: !input url
tag: !input zone
else:
- service: notify.mobile_app_{{trigger.entity_id.split('.')[-1]}}
data:
message: clear_notification
data:
tag: !input zone
mode: single
blueprint:
name: Spazzatura
domain: automation
input:
schedule:
name: Giorni
selector:
entity:
domain: schedule
boolean:
name: Attivazione
selector:
entity:
domain: input_boolean
message:
name: Messaggio
selector:
text:
trigger:
- id: schedule
platform: state
entity_id: !input schedule
- id: state
platform: state
entity_id: !input boolean
to: "on"
condition: []
action:
- if:
- condition: and
conditions:
- condition: state
entity_id: !input schedule
state: "on"
- condition: state
entity_id: !input boolean
state: "on"
then:
- service: script.notifica_spazzatura
data:
title: Spazzatura
message: !input message
- if:
- condition: and
conditions:
- condition: trigger
id: schedule
- condition: state
entity_id: !input schedule
state: "off"
then:
- service: homeassistant.turn_off
data: {}
target:
entity_id: !input boolean
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment