Google Home - Node Red = TTS

Alexa, Google Home and Siri
Post Reply
korniza
Posts: 198
Joined: Thursday 27 August 2015 18:12
Target OS: Raspberry Pi
Domoticz version: V3.6028
Location: Greece
Contact:

Google Home - Node Red = TTS

Post by korniza » Tuesday 31 October 2017 18:33

Hi @ all,
I try to build a virtual device with a text sensor that can be used as an input to node-red using the google-home-notification node. It is too easy to install and use node-red so comparing to other implementations it did not require a middleware to send the tts to google home.
My issue is that I need to build a dzvents script and parse the text of the text sensor via MQTT when value (text) changed.

Any help?
Attachments
google-home-notify.png
google-home-notify.png (21.55 KiB) Viewed 2506 times
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)

Bradds
Posts: 23
Joined: Wednesday 22 March 2017 23:49
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Google Home - Node Red = TTS

Post by Bradds » Wednesday 01 November 2017 2:29

Not sure what you are asking, but if it is how to get google home to read out sensor data/switch status etc.. follow this guide -

viewtopic.php?f=4&t=13607&start=20#p148867

Or this one

http://www.domoticz.com/forum/viewtopic ... 20#p150149

If you are using the google home notify node instead of the chromecast node, just substitute the text in the speech function to something like....

msg.payload = 'the '+msg.payload.Name+' is '+msg.payload.Temp+'degrees'
return msg;

Or whatever your "text" is.

korniza
Posts: 198
Joined: Thursday 27 August 2015 18:12
Target OS: Raspberry Pi
Domoticz version: V3.6028
Location: Greece
Contact:

Re: Google Home - Node Red = TTS

Post by korniza » Wednesday 01 November 2017 4:07

Thank you Bradds for answer. I have no idea about this setup. My request is kind different as I want to use GH to perform automatic notifications. For example if CO2 is higher that 1000ppm, to send a tts on GH and warn me to open window for fresh air, or warn for a forgotten bathroom light was left on. So I do not want to ask Google home for a status of device.
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)

Bradds
Posts: 23
Joined: Wednesday 22 March 2017 23:49
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Google Home - Node Red = TTS

Post by Bradds » Friday 03 November 2017 0:58

What you are describing is exactly what the guides in the last post do.
The only difference is that the "status" switch is activated from an IFTTT command via Google home.
You can substitute the "status" switch for any switch or command from domoticz that you want.
Then once the command is filtered in Node-red you can get google to read out whatever you put in the msg.payload, be it text, status etc.. etc..

To do what you want, follow one of the guides listed (omitting the IFTTT part) , then just create a virtual switch in domoticz that gets activated once your conditions are met via a script/blocky or whatever means you choose. Filter out your switch in node-red and then get google to read out a warning.

Here is an example for when a front Door PIR is activated, then google alerts "Someone is at the front door" same methodology applies for any switch/device/script

Code: Select all

[{"id":"3cbe0d3a.f24a12","type":"mqtt in","z":"534615a.37d49ec","name":"dom output","topic":"domoticz/out","qos":"0","broker":"d5e65930.0b5258","x":65,"y":653.8232755661011,"wires":[["24f5b75.efa7048"]]},{"id":"1156c6a8.580929","type":"switch","z":"534615a.37d49ec","name":"Front door motion alert","property":"payload.idx","propertyType":"msg","rules":[{"t":"eq","v":"581","vt":"str"}],"checkall":"false","outputs":1,"x":386.99989318847656,"y":654.8233213424683,"wires":[["a3318f1e.ab2b1"]]},{"id":"24f5b75.efa7048","type":"json","z":"534615a.37d49ec","name":"","x":215.4091033935547,"y":654.6414823532104,"wires":[["1156c6a8.580929"]]},{"id":"5240ff38.9d0ad","type":"function","z":"534615a.37d49ec","name":"Front Door Audio","func":"msg.payload = 'http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=Somebody%20is%20at%20the%20front%20door&tl=En-gb';\nreturn msg;","outputs":1,"noerr":0,"x":1135.611099243164,"y":647.2344694137573,"wires":[["bd451141.202b9"]]},{"id":"837b1e54.388be","type":"switch","z":"534615a.37d49ec","name":"on","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"}],"checkall":"false","outputs":1,"x":890.0000152587891,"y":648.6233243942261,"wires":[["5240ff38.9d0ad"]]},{"id":"a3318f1e.ab2b1","type":"function","z":"534615a.37d49ec","name":"Repub","func":"msg.topic = \"domoticz/out/device/\"+msg.payload.name;\n\nif (msg.payload.nvalue == 1) { \n    msg.payload = \"ON\"} \nelse\n{\n    msg.payload = \"OFF\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":650.1667022705078,"y":650.1233243942261,"wires":[["837b1e54.388be"]]},{"id":"bd451141.202b9","type":"googlehome-notify","z":"534615a.37d49ec","server":"1855c628.acb63a","name":"Google Home","x":1329.000015258789,"y":644.7143278121948,"wires":[]},{"id":"5ed22fa5.4e83","type":"comment","z":"534615a.37d49ec","name":"Only acivate when switched on","info":"","x":900.0000152587891,"y":609.7143278121948,"wires":[]},{"id":"4db854ad.7b413c","type":"comment","z":"534615a.37d49ec","name":"Front Door PIR IDX Filter","info":"","x":392.42859649658203,"y":605.4286479949951,"wires":[]},{"id":"a2ce6e0e.2a7dd","type":"comment","z":"534615a.37d49ec","name":"Filter the On/Off data from switch","info":"","x":669.0000152587891,"y":700.7143278121948,"wires":[]},{"id":"d5e65930.0b5258","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""},{"id":"1855c628.acb63a","type":"googlehome-config-node","z":"","ipaddress":"192.168.1.174","language":"en"}]

Or ....

You could do it all in node red by filtering out the data from your CO2 sensor to activate a node once it reaches a certain value, upto you which way you go.

Here is an example of a warning if the bathroom light switch is on for a set period of time, change the idx to your bathroom switch and adjust the time in the trigger node. The trigger node gets activated once the switch is on, and alarms to google if the time lapses. If it receives an off signal from the switch in the meantime, it cancels the warning. I have included on/off inject nodes for testing purposes. Have a play and you should get the idea. The on/off filter node is not necessary, but handy if you want to use it to switch something else from the command.

Code: Select all

[{"id":"f6fc7c85.0db32","type":"mqtt in","z":"e2c25c03.2dfd6","name":"dom output","topic":"domoticz/out","qos":"0","broker":"d2a7254c.35b4d8","x":86,"y":166.39462757110596,"wires":[["e42bd309.f3a42"]]},{"id":"653a8121.0621b","type":"switch","z":"e2c25c03.2dfd6","name":"Bathroom light switch filter","property":"payload.idx","propertyType":"msg","rules":[{"t":"eq","v":"100","vt":"str"}],"checkall":"false","outputs":1,"x":417.99989318847656,"y":167.39467334747314,"wires":[["6f9c86c1.3c6f38"]]},{"id":"e42bd309.f3a42","type":"json","z":"e2c25c03.2dfd6","name":"","x":236.4091033935547,"y":167.21283435821533,"wires":[["653a8121.0621b"]]},{"id":"8d7c91db.207da","type":"function","z":"e2c25c03.2dfd6","name":"Warning TTS","func":"msg.payload = 'http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=warning, the bathroom light has been on for more than 10 minutes&tl=En-gb';\nreturn msg;","outputs":1,"noerr":0,"x":1086.6110954284668,"y":159.80582427978516,"wires":[["574c6e02.7bc21"]]},{"id":"d845b9b4.53d8f8","type":"switch","z":"e2c25c03.2dfd6","name":"on/off","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"},{"t":"eq","v":"OFF","vt":"str"}],"checkall":"false","outputs":2,"x":741.0000495910645,"y":165.48040962219238,"wires":[["cec2a64.bd55158"],["cec2a64.bd55158"]]},{"id":"6f9c86c1.3c6f38","type":"function","z":"e2c25c03.2dfd6","name":"Repub","func":"msg.topic = \"domoticz/out/device/\"+msg.payload.name;\n\nif (msg.payload.nvalue == 1) { \n    msg.payload = \"ON\"} \nelse\n{\n    msg.payload = \"OFF\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":614.0238418579102,"y":165.55179500579834,"wires":[["d845b9b4.53d8f8"]]},{"id":"cec2a64.bd55158","type":"trigger","z":"e2c25c03.2dfd6","op1":"","op2":"1","op1type":"nul","op2type":"str","duration":"10","extend":false,"units":"s","reset":"OFF","name":"","x":916.0000228881836,"y":163.53751277923584,"wires":[["8d7c91db.207da"]]},{"id":"e06cd425.fe2148","type":"inject","z":"e2c25c03.2dfd6","name":"ON","topic":"","payload":"ON","payloadType":"str","repeat":"","crontab":"","once":false,"x":606,"y":102,"wires":[["d845b9b4.53d8f8"]]},{"id":"b4fd1198.d2c39","type":"inject","z":"e2c25c03.2dfd6","name":"OFF","topic":"","payload":"OFF","payloadType":"str","repeat":"","crontab":"","once":false,"x":612,"y":222,"wires":[["d845b9b4.53d8f8"]]},{"id":"574c6e02.7bc21","type":"googlehome-notify","z":"e2c25c03.2dfd6","server":"","name":"","x":1301,"y":160,"wires":[]},{"id":"d2a7254c.35b4d8","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]
Regards.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests