Hi folks,
I’m working on my fritzbox call monitor automation. Target is that Alexa is telling me, who is calling. So far everything works well but I have a small problem in my automation.
- id: '1578830495122'
alias: Anruferansage
description: ''
trigger:
- entity_id: sensor.telefon_festnetz
from: idle
platform: state
to: ringing
condition: []
action:
- data:
data:
type: tts
message: Anruf von {{ state_attr('sensor.telefon_festnetz', 'from_name') }} ({{ state_attr('sensor.telefon_festnetz', 'from') }})
service: notify.alexa_media_buero
With this automation, Alexa tells me first the name from the caller and then the number from the caller.
How can I change the automation that Alexa is only telling me the number, when the contact is not in the phone book? When the caller is not in the phone book, it gives back “unknown”.
Thanks in advance,
Andy
hildwin
(Frank Bergmann)
January 12, 2020, 12:58pm
2
Check if ‘from’ is equal to ‘unknown’, if it is exclude this part from the message.
But as far as I know HA couldn’t read the FritzBox phonebook (FRITZ!OS: [07.12] installed).
Thanks for the hint. My code is working now.
Reading the phonebook works fine.
- id: '1578830495122'
alias: Anruferansage ohne Name
description: ''
trigger:
- entity_id: sensor.telefon_festnetz
from: idle
platform: state
to: ringing
condition:
- condition: template
value_template: "{{ states.sensor.telefon_festnetz.attributes.from_name == 'unknown' }}"
action:
- data:
data:
type: tts
method: all
message: Anruf von {{ state_attr('sensor.telefon_festnetz', 'from') }}
service: notify.alexa_media_buero
1 Like
hildwin
(Frank Bergmann)
January 12, 2020, 7:34pm
4
Great!
I would try something shorter like this. Replaces the message-line in your original code (I’m not sure about the brackets):
message: Anruf von {% if not (state_attr("sensor.telefon_festnetz", 'from_name') == 'unknown') -%}} {{ state_attr('sensor.telefon_festnetz', 'from_name') }}{%- endif %} ({{ state_attr('sensor.telefon_festnetz', 'from') }})