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

Add the http response to the top connection of the function node and the switch to the bottom.

Like that, see the debug on the right.

When I send this command now in Chrome browser it just spinning and I don’t get a response back in the browser.

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

But I do get this in the node red debug:

“No response object”

typo in function node try this

[{"id":"4405a5e2.b6263c","type":"function","z":"8d22ae29.7df6d","name":"","func":"var IPS = msg.payload.ip.split(\"|\");\nfor (var i in IPS) { \nmsg.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\nnode.send([null, [msg]]);\n}\nmsg.payload = \"ok\"; // the response message\nreturn [msg];\n","outputs":2,"noerr":0,"initialize":"","finalize":"","x":320,"y":2220,"wires":[["9d497085.252fe8","d46f5c71.d2de1"],["5694dfbe.42dd8"]]}]

just edited it again copy it again for new update

The browser is working again and says OK after I send the HTTP command.

I get this now in debug:

image

OK trying again

Browser says OK after issuing the HTTP command.

Nothing gets put in to the debug window at all now it remains empty.

No TTS heard however.

All blue CastV2 nodes are connected and green.

put debug on bottom function output and the out put of switch that is ip 192.168.0.16

debug on switch out put not cast output.
can i also see the settings of the switch node?

Seems to be the same:

change msg.payload.title to msg.payload.ip

Its msg.payload.title should it not be msg.payload.message?

Think that fixed it the Lounge Mini lives she just spoke !

ok how do you want volume to be handled, as reading info the volume is set with a seperate payload.

I don’t know, the original cast flow for the TTS you setup, there are no volume controls on the URLs I am sending from Vera or in its function node.

It was that other flow for the dog barking alert thing to play WAV files, you also setup, that had volume controls in the function.

I think playing WAVs still works OK with the original Cast node and not that bothered about it anyway the dog ignores it and doesn’t stop barking haha.

msg.payload ={};
var urls = ["http://192.168.0.4:1880/alert8.wav"]

msg.payload.url = urls[Math.floor(Math.random() * urls.length)];
msg.payload.volume = 60;
msg.payload.contentType = "audio/vnd.wav";
msg.payload.ip = "192.168.0.19";
msg.payload["port"] = 8009;
node.send(msg);
setTimeout(function(){
delete msg.payload.url;
delete msg.payload.contentType;
msg.payload.volume = 40;
node.send(msg);
}, 30000);
return;

For the TTS announcements I guess if I can specify a playback volume and then maybe lower it again that would be cool.

i can add a default volume if no volume set in url. Then have flow set new volume then return to default.

That would be grand !

Can you check if you set this inject node feeding directly into the castv2 node, if it sets volume to 100 and speaks.

[{"id":"5b00ab01.0fe374","type":"inject","z":"8d22ae29.7df6d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"app\":\"DefaultMediaReceiver\",\"type\":\"TTS\",\"text\":\"Something to say\",\"speed\":1,\"language\":\"en\",\"volume\":100}","payloadType":"json","x":100,"y":2340,"wires":[[]]}]