I’d like to have automation that sends a notification when I enter a zone.
Currently I have the below, which works for 1 zone.
Assume I have zone.one, zone.two, zone.three, what I’d like to do is to add the additional zones and have a dynamic notification instead of 3 scripts (one per zone)
I can’t quite work out how to pass multiple zones, and have this appear in the notification?
- id: 'Entering Zone'
alias: Notification when entering Zone
description: ''
trigger:
- entity_id: device_tracker.iphone
event: enter
platform: zone
zone: zone.one
condition: []
action:
- data:
message: You're entering {{ state_attr('zone.one', 'friendly_name') }}
title: Zone Notification
service: notify.mobile_app_iphone
- id: 'Entering Zone'
alias: Notification when entering Zone
description: ''
trigger:
- entity_id: device_tracker.iphone
event: enter
platform: zone
zone: zone.one
- entity_id: device_tracker.iphone
event: enter
platform: zone
zone: zone.two
- entity_id: device_tracker.iphone
event: enter
platform: zone
zone: zone.three
condition: []
action:
- data:
message: You're entering {{ trigger.to_state.attributes.friendly_name }}
title: Zone Notification
service: notify.mobile_app_iphone
Untested. but I have a simliar setup working:
- id: "1557405390202"
alias: TeleG - Notify lights on when not home
trigger:
- entity_id: light.chandelier
platform: state
to: "on"
- entity_id: input_boolean.group_fan_state
platform: state
to: "on"
condition:
- condition: state
entity_id: sensor.jim_home
state: "false"
- condition: and
conditions:
- condition: state
entity_id: input_boolean.boolean_switch3
state: "on"
action:
- data_template:
message: Alert- "{{ trigger.to_state.attributes.friendly_name }}" turned on
service: notify.habot
You may, or may not need to quote around the trigger variable.