Using Node-Red for Google Home TTS announcements and other stuff eWeLink

eWeLink is broken as well can’t update it or reinstall it now.

So not having much luck with node-red at the moment:

@ElCid

Apparently the other node-red-contrib-castv2 has already been fixed for Google Home TTS.

The one I have been using node-red-contrib-cast is still broken.

TTS Example:

{
  payload: {
    app: "DefaultMediaReceiver",
    type: "TTS",
    text: "Something to say",
    speed: 1, // optional to adjust TTS speed, defaults to 1
    language: "en", // optional to set TTS language, default to en
    metadata: { // optional unless desired, follows normal metadata rules noted above
      title: "Media title"
    }
  }
}

Do you think it might be possible to do something similar with regards to sending dynamic URLs for the TTS message and specifying the target Home device IP ?

It also looks like this castv2 node can do much more like playback transport controls and volume control etc.

This is the current function code I am using with the now broken node-red-contrib-cast.

var IPS = msg.payload.ip.split("|");
for (var i in IPS) { 
msg.payload = {"message": msg.payload.message, "ip": IPS[i], "volume": msg.payload.volume};
node.send([null, [msg]]);
}
msg.payload = "ok"; // the response message
return [msg];

Cheers

I’ve just installed Castv2 and added the IP address of my Lounge Google Mini in to it.

It does actually say connected and Green not like the screen shot below.

I added a function node and just copied their TTS example but it doesn’t like it.

image

image

Don’t know what I am doing which is nothing new.

Saw this Youtube video:

He has this in his function:

msg =
{
  host: "192.168.0.16",
  payload: {
    type: "TTS",
    text: "This is a test",
    speed: 1, // optional to adjust TTS speed, defaults to 1
    language: "en", // optional to set TTS language, default to en
    title: "Test1"
    }
  }

  

  return msg;

It works when I press the inject node the Google Home Mini talks.

As I’ve also specified the Home Mini’s IP address in the blue Castv2 node this also works without the “host” line:

msg =
{
  payload: {
    type: "TTS",
    text: "This is a test",
    speed: 1, // optional to adjust TTS speed, defaults to 1
    language: "en", // optional to set TTS language, default to en
    title: "Test1"
    }
  }

  

  return msg;

However its not dynamic at all like your original setup.

This is the original now broken node-red-contrib-cast:

image

I’m not even sure if the other node-red-contrib-castv2 supports specifying the msg.ip and the msg.payload.message as part of the incoming message. So dynamic will never work if it doesn’t ?

You will need to have a castv2 node for each ip address as the node does not allow dynamic ips like cast. Just finished work will have a bath and tea then take a look.

1 Like

I’ve asked if they can add support for it?

If I have to have a different flow for each TTS message and for what Google Homes I want to send the messages to, that is a massive amount of work, plus I have to edit all my Vera scenes and PLEG actions that send out TTS messages.

No we can leave your urls as they are i will add a switch node to direct to different cast nodes.

as below

you will need to add cast nodes where each debug is, If you want more nodes just add a new field in the switch node. Edit the switch node with th ip’s of the cast nodes

[{"id":"4405a5e2.b6263c","type":"function","z":"8d22ae29.7df6d","name":"","func":"var IPS = msg.payload.ip.split(\"|\");\nfor (var i in IPS) { \nmsg.payload = msg =\n{\n  payload: {\n    type: \"TTS\",\n    text: msg.payload.message,\n    speed: 1, // optional to adjust TTS speed, defaults to 1\n    language: \"en\", // optional to set TTS language, default to en\n    title:\"\",\n    ip: IPS[i]\n    }\n  }\n\nnode.send([null, [msg]]);\n}\nmsg.payload = \"ok\"; // the response message\nreturn [msg];\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":2220,"wires":[["5694dfbe.42dd8"]]},{"id":"5694dfbe.42dd8","type":"switch","z":"8d22ae29.7df6d","name":"","property":"payload.ip","propertyType":"msg","rules":[{"t":"eq","v":"192.168.1.24","vt":"str"},{"t":"eq","v":"192.168.1.26","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":490,"y":2220,"wires":[["d32fa5b0.4ba6f"],["81a9ee49.571648"]]},{"id":"d32fa5b0.4ba6f","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":2200,"wires":[]},{"id":"81a9ee49.571648","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":680,"y":2240,"wires":[]}]

I have not added volume yet , lets get it working then we can sort volume out.

Did this work with out entering a ip address in the cast v2 node?

Yes I can remove the “host” line if I specify the IP in the CastV2 node instead.

I’ve not tested it yet but if just built it:

add a http response node after the http in node or the connection will hang.

Just to clarify if you enter host ip in object and remove ip from cast v2 node does it work?

If it does we can get rid of switch.

After adding the http response node, all the CastV2 nodes have connected and are green.

If I send this http command

http://192.168.0.4:1880/sceneTrigger?message=Alarm%20Carbon%20Monoxide%20Detected&ip=192.168.0.16

I get this:

image

move the http response to directly after the http in

The IP has to be in the blue CastV2 nodes or they don’t connect and go green.

As i thought, just clarifying.

Can you add a second output to the function node as i forgot to add it. It is at the bottom of the config page.

It behaves different now.

I see this in the web browser after sending the test command, normally on the old cast one it just said OK.

I don’t see anything in the debug output now in Node Red and no TTS heard.

image

What is the second output connecting to ?