[Node Red] Sending Announcements over TTS

I have some Google Home devices that are media_player items; and I am able to create announcements using:

entity_id: media_player.kitchen_display
message: "This is an announcement"

Obviously; this works just fine as a regular automation; however, when I send this as a payload over NodeRed; the service is called; and I hear my display activate for something to happen - only nothing does.

My msg payload currently looks like this; although I am sure that it isn’t really correct (obviously it isn’t working):

What it is supposed to do is that when changes; to essentially ‘speak’ the new state as the announcement.

{
    "data_template": [
        {
            "message": "{{ states.<entity>.state }}"
        }
    ]
}

I have seen a few help sites suggest using data / data_template; but I am not sure which way is the best way to do it; or if I am even going about this correctly.

Note: <entity> is a placeholder for an actual entity; which using that template does report the correct state; the state is just not passed to be spoken over the TTS service call (google_tts.say).

I use a call service node with the following.
Domain: tts
Service: google_translate_say
Entity Id: speaker name
Data: {“message”:“A curb event is starting. Non essential electric items are being turned off”}

I just changed Data to:
{“message”:"{{states.sensor.power_solar.state}}"} and it announced the value of that sensor perfectly.

I must not be getting my syntax correct because a basic attempt is throwing out an error:

{
    "data": [
        {
            "message": "test"
        }
    ]
}

The error that I receive:

"Call-service API error.  Error Message: extra keys not allowed @ data['data']"

What sort of node are you using to have that input?
I just a call service node and fill in the boxes, but maybe take out the square braces to start with and see what that does.

I just exported mine to get the relevent info and it is formatted like this:

[
    {
        "id": "7fb042c5.2ce5dc",
        "type": "api-call-service",
        "z": "5a8fb8a8.e0d978",
        "name": "Notify",
        "server": "87d2ce8.d0a443",
        "version": 1,
        "debugenabled": false,
        "service_domain": "tts",
        "service": "google_translate_say",
        "entityId": "media_player.lounge_speaker",
        "data": "{\"message\":\"A curb event is starting. Non essential electric items are being turned off\"}",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 610,
        "y": 160,
        "wires": [
            []
        ]
    },
    {
        "id": "87d2ce8.d0a443",
        "type": "server",
        "name": "Home Assistant",
        "addon": true
    }
]

I am doing a simple inject node (testing) with a service call node and output to a debug node.

My data JSON (under Entity) is one line to keep it simple:

[
    {
        "message": "test"
    }
]



This works fine under an Automation outside of NR.

Drop the square braces and leave only the curly braces

It dings to ‘cast’ but says / does nothing.

It’s like the service is calling but the “message” payload isn’t getting received by the device? I am not sure, here.

change google_translate to google_translate_say

I assume that you mean cloud_say; and there doesn’t appear to be any difference here. Is this a bug by chance?

Mine has google_translate_say

This topic seems to be what I am experiencing also:

I am going to read up on this and see if it’s something that might answer what’s happening here.

Maybe I might find something but it doesn’t appear to be isolated to me, after all.

It seems like it’s calling this over http and Google requires SSL.

I confirmed this from my logs:

Solution : I set my external + internal URL to be both my external https address; and now it works.

1 Like

I see you have it solved, but did you have internal URL set to http://hassio:8123 or http://192.168.x.x:8123 (or appropriate address)?
I use the second and it works fine. Following that link you posted it seems to be very dependant on things being ‘just right’ and I think I may have been very lucky to get it working first time.

I had it set to http://hassio:8123 (no SSL).

Because Google requires HTTPS / SSL using my external URL for both internal + external is what fixed it - the logs were showing me it was trying to use HTTP causing the failures when I need to use HTTPS.

Because of google tts changing usage rules frequently i finally decided to develop the “node-red-google-notify” node. Each voice message is stored in a cache folder thus you need google tts only when the voice message is played for the first time.
If you want to give a try here you can find more details about the node: https://flows.nodered.org/node/node-red-google-notify

1 Like

Using the Cast node works, but then I cant queue messages.

I get this error when I use the Call Service TTS.