NEW UPDATE - 08/12/2020
Last week the node-red-contrib-cast broke and TTS stopped working and as of writing it hasn’t been fixed yet.
It is currently presenting the following error message:
“Not able to get media file via google-tts:get token key failed from google”
EDIT:
As of version 0.2.17 of the original node-red-contrib-cast, it is working again now.
So you can now choose either of these different Cast nodes to use, up to you…
END OF EDIT
Here is a new flow using the node-red-contrib-castv2 instead for Google Home TTS.
This is an improved version, not only can you send HTTP commands to it from your Vera scenes or PLEG / Reactor actions, to initiate a TTS announcement, you can now also monitor devices in your Vera, like door contact sensors, using the node-red-contrib-mios and have TTS announcements when that door is opened / closed etc.
Global volume levels for the TTS announcement and for lowering the volume level again afterwards on the Google Home speakers can also be set.
I’ve written instructions inside the various Comment labels within the flow.
Many thanks to @ElCid who has designed this flow for us !
node-red-contrib-castv2 seems to be more reliable also which is an added bonus, as its nodes have a constant connection to each Google Home speaker. It appears to work much better and more consistently compared to the old node-red-contrib-cast setup.
The HTTP command URLs you create and send from Vera have not changed and are the same as the examples further below.
END OF NEW UPDATE
OLD UPDATE
This is the final version of dynamic Http URLs for TTS Cast / Google Home using the node-red-contrib-cast.
Many thanks to @ ElCid it was his solution !
EXAMPLE URLs:
Single IP address of a Cast / Google Home Device:
http://NODE-RED-IP:1880/sceneTrigger?message=TEST&ip=192.168.0.16
Multiple IP addresses of Cast / Google Home Devices:
http://NODE-RED-IP:1880/sceneTrigger?message=TEST&ip=192.168.0.16|192.168.0.17|192.168.0.18
To send from a vera scene use luup.inet.wget e.g
luup.inet.wget("http://NODE-RED-IP:1880/sceneTrigger?message=TEST&ip=192.168.0.16")
I hope this is formatted correctly. If not I’ve attached the json file.flows.zip (850 Bytes)
[{"id":"9c2feedf.8f0c6","type":"tab","label":"Google-Home-TTS-Cast","disabled":false,"info":""},{"id":"d6bc502.55b51b","type":"debug","z":"9c2feedf.8f0c6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":710,"y":140,"wires":[]},{"id":"b58cca49.dbc598","type":"comment","z":"9c2feedf.8f0c6","name":"TTS Cast - Specify IP(s) in the URL","info":"","x":160,"y":60,"wires":[]},{"id":"f3bfb696.be0b48","type":"http in","z":"9c2feedf.8f0c6","name":"http request from scene","url":"sceneTrigger2","method":"get","upload":false,"swaggerDoc":"","x":120,"y":100,"wires":[["c57cb7e7.898598"]]},{"id":"c5649b06.ea2558","type":"http response","z":"9c2feedf.8f0c6","name":"http response","statusCode":"200","headers":{},"x":580,"y":100,"wires":[]},{"id":"c57cb7e7.898598","type":"function","z":"9c2feedf.8f0c6","name":"IP-Addresses-Function","func":"var IPS = msg.payload.ip.split(\"|\");\nfor (var i in IPS) { \nmsg.payload = {\"message\": msg.payload.message, \"ip\": IPS[i], \"volume\": msg.payload.volume};\nnode.send([null, [msg]]);\n}\nmsg.payload = \"ok\"; // the response message\nreturn [msg];","outputs":2,"noerr":0,"x":350,"y":100,"wires":[["c5649b06.ea2558"],["6eaf08dd.ff98f8"]]},{"id":"6eaf08dd.ff98f8","type":"cast-to-client","z":"9c2feedf.8f0c6","name":"","url":"","contentType":"","message":"","language":"En-gb","ip":"","port":"","volume":"","x":550,"y":140,"wires":[["d6bc502.55b51b"]]}]
END OF OLD UPDATE
MY ORIGINAL POSTING
I’ve been playing around with node-red for the first time today. I just installed node-red on my Windows 10 laptop as a test. Following these instructions here.
I have been able to set up a HTTP IN endpoint in node-red, so I can send a http command to node-red from Vera for example, to then do something, in this case to send a TTS announcement of “Hello” to two of my Google Home speakers.
http://[IP-ADDRESS-NODE-RED-DEVICE:1880/hello
I used the node-red-contrib-cast
Unrelated but I also managed to setup a eWeLink node to control my WIFI oil diffuser. I setup a HTTP IN for the on command and a HTTP IN for the off command. I can now turn on and off the diffuser by sending http commands to node-red from Vera.
What else are other Vera users using Node-Red for ?
There is also a node for MIOS Vera here
I got that up and running and was able to set dim levels on one of my lamps in Vera in Node-red.
Not sure what I would really use the MIOS node for however?
UPDATE:
So this is how I have been getting a Vera scene to do something in node-red.
In this example it sends a TTS to a Google Home speaker, using the node-red-contrib-cast
HTTP IN node:
Method is GET
URL: /whatever-you-want
Template Node:
Text “OK” response
HTTP Response node:
Status Code = 200
Cast Node:
Send TTS to a Google Home speaker
So in the actual Vera scene under “Also, execute the following Luup code:”
Send the http command to node-red e.g.
luup.inet.wget(“http://NODE-RED-IP:1880/doorbellstatus”)
Where “/doorbellstatus” = URL: /whatever-you-want
What you specified the URL as in the “http in” node.
So when you run the Vera scene the URL is sent to node-red and any associated actions in node-red will be carried out.