Why this notification is not working? It sends only second sentence - “Dan is away.” If trigger state is home it sends second sentece and never first.
service: notify.mobile_app_motorola_one_vision
data:
title: Tracker Dan
message: |
{% if is_state('trigger.to_state.state', 'home') %}
Dan is home.
{% else %}
Dan is away.
{% endif %}
enabled: true
fdpmatic
(fdpmatic)
July 3, 2023, 9:57am
2
I think because the else is always true.
I am not expert but in the if condition maybe you have to check the device_tracker state change.
For example I have one sample automation that send notification to alexa based on the device_tracker, maybe can help you.
alias: "Notify Person Tracking"
description: ""
trigger:
- platform: state
entity_id:
- device_tracker.fabcel
to: home
id: inHome
from: not_home
- platform: state
entity_id:
- device_tracker.fabcel
id: NotInHome
to: not_home
from: home
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: inHome
sequence:
- service: notify.alexa_media
data:
message: Welcome!
target: media_player.echo_dot_di_fabrizio
data:
type: tts
- conditions:
- condition: trigger
id: NotInHome
sequence:
- service: notify.alexa_media
data:
message: Goodbye!
target: media_player.echo_dot_di_fabrizio
data:
type: tts
mode: single
Tinkerer
(aka DubhAd on GitHub)
July 3, 2023, 10:06am
4
The problem is that you’re trying to use trigger.to_state.state
where it’s expecting an entity ID.
{% if trigger.to_state.state == 'home' %}
is what you want
3 Likes