Can't get google TTS to work with Fritzbox CallerID

Hi all,

I have a FritzBox VDSL2 modem, and I’m trying to get the CallerID functionality to work with Google TTS.

  • Google TTS works, I can put it on my overview with a button, and make it speak a pre-defined sentence. I use this code behind a button:
show_name: true
show_icon: true
type: button
tap_action:
  action: call-service
  service: tts.google_translate_say
  data:
    entity_id: media_player.huiskamer
    message: dit is een testje
    language: nl
  target: {}
name: praten test
icon_height: 40px

I also have a template in my configuration yaml for the CallerID.
I did put the “line_status” entity on my overview, and I get the necessary information.
This is in my configuration.yaml:

template:
    sensors:
      line_status:
        value_template: >-
            {%- if is_state("sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek", "idle") %}
                Vrij
            {%  elif is_state("sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek", "dialing") %}
                Naar {{ states.sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek.attributes.to_name }} ({{ states.sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek.attributes.to }})
            {%  elif is_state("sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek", "ringing") %}
                Van {{ states.sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek.attributes.from_name }} ({{ states.sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek.attributes.from }})
            {% else %}
                Met {{ states.sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek.attributes.with_name }} ({{ states.sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek.attributes.with }})
            {%- endif %}
        friendly_name: 'Line status'

However, I don’t know how to combine these 2 items.
(I’m quiet a newbie into this Home Automation, I love it however)
I’m still a bit “lost” between all this integrations/scripts/automations/templates etc …
Can someone help me a bit with this ?

Thanks & best regards from Belgium,
Kris

You’re close. :slight_smile:

Use a template in your message.

show_name: true
show_icon: true
type: button
tap_action:
  action: call-service
  service: tts.google_translate_say
  data:
    entity_id: media_player.huiskamer
    message: "No, its not the pope thats calling, its {{ states('sensor.line_status') }}"
    language: nl
  target: {}
name: praten test
icon_height: 40px

Basically you were on the right track. With the sensor under template (your second code part), you already are setting the correct value from the FritzBox. What you now need in your TTS message, is nothing but the state of that “handmade” sensor to be given out.

On a side note, you shouldn’t use states.sensor... as this will give an error message in the logs, if the state is not set, eg. after a restart. To avoid this error message (that not really causes any problems) you should use states('sensor...').

See here: Templating - Home Assistant

PS: You Belgians have really cool passports nowadays! :+1: Congrats, I bet they invite to small talk on every border control :rofl: :rofl:

Hi Patrick,

I don’t know what is so cool about our passports :slight_smile:
The government keeps telling us that we are in the top-4 with most secured passports :slight_smile:

I tried your proposal, but it didn’t work.
I assume I need to use data_template instead: of data: (but that is not possible with a button)

Furthermore, I have no idea on how to “automate” the speech.
I’m missing something here … Maybe it’s my lack of knowledge of the syntax ?
I tried with triggers and notifications, but I can’t get nothing working.
To make things even worse, after some fiddling around, my sensor-state doesn’t even work anymore.
(luckely, I’m good with backups, lol)

I have an IT background, but I find it hard to “interprete” the documentation in the correct way.
Still a long way to go …
Maybe another push in the right direction is what I need.
(been struggling with this for already 3 days)

thanks in advance,
best regards,
Kris

You have the most famous comic figures from Belgium in your new passports (me, as a German, being jealous :rofl: :rofl: ). That is so cool, I love it. :+1: Les Schtroumpfs / Smurfs / Schlümpfe

So let’s see how we can get you there. :slight_smile:

You want your TTS say the number of the caller, if a call comes in, right?

If so, the second part of your code, this one

template:
    sensors:
      line_status:
        value_template: >-
            {%- if is_state("sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek", "idle") %}
                Vrij
            {%  elif is_state("sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek", "dialing") %}
                Naar {{ states.sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek.attributes.to_name }} ({{ states.sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek.attributes.to }})
            {%  elif is_state("sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek", "ringing") %}
                Van {{ states.sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek.attributes.from_name }} ({{ states.sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek.attributes.from }})
            {% else %}
                Met {{ states.sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek.attributes.with_name }} ({{ states.sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek.attributes.with }})
            {%- endif %}
        friendly_name: 'Line status'

is perfectly ok. You get sensor.line_state from this, and can see this sensor, right?

Next step would be the automation to actually do something. The trigger for this automation should be, if the phone rings.

automation:
  - alias: 'Tell me who calls'
    id: 'Tell me me who calls'
    trigger:
      - platform: state
        entity_id: sensor.fritz_box_fon_wlan_7360_call_monitor_Ha_Telefoonboek
        to: ringing
    action:
      - service: tts.google_translate_say
        data:
          entity_id: media_player.huiskamer
          message: "{{ states('sensor.line_status') }}"

To explain it a little:

  • it triggers, when the state of the phone changes to ringing.
  • as action, it calls the TTS service and let it speak the value of the sensor you created earlier, namely sensor.line_status.

If it would only be for this one automation, you could leave the template sensor out of the picture completely and set the same values only in that automation. Not that it would make much sense though, but just to note. :slight_smile: You will likely want to use that template sensor in other places as well.

That should be it, try it! :slight_smile:

Hi Patrick,

Haa, indeed, the comics, almost forgot about that part, I’m only up in 2024 for a new passport.
(becoming 50 in 2024) I will be proud of my new passport. I hope I can get Nero in my passport :slight_smile:

Thanks for the YAML script, and the explanation, it works !
I was fiddling with triggers, but at the wrong place, I learned a lot today :slight_smile:
(Also got my Sonoff NSPanel switches up-and-running, everything comes together nicely)

So, you’re German, also cool, Germany is my favorite holidays-country.
Still a lot of steam-trains in Germany, I’m a (steam)-train addict :slight_smile:
Hope to talk to you again in the future …

Best regards,
Kris

We will, I’m quite sure. This HA thingy is quite adictive, as you might have already noticed. :rofl:

Thanks for the compliment, I hope you’ll always have a pleasant stay here and will be very warmly welcomed! In this dark times we need to stand united, especially in Europe! :wink: :slight_smile:

An ex-colleague of mine is a steam-train enthusiast as well, he owns together with some friends a small track (around 3km or 4km I think). I was there just once, but it is an amazing experience! Need to do that again sometime! :slight_smile:

But to say something HA related, please keep us informed about the Sonoff device (there is a thread about it somewhere here). It sound very interesting, nice little display and enough power to do some nice stuff. :smiley:

Have a nice weekend! :slight_smile:

Hi,

I’m a bit late to game – sorry for that – but I came up with an enhancement that some readers may appreciate. My CallerID TTS automation keeps repeating the name of the caller (or the number if there’s no corresponding FRITZ!Box phone book entry) while the phone keeps ringing. The interval between the repetitions is set to match the cadence of the ringing signal, which is 5 seconds in my home country, Finland. When the ringing stops, so do the repetitions. It’s a no-brainer, really.

I trust everyone is fluent in Finnish:

actions:
  - repeat:
      sequence:
        - action: tts.google_translate_say
          metadata: {}
          data:
            cache: false
            language: fi
            entity_id: media_player.akana
            message: >-
              {% if (state_attr('sensor.fritsuboksi', 'from_name') == 'unknown') %} 
              Tuntemattomasta numerosta soitetaan! 
              {% else %}
              {{state_attr('sensor.fritsuboksi', 'from_name')}} soittaa! 
              {% endif %}
        - delay:
            hours: 0
            minutes: 0
            seconds: 5
            milliseconds: 0
      while:
        - condition: state
          entity_id: sensor.fritsuboksi
          state: ringing
          for:
            hours: 0
            minutes: 0
            seconds: 0
mode: single

I hope someone finds this useful.