Google Home

Alexa, Google Home and Siri
deennoo
Posts: 905
Joined: Wednesday 10 December 2014 14:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Google Home

Post by deennoo » Wednesday 02 August 2017 9:11

Google arrive on trench language this week, it will be Time to cet One and try it for sure !
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / ESP8266 / MQTT / BLE
http://domo-attitude.fr

User avatar
sincze
Posts: 721
Joined: Monday 02 June 2014 22:46
Target OS: Linux
Domoticz version: 3.8153
Location: Netherlands
Contact:

Re: Google Home

Post by sincze » Saturday 05 August 2017 11:42

My Google-Home & ha-bridge helps to keep things local and fast. (limited to: on/off/dim)
[url]https://github.com/bwssytems/ha-bridge[/url]

But with some creativity you can even control KODI with it. :D
WAF = 0 points but... well.
Using Pass2php since 2016-12
LAN: RFLink, P1-Port, OTGW, MySensors
USB: RFXCom, ZWave
WIFI: Mi-light Wifi-Bridge, Sonoff, ESP8266, Xiaomi Gateway
Solar: Omnik Inverter, PVOutput
Video: Kodi clients with Harmony HUB
Sensors: You name it I probably got 1.

deennoo
Posts: 905
Joined: Wednesday 10 December 2014 14:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Google Home

Post by deennoo » Saturday 05 August 2017 13:15

Ifttt to the same (cloudly) and fast for me, didn't try you link already.

Main challenge is to get answer from open question :
What's the temperature ?
Is there some door open ?
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / ESP8266 / MQTT / BLE
http://domo-attitude.fr

paralight
Posts: 2
Joined: Wednesday 08 February 2017 14:09
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Google Home

Post by paralight » Wednesday 09 August 2017 16:49

Flag
Interested with this connection with domoticz and Google Home.

tequila
Posts: 86
Joined: Tuesday 02 August 2016 17:08
Target OS: -
Domoticz version:
Contact:

Re: Google Home

Post by tequila » Thursday 31 August 2017 9:25

Interesting news regarding Google home and Z-Wave:

https://www.cnet.com/news/google-home-e ... th-z-wave/

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

Re: Google Home

Post by Bradds » Saturday 02 September 2017 0:20

Hi All.

To get Google home to do anything you want in domoticz, I prefer use IFTTT to send uservariables to Dom.
For example, if you setup an IFTTT for Assistant to webhooks to send "Check $ Status" or "Turn $ on" or "Set Temperature to #" or "what is the $ temperature" to Dom, you can then do whatever you want with it in Domoticz.
I use these string variables to then process commands in node red, where you can put in your own REGEX filters and get it to do anything. If you use chromecast-play node in node red you can also get it to read out temperatures, switch status, what doors are open, notify you when someone is at the door, etc... Limitless.

Also works well with google assistant on your phone, with the above setup and tasker notifications + pushover on your phone, you can get google assistant to read out temps, switch status, anything you can think of really.

Regards,

Wob76
Posts: 58
Joined: Wednesday 19 April 2017 6:31
Target OS: Linux
Domoticz version:
Contact:

Re: Google Home

Post by Wob76 » Saturday 02 September 2017 11:22

Bradds wrote:Hi All.

To get Google home to do anything you want in domoticz, I prefer use IFTTT to send uservariables to Dom.
For example, if you setup an IFTTT for Assistant to webhooks to send "Check $ Status" or "Turn $ on" or "Set Temperature to #" or "what is the $ temperature" to Dom, you can then do whatever you want with it in Domoticz.
I use these string variables to then process commands in node red, where you can put in your own REGEX filters and get it to do anything. If you use chromecast-play node in node red you can also get it to read out temperatures, switch status, what doors are open, notify you when someone is at the door, etc... Limitless.

Also works well with google assistant on your phone, with the above setup and tasker notifications + pushover on your phone, you can get google assistant to read out temps, switch status, anything you can think of really.

Regards,
Very interesting, I have incoming commands working directly with Domoticz, I just got a Google home and was going to start looking at the cast option to get it to respond. Any chance you are willing to share your flows?

Wob

Sent from my SM-G935F using Tapatalk


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

Re: Google Home

Post by Bradds » Saturday 02 September 2017 14:35

I'm out and about this weekend, but I will post an how to when I get a chance if anyone is interested.
Last edited by Bradds on Sunday 03 September 2017 0:51, edited 1 time in total.

mottola
Posts: 1
Joined: Monday 09 January 2017 17:20
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Google Home

Post by mottola » Saturday 02 September 2017 16:34

Ok.
thank you

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

Re: Google Home

Post by Bradds » Saturday 02 September 2017 23:05

Hi All.

As requested, I have managed to whip up quick guide on how I get Google Home to control my devices and read out device status of Domoticz switches/sensors.

Prerequisites. This how-to assumes you have the following installed and setup on your raspberry pi.
Domoticz. (latest stable)
Node Red. (Ver 17.5)
MQTT Broker (Mosquitto) – And MQTT Client Gateway with LAN interface configured in Dom Hardware
IFTTT Account linked to your google home – with webhooks activated.
Router configured to allow remote access to your domoticz.

To Get Google Home to read out switch/sensor status. (example flow below is for front door status and Living room temperature)
1. Setup a user variable in domoticz called “Status” (Setup > More options > User variables)
Variable Name = Status | Variable type = String | Variable value = test - Make a note of the IDX assigned to this variable as you will need it later in node red
2. Enable Dummy (Virtual) switches in Hardware section of domoticz (if you haven’t already)
3. Create a virtual switch called “Status” and Set off delay to 1 second – Make a note of the IDX assigned to this switch as you will need it later in node red.
4. Setup > More options > Events – Create a new Lua Event called “Status Var” and make sure UserVariable is selected.
5. Copy and paste this into the Status Var Event, Activate and save

commandArray = {}

if (uservariablechanged['Status']) then

print('Status requsest made')
commandArray['Status'] = 'On'

end

return commandArray

6. Logon to your IFTTT account and create a new applet for google assistant – select option – “Say a phrase with a text ingredient”
7. Fill in the first “What do you want to say?” Field with “check $ status “ 2nd “get $ status” etc…
8. Fill in the response field with whatever you want, I use “Checking $ Status”
9. For the THEN THAT option in IFTTT select webhooks
10. In the URL field copy and paste the following (obviously replacing the username/password/IP address with your own)

http://yourdomusername:[email protected]:8080/json.htm?type=command&param=updateuservariable&vname=Status&vtype=2&vvalue={{TextField}}

11. Method = GET | Content Type = text/plain | Body = leave blank …. Click Save – I recommend unchecking receive notifications as they get annoying.
12. At this stage, test it is working by saying “Ok Google, check switch status” then back under user variables in domoticz, you should now see the word “test” replaced with “switch” in the variable value. So far so good.
13. Now open node-red, goto Manage palette and install node-red-contrib-chromecast
14. Import the flow below into your node-red

[{"id":"2dc288d2.d6e988","type":"tab","label":"Flow 1"},{"id":"74b79ef.bc8ae6","type":"mqtt in","z":"2dc288d2.d6e988","name":"Local dom output","topic":"domoticz/out","qos":"0","broker":"4f2d543c.fee50c","x":121,"y":140,"wires":[["4376e10b.e8cd2"]]},{"id":"4376e10b.e8cd2","type":"json","z":"2dc288d2.d6e988","name":"","x":266.7345314025879,"y":139.15151977539062,"wires":[["9b2abc3d.83e6f"]]},{"id":"70a9a292.91ddbc","type":"json","z":"2dc288d2.d6e988","name":"","x":568.3117065429688,"y":313.7344055175781,"wires":[["cced9b03.dcd448"]]},{"id":"13709fb9.7e35f","type":"switch","z":"2dc288d2.d6e988","name":"Filter On","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"}],"checkall":"false","outputs":1,"x":880.6825485229492,"y":135.8635892868042,"wires":[["5deef4e7.bec8bc"]]},{"id":"5182a8d4.e73ab8","type":"function","z":"2dc288d2.d6e988","name":"Repub","func":"msg.topic = 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":746.7380599975586,"y":136.3000946044922,"wires":[["13709fb9.7e35f"]]},{"id":"9b2abc3d.83e6f","type":"switch","z":"2dc288d2.d6e988","name":"Status switch Filter - idx - change to yours","property":"payload.idx","propertyType":"msg","rules":[{"t":"eq","v":"6","vt":"str"}],"checkall":"false","outputs":1,"x":502.3910102844238,"y":137.04409790039062,"wires":[["5182a8d4.e73ab8"]]},{"id":"cced9b03.dcd448","type":"change","z":"2dc288d2.d6e988","name":"","rules":[{"t":"move","p":"payload.result.0.Name","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":778.9999389648438,"y":315.3375549316406,"wires":[["ae9a1a21.5f2348"]]},{"id":"5deef4e7.bec8bc","type":"http request","z":"2dc288d2.d6e988","name":"Get_Status_Variable text - change IDX to your status variable IDX","method":"GET","ret":"txt","url":"http://127.0.0.1:8080/json.htm?type=command&param=getuservariable&idx=1","tls":"","x":262.8570861816406,"y":314.33756256103516,"wires":[["70a9a292.91ddbc"]]},{"id":"ae9a1a21.5f2348","type":"switch","z":"2dc288d2.d6e988","name":"Device Name Filter","property":"payload.result.0.Value","propertyType":"msg","rules":[{"t":"regex","v":"(the )?front door","vt":"str","case":true},{"t":"eq","v":"living room temperature","vt":"str"},{"t":"else"}],"checkall":"false","outputs":3,"x":1093.4285278320312,"y":319.5714416503906,"wires":[["2532485d.99a438"],["c42d1e6.496bae"],["137ba38f.64f37c"]]},{"id":"2532485d.99a438","type":"http request","z":"2dc288d2.d6e988","name":"Get Get Front door Status - Change rid to IDX of your front door contact","method":"GET","ret":"txt","url":"http://127.0.0.1:8080/json.htm?type=devices&rid=1169","tls":"","x":1583.4285888671875,"y":239.42858695983887,"wires":[["3c7c506e.0740c"]]},{"id":"94480dd0.07104","type":"change","z":"2dc288d2.d6e988","name":"Change to NAME1/STATUS1","rules":[{"t":"move","p":"payload.result.0.Status","pt":"msg","to":"payload.STATUS1","tot":"msg"},{"t":"move","p":"payload.result.0.Name","pt":"msg","to":"payload.NAME1","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2103.8570251464844,"y":235.57143592834473,"wires":[["57302af.94548d4"]]},{"id":"3c7c506e.0740c","type":"json","z":"2dc288d2.d6e988","name":"","x":1911.1427955627441,"y":236.99998092651367,"wires":[["94480dd0.07104"]]},{"id":"57302af.94548d4","type":"function","z":"2dc288d2.d6e988","name":"TTS - Device \"is \" status Convet to Voice Google home - Change IP to your google Home IP","func":"msg.payload = {\n ip: '192.168.1.174',\n url: 'http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=the%20'+msg.payload.NAME1+'%20is%20'+msg.payload.STATUS1+'&tl=En-gb',\n};\nreturn msg;","outputs":1,"noerr":0,"x":2595.5713806152344,"y":234.57143783569336,"wires":[["9af290fd.acd65"]]},{"id":"5a6db0e3.e194e","type":"chromecast-play","z":"2dc288d2.d6e988","name":"","url":"","contentType":"","ip":"","x":3243.5712890625,"y":302.5714416503906,"wires":[[]]},{"id":"137ba38f.64f37c","type":"function","z":"2dc288d2.d6e988","name":"TTS - Device Not Found - Change IP to your google Home IP","func":"msg.payload = {\n ip: '192.168.1.174',\n url: 'http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=Device not found on your network&tl=En-gb',\n contentType: 'audio/mp3',\n};\nreturn msg;","outputs":1,"noerr":0,"x":1524.28564453125,"y":349,"wires":[["5a6db0e3.e194e"]]},{"id":"c42d1e6.496bae","type":"http request","z":"2dc288d2.d6e988","name":"Get Living Room Temp - Change RID","method":"GET","ret":"txt","url":"http://127.0.0.1:8080/json.htm?type=devices&rid=1085","tls":"","x":1431,"y":292,"wires":[["4d5c7dce.4a1d44"]]},{"id":"4d5c7dce.4a1d44","type":"json","z":"2dc288d2.d6e988","name":"","x":1665.428466796875,"y":292.9999084472656,"wires":[["f3987f95.78ac3"]]},{"id":"f3987f95.78ac3","type":"change","z":"2dc288d2.d6e988","name":"Change to Temp/Name","rules":[{"t":"move","p":"payload.result.0.Temp","pt":"msg","to":"payload.Temp","tot":"msg"},{"t":"move","p":"payload.result.0.Name","pt":"msg","to":"payload.Name","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1852.0716552734375,"y":291.71435546875,"wires":[["5dcf64be.0a3e8c"]]},{"id":"5dcf64be.0a3e8c","type":"function","z":"2dc288d2.d6e988","name":"TTS - Temp \"is\" XX Deg - Convet to Voice Google home - Change IP to your google Home IP","func":"msg.payload = {\n ip: '192.168.1.174',\n url: 'http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=the%20'+msg.payload.Name+'%20is%20'+msg.payload.Temp+'degrees&tl=En-gb',\n contentType: 'audio/mp3',\n}\nreturn msg;","outputs":1,"noerr":0,"x":2321,"y":288,"wires":[["9af290fd.acd65"]]},{"id":"9af290fd.acd65","type":"delay","z":"2dc288d2.d6e988","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":3086.5,"y":273,"wires":[["5a6db0e3.e194e"]]},{"id":"4f2d543c.fee50c","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":""}]

15. You are going to have to change the IDX of your status switch and status Variable in the flow to match your own, and also the IP address of your Google Home in the TTS function. You will also need to change the RID in the “Get XXXX status” of the device you want to query (http://127.0.0.1:8080/json.htm?type=devices&rid=1169) 1169 in this case is the IDX of my front door contact.
16. You can now test by saying “OK google, check front door status” and your google home should respond by saying “checking front door status.......the front door is closed” – or open, whatever state it is in.
17. You might want to play with the delay node before the “Play” node if your google home speaks too quickly after a request is made.
18. Once this is setup, you just need to add all your sensors/switches to the device name filter and create a Get XXXX status (http input) for each of your devices.

To switch devices, just substitute status for switch in the above How to and create an IFTTT with “Turn $ on”, Turn on $” – “Switch $ on” “Switch on $” – you get the idea. Also add Turn On before the {{textfield}} in your output url in webhooks so that you can filter Turn on – also duplicate the IFTTT for turn off
This is useful as you can create as many names as you want for each switch using the REGEX function in the filter node.
An example flow is here for turning on “main” or “Big” lights

[{"id":"da83eefa.a57ab","type":"switch","z":"81cc4560.b7ebb8","name":"Main Light Name Filter","property":"payload.result.0.Value","propertyType":"msg","rules":[{"t":"regex","v":"Turn on (the )?(main |big )(light(s)?|lite)","vt":"str","case":true},{"t":"regex","v":"Turn off (the )?(main |big )(light(s)?|lite)","vt":"str","case":true},{"t":"else"}],"checkall":"false","outputs":3,"x":379,"y":221.90552139282227,"wires":[["298f34de.3eaa8c"],["2e1696c4.b9316a"],[]]},{"id":"298f34de.3eaa8c","type":"trigger","z":"81cc4560.b7ebb8","op1":"","op2":"{\"command\": \"switchlight\", \"idx\": 440, \"switchcmd\": \"On\"}","op1type":"nul","op2type":"json","duration":"250","extend":false,"units":"ms","reset":"","name":"IDX 440 Living room main lights on","x":694.2944946289062,"y":199,"wires":[[]]},{"id":"2e1696c4.b9316a","type":"trigger","z":"81cc4560.b7ebb8","op1":"","op2":"{\"command\": \"switchlight\", \"idx\": 440, \"switchcmd\": \"Off\"}","op1type":"nul","op2type":"json","duration":"250","extend":false,"units":"ms","reset":"","name":"IDX 440 Living room main lights off","x":699.4188385009766,"y":239.92733669281006,"wires":[[]]}]

A good tool for testing regex is here … https://regex101.com/
For getting Temperature, same applies. Just create an IFTTT For “what is the $ temperature” with "Checking temperature sensor" as response. then output to the status variable as above, but add temperature after the text field in webhooks url - for filtering purposes eg. http://yourdomusername:[email protected]:8080/json.htm?type=command&param=updateuservariable&vname=Status&vtype=2&vvalue={{TextField}} temperature

Then you will get something like this. "OK, Google, what is the living room temperature" ... Checking temperature sensor ..... The living room temperature is 21 degrees.

This is probably not the most elegant way of doing this but I find it useful and very adaptable.
You can build on this to create fancy sub routines in node red, for example to check multiple doors/switches/sensors and report back which are open/closed ect..ect… Sky is the limit.
Hope this helps out some of you to unlock the full potential of integrating Google home and Domoticz.
If anyone has any ideas for improvements, please let me know.

Enjoy.

PS. Have your google home language set to UK as the US TTS conversion doesn't sound the same. The UK one does. If you want to change the TTS output to US, edit the TTS function and change the last bit of the http line to En-us.
Last edited by Bradds on Sunday 03 September 2017 12:37, edited 1 time in total.

deennoo
Posts: 905
Joined: Wednesday 10 December 2014 14:06
Target OS: Linux
Domoticz version: beta
Location: Bordeaux France
Contact:

Re: Google Home

Post by deennoo » Sunday 03 September 2017 0:48

Bradds wrote:Hi All.

As requested, I have managed to whip up quick guide on how I get Google Home to control my devices and read out device status of Domoticz switches/sensors.

Prerequisites. This how-to assumes you have the following installed and setup on your raspberry pi.
Domoticz. (latest stable)
Node Red. (Ver 17.5)
MQTT Broker (Mosquitto) – And MQTT Client Gateway with LAN interface configured in Dom Hardware
IFTTT Account linked to your google home – with webhooks activated.
Router configured to allow remote access to your domoticz.

To Get Google Home to read out switch/sensor status. (example flow below is for front door status and Living room temperature)
1. Setup a user variable in domoticz called “Status” (Setup > More options > User variables)
Variable Name = Status | Variable type = String | Variable value = test - Make a note of the IDX assigned to this variable as you will need it later in node red
2. Enable Dummy (Virtual) switches in Hardware section of domoticz (if you haven’t already)
3. Create a virtual switch called “Status” and Set off delay to 1 second – Make a note of the IDX assigned to this switch as you will need it later in node red.
4. Setup > More options > Events – Create a new Lua Event called “Status Var” and make sure UserVariable is selected.
5. Copy and paste this into the Status Var Event, Activate and save

commandArray = {}

if (uservariablechanged['Status']) then

print('Status requsest made')
commandArray['Status'] = 'On'

end

return commandArray

6. Logon to your IFTTT account and create a new applet for google assistant – select option – “Say a phrase with a text ingredient”
7. Fill in the first “What do you want to say?” Field with “check $ status “ 2nd “get $ status” etc…
8. Fill in the response field with whatever you want, I use “Checking $ Status”
9. For the THEN THAT option in IFTTT select webhooks
10. In the URL field copy and paste the following (obviously replacing the username/password/IP address with your own)

http://yourdomusername:[email protected] ... {TextField}}

11. Method = GET | Content Type = text/plain | Body = leave blank …. Click Save – I recommend unchecking receive notifications as they get annoying.
12. At this stage, test it is working by saying “Ok Google, check switch status” then back under user variables in domoticz, you should now see the word “test” replaced with “switch” in the variable value. So far so good.
13. Now open node-red, goto Manage palette and install node-red-contrib-chromecast
14. Import the flow below into your node-red

[{"id":"2dc288d2.d6e988","type":"tab","label":"Flow 1"},{"id":"74b79ef.bc8ae6","type":"mqtt in","z":"2dc288d2.d6e988","name":"Local dom output","topic":"domoticz/out","qos":"0","broker":"4f2d543c.fee50c","x":121,"y":140,"wires":[["4376e10b.e8cd2"]]},{"id":"4376e10b.e8cd2","type":"json","z":"2dc288d2.d6e988","name":"","x":266.7345314025879,"y":139.15151977539062,"wires":[["9b2abc3d.83e6f"]]},{"id":"70a9a292.91ddbc","type":"json","z":"2dc288d2.d6e988","name":"","x":568.3117065429688,"y":313.7344055175781,"wires":[["cced9b03.dcd448"]]},{"id":"13709fb9.7e35f","type":"switch","z":"2dc288d2.d6e988","name":"Filter On","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"ON","vt":"str"}],"checkall":"false","outputs":1,"x":880.6825485229492,"y":135.8635892868042,"wires":[["5deef4e7.bec8bc"]]},{"id":"5182a8d4.e73ab8","type":"function","z":"2dc288d2.d6e988","name":"Repub","func":"msg.topic = 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":746.7380599975586,"y":136.3000946044922,"wires":[["13709fb9.7e35f"]]},{"id":"9b2abc3d.83e6f","type":"switch","z":"2dc288d2.d6e988","name":"Status switch Filter - idx - change to yours","property":"payload.idx","propertyType":"msg","rules":[{"t":"eq","v":"6","vt":"str"}],"checkall":"false","outputs":1,"x":502.3910102844238,"y":137.04409790039062,"wires":[["5182a8d4.e73ab8"]]},{"id":"cced9b03.dcd448","type":"change","z":"2dc288d2.d6e988","name":"","rules":[{"t":"move","p":"payload.result.0.Name","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":778.9999389648438,"y":315.3375549316406,"wires":[["ae9a1a21.5f2348"]]},{"id":"5deef4e7.bec8bc","type":"http request","z":"2dc288d2.d6e988","name":"Get_Status_Variable text - change IDX to your status variable IDX","method":"GET","ret":"txt","url":"http://127.0.0.1:8080/json.htm?type=com ... 516,"wires":[["70a9a292.91ddbc"]]},{"id":"ae9a1a21.5f2348","type":"switch","z":"2dc288d2.d6e988","name":"Device Name Filter","property":"payload.result.0.Value","propertyType":"msg","rules":[{"t":"regex","v":"the? front door","vt":"str","case":true},{"t":"eq","v":"living room temperature","vt":"str"},{"t":"else"}],"checkall":"false","outputs":3,"x":1093.4285278320312,"y":319.5714416503906,"wires":[["2532485d.99a438"],["c42d1e6.496bae"],["137ba38f.64f37c"]]},{"id":"2532485d.99a438","type":"http request","z":"2dc288d2.d6e988","name":"Get Get Front door Status - Change rid to IDX of your front door contact","method":"GET","ret":"txt","url":"http://127.0.0.1:8080/json.htm?type=dev ... 887,"wires":[["3c7c506e.0740c"]]},{"id":"94480dd0.07104","type":"change","z":"2dc288d2.d6e988","name":"Change to NAME1/STATUS1","rules":[{"t":"move","p":"payload.result.0.Status","pt":"msg","to":"payload.STATUS1","tot":"msg"},{"t":"move","p":"payload.result.0.Name","pt":"msg","to":"payload.NAME1","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2103.8570251464844,"y":235.57143592834473,"wires":[["57302af.94548d4"]]},{"id":"3c7c506e.0740c","type":"json","z":"2dc288d2.d6e988","name":"","x":1911.1427955627441,"y":236.99998092651367,"wires":[["94480dd0.07104"]]},{"id":"57302af.94548d4","type":"function","z":"2dc288d2.d6e988","name":"TTS - Device \"is \" status Convet to Voice Google home - Change IP to your google Home IP","func":"msg.payload = {\n ip: '192.168.1.174',\n url: 'http://translate.google.com/translate_t ... };\nreturn msg;","outputs":1,"noerr":0,"x":2595.5713806152344,"y":234.57143783569336,"wires":[["9af290fd.acd65"]]},{"id":"5a6db0e3.e194e","type":"chromecast-play","z":"2dc288d2.d6e988","name":"","url":"","contentType":"","ip":"","x":3243.5712890625,"y":302.5714416503906,"wires":[[]]},{"id":"137ba38f.64f37c","type":"function","z":"2dc288d2.d6e988","name":"TTS - Device Not Found - Change IP to your google Home IP","func":"msg.payload = {\n ip: '192.168.1.174',\n url: 'http://translate.google.com/translate_t ... b&q=Device not found on your network&tl=En-gb',\n contentType: 'audio/mp3',\n};\nreturn msg;","outputs":1,"noerr":0,"x":1524.28564453125,"y":349,"wires":[["5a6db0e3.e194e"]]},{"id":"c42d1e6.496bae","type":"http request","z":"2dc288d2.d6e988","name":"Get Living Room Temp - Change RID","method":"GET","ret":"txt","url":"http://127.0.0.1:8080/json.htm?type=dev ... 292,"wires":[["4d5c7dce.4a1d44"]]},{"id":"4d5c7dce.4a1d44","type":"json","z":"2dc288d2.d6e988","name":"","x":1665.428466796875,"y":292.9999084472656,"wires":[["f3987f95.78ac3"]]},{"id":"f3987f95.78ac3","type":"change","z":"2dc288d2.d6e988","name":"Change to Temp/Name","rules":[{"t":"move","p":"payload.result.0.Temp","pt":"msg","to":"payload.Temp","tot":"msg"},{"t":"move","p":"payload.result.0.Name","pt":"msg","to":"payload.Name","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1852.0716552734375,"y":291.71435546875,"wires":[["5dcf64be.0a3e8c"]]},{"id":"5dcf64be.0a3e8c","type":"function","z":"2dc288d2.d6e988","name":"TTS - Temp \"is\" XX Deg - Convet to Voice Google home - Change IP to your google Home IP","func":"msg.payload = {\n ip: '192.168.1.174',\n url: 'http://translate.google.com/translate_t ... =En-gb',\n contentType: 'audio/mp3',\n}\nreturn msg;","outputs":1,"noerr":0,"x":2321,"y":288,"wires":[["9af290fd.acd65"]]},{"id":"9af290fd.acd65","type":"delay","z":"2dc288d2.d6e988","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":3086.5,"y":273,"wires":[["5a6db0e3.e194e"]]},{"id":"4f2d543c.fee50c","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":""}]

15. You are going to have to change the IDX of your status switch and status Variable in the flow to match your own, and also the IP address of your Google Home in the TTS function. You will also need to change the RID in the “Get XXXX status” of the device you want to query (http://127.0.0.1:8080/json.htm?type=devices&rid=1169) 1169 in this case is the IDX of my front door contact.
16. You can now test by saying “OK google, check front door status” and your google home should respond by saying “checking front door status.......the front door is closed” – or open, whatever state it is in.
17. You might want to play with the delay node before the “Play” node if your google home speaks too quickly after a request is made.
18. Once this is setup, you just need to add all your sensors/switches to the device name filter and create a Get XXXX status (http input) for each of your devices.

To switch devices, just substitute status for switch in the above How to and create an IFTTT with “Turn $ on”, Turn on $” – “Switch $ on” “Switch on $” – you get the idea. Also add Turn On before the {{textfield}} in your output url in webhooks so that you can filter Turn on – also duplicate the IFTTT for turn off
This is useful as you can create as many names as you want for each switch using the REGEX function in the filter node.
An example flow is here for turning on “main” or “Big” lights

[{"id":"da83eefa.a57ab","type":"switch","z":"81cc4560.b7ebb8","name":"Main Light Name Filter","property":"payload.result.0.Value","propertyType":"msg","rules":[{"t":"regex","v":"Turn on (the )?(main |big )(light(s)?|lite)","vt":"str","case":true},{"t":"regex","v":"Turn off (the )?(main |big )(light(s)?|lite)","vt":"str","case":true},{"t":"else"}],"checkall":"false","outputs":3,"x":379,"y":221.90552139282227,"wires":[["298f34de.3eaa8c"],["2e1696c4.b9316a"],[]]},{"id":"298f34de.3eaa8c","type":"trigger","z":"81cc4560.b7ebb8","op1":"","op2":"{\"command\": \"switchlight\", \"idx\": 440, \"switchcmd\": \"On\"}","op1type":"nul","op2type":"json","duration":"250","extend":false,"units":"ms","reset":"","name":"IDX 440 Living room main lights on","x":694.2944946289062,"y":199,"wires":[[]]},{"id":"2e1696c4.b9316a","type":"trigger","z":"81cc4560.b7ebb8","op1":"","op2":"{\"command\": \"switchlight\", \"idx\": 440, \"switchcmd\": \"Off\"}","op1type":"nul","op2type":"json","duration":"250","extend":false,"units":"ms","reset":"","name":"IDX 440 Living room main lights off","x":699.4188385009766,"y":239.92733669281006,"wires":[[]]}]

A good tool for testing regex is here … https://regex101.com/
For getting Temperature, same applies. Just create an IFTTT For “what is the $ temperature” with "Checking temperature sensor" as response. then output to the status variable as above, but add temperature after the text field in webhooks url - for filtering purposes eg. http://yourdomusername:[email protected] ... {TextField}} temperature

Then you will get something like this. "OK, Google, what is the living room temperature" ... Checking temperature sensor ..... The living room temperature is 21 degrees.

This is probably not the most elegant way of doing this but I find it useful and very adaptable.
You can build on this to create fancy sub routines in node red, for example to check multiple doors/switches/sensors and report back which are open/closed ect..ect… Sky is the limit.
Hope this helps out some of you to unlock the full potential of integrating Google home and Domoticz.
If anyone has any ideas for improvements, please let me know.

Enjoy.

PS. Have your google home language set to UK as the US TTS conversion doesn't sound the same. The UK one does. If you want to change the TTS output to US, edit the TTS function and change the last bit of the http line to En-us.
Nice how to, just question, if i listen à TuneIn station does Google home will continu to play it ?
Domoticz stable 3.5877 for real & Domoticz beta for test
Rfxtrxe / RFLink / Milight / Yeelight / ESP8266 / MQTT / BLE
http://domo-attitude.fr

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

Re: Google Home

Post by Bradds » Sunday 03 September 2017 0:59

Unfortunately no. Any playback gets interrupted and wont resume automatically.

Wob76
Posts: 58
Joined: Wednesday 19 April 2017 6:31
Target OS: Linux
Domoticz version:
Contact:

Re: Google Home

Post by Wob76 » Sunday 03 September 2017 2:59

Thanks so much for making the effort Bradds, I'll be giving this a try this werk.

Sent from my SM-G935F using Tapatalk


Wob76
Posts: 58
Joined: Wednesday 19 April 2017 6:31
Target OS: Linux
Domoticz version:
Contact:

Re: Google Home

Post by Wob76 » Monday 11 September 2017 6:31

Hi All,

I have taken @Bradds very nice work and expanded on it, it works great, but started to get messy when I had a heap of devices in it. I also wanted to limit how much I needed to modify the flow. So instead of relying on the switch in nodered to map regex to a rid I decided to see if I could get it to pull data from Domoticz.

I now have it working, although I am going to call it alpha\beta as I have only had it going for a few days, but thought I would put it up for anyone wanting to try.

I won't double up on the great info that Bradds posted, his info for MQTT, IFTTT, etc all still stand. You need all that working before you need my flow.

I wanted to keep using regex, as I like how flexible it is for a device name, that proved to be a pain when comparing the array in a function, well at least for my limited program skills (I have only been using nodered\javascript for a couple of months), but I got there. The script does JSON commands to Domoticz, one to get the Status Variable (your command from IFTT) and a second to pull down the list of devices.

What my flow does is move the regex from nodered into Domoticz, You need to add a description for any device you want to talk and start it with "GoogleHome: " (space included) then followed by your regex. You can define a different prefix in the flow if you so choose.

Example
Description.JPG
Description.JPG (15.67 KiB) Viewed 1317 times
I have tried to keep the flow as beginner friendly as I could, all the things you need to define to make it work on your system should be in the "Define User Variables" node, settings include.
  • msg.user.dom_ip = You Domoticz servers IP, or 127.0.0.1 if running on the same box. Example: 192.168.0.1
  • msg.user.dom_port = The port Domoticz uses (default 8080), if you use https you will need to modify the url in the http nodes.
  • msg.user.status_switch = The IDX of the switch created in Bradds instructions.
  • msg.user.status_var = The IDX of the Variable as created in Bradds instructions.
  • msg.user.desc_filter = The prefix\filter used to identify devices to talk to.
  • flow.goolgehome.ip = The IP Address of your Google Home\Chromecast Device, you will need this to be static, eg, 192.168.0.2
  • flow.goolgehome.lang = The Language used with TTS, I used En-au, Bradds uses En-uk, US is En-us, or find your own.
  • flow.goolgehome.volume = Sets the volume for the message sent, you will need a modified version of the chromecast node for this to have any effect (see here)
I have built the switch nodes for devices I have, so currently it supports
  • Temperature Sensors (Read Temperature)
  • Switches (Read state)
  • Selector Switches (It will read the Level Name as defined on the switch)
  • Thermostat (Read the setpoint)
  • Power Usage Utility (Read the Current Day Usage)
You can add devices if you have the outside my scope, just see the note in the flow, hopefully it makes sense, you just need to define Type and maybe SubType, then create a matching TTS Function (again see the note in the flow).

As with Bradds flow, if you want to modify the delay you can do so just before the "Speak" node.

Please let me know if you give this a go, if you have any problems, or if you need any help.

Finally here is the nodered flow

Code: Select all

[{"id":"158b1b00.fb8335","type":"tab","label":"Dom 2 Google Home","disabled":false,"info":""},{"id":"18b55b5c.584965","type":"mqtt in","z":"158b1b00.fb8335","name":"From Dom","topic":"domoticz/out/#","qos":"0","broker":"","x":100,"y":60,"wires":[["e22696bb.e14b78"]]},{"id":"e22696bb.e14b78","type":"json","z":"158b1b00.fb8335","name":"","x":225.7345314025879,"y":59.151519775390625,"wires":[["f244e1bd.254b3"]]},{"id":"2989c93.da6bd36","type":"switch","z":"158b1b00.fb8335","name":"Filter \"On\"","property":"payload.nvalue","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"}],"checkall":"false","outputs":1,"x":130,"y":200,"wires":[["d1c37b95.df5ad8","e18ecc75.aefe6"]]},{"id":"1e9dfe05.0c6ca2","type":"switch","z":"158b1b00.fb8335","name":"Status switch filter","property":"payload.idx","propertyType":"msg","rules":[{"t":"eq","v":"user.status_switch","vt":"msg"}],"checkall":"false","outputs":1,"x":610,"y":60,"wires":[["2989c93.da6bd36"]]},{"id":"7bc830bc.de823","type":"json","z":"158b1b00.fb8335","name":"","x":490,"y":220,"wires":[["a5028170.79fba"]]},{"id":"a5028170.79fba","type":"change","z":"158b1b00.fb8335","name":"Set Topic","rules":[{"t":"move","p":"payload.result.0.Name","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":620,"y":220,"wires":[["2f21a414.0588ac"]]},{"id":"e18ecc75.aefe6","type":"http request","z":"158b1b00.fb8335","name":"Get_Status_Variable","method":"GET","ret":"txt","url":"http://{{{user.dom_ip}}}:{{{user.dom_port}}}/json.htm?type=command&param=getuservariable&idx={{{user.status_var}}}","tls":"","x":320,"y":220,"wires":[["7bc830bc.de823"]]},{"id":"2f21a414.0588ac","type":"join","z":"158b1b00.fb8335","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","x":790,"y":220,"wires":[["f07e74be.6866b8"]]},{"id":"f07e74be.6866b8","type":"function","z":"158b1b00.fb8335","name":"Find Match","func":"// This function compares our request to our array of devices, using the Description\n// It is designed for a descripton that is in regex format\n// Only the first result will be used downstream\n// if you are seeing multiple matches you could debug this node to check your regex patterns\n\nvar devices = msg.payload.Devices;\nvar request = [ msg.payload.Status.result[0].Value ];\n\nvar match = devices.filter(function (regex) {\n    return request.some(function (text) {\n        var realregex = new RegExp(regex.Description, \"i\"); // convert description to real regex\n        return text.match(realregex);\n    });\n});\n\nif (match.length === 0) {   // If array is empty, no matches found\n    request = request.toString();\n    var match = [ { Type: \"Error\", request } ];\n}\n\nvar msg = { topic:\"Output\", payload: { match:match } };\n\nreturn msg;","outputs":"1","noerr":0,"x":130,"y":440,"wires":[["e01e6da2.c7339"]]},{"id":"d1c37b95.df5ad8","type":"http request","z":"158b1b00.fb8335","name":"Get Device List","method":"GET","ret":"obj","url":"http://{{{user.dom_ip}}}:{{{user.dom_port}}}/json.htm?type=devices&filter=all&used=true&order=Name","tls":"","x":300,"y":180,"wires":[["6d1ca91e.a97f78"]]},{"id":"6d1ca91e.a97f78","type":"change","z":"158b1b00.fb8335","name":"Just Devices","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.result","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":180,"wires":[["35276c93.d95bd4"]]},{"id":"35276c93.d95bd4","type":"function","z":"158b1b00.fb8335","name":"Filter Array","func":"// This function filters our devices down to results with our filter term in the \"Description\"\n// It them strips the filter term\\prefix\n\nvar filter = msg.user.desc_filter;\nvar arr = msg.payload;\n\nvar matches = arr.filter(function (item) {\n        if (item.Description.indexOf(filter)>-1) {\n            item.Description = item.Description.replace(filter, \"\");    // strip the prefix\n            return item;\n        }\n});\n\nvar msg = { topic:\"Devices\", payload: matches };\n\nreturn msg;","outputs":1,"noerr":0,"x":630,"y":180,"wires":[["2f21a414.0588ac"]]},{"id":"9afacd2b.8b4e7","type":"chromecast-play","z":"158b1b00.fb8335","name":"Speak","url":"","contentType":"audio/mp3","ip":"","volume":"","x":1190,"y":420,"wires":[["88639723.c3a738"]]},{"id":"3c40efc5.2d43","type":"delay","z":"158b1b00.fb8335","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1040,"y":420,"wires":[["1a367f2c.ab9e61","9afacd2b.8b4e7"]]},{"id":"88639723.c3a738","type":"debug","z":"158b1b00.fb8335","name":"Output","active":true,"console":"false","complete":"payload","x":1310,"y":420,"wires":[]},{"id":"458fc401.dd55fc","type":"function","z":"158b1b00.fb8335","name":"The device, $device, has not been configured","func":"msg.payload = {\n url: 'http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=The device, '+msg.payload.match[0].request+', has not been configured&tl='+flow.get(\"goolgehome.lang\"),\n};\nmsg.payload.ip = flow.get(\"goolgehome.ip\");\nmsg.payload.volume = flow.get(\"goolgehome.volume\");\nreturn msg;","outputs":1,"noerr":0,"x":790,"y":540,"wires":[["3c40efc5.2d43"]]},{"id":"37f94140.355a9e","type":"function","z":"158b1b00.fb8335","name":"The $ Temp is XX Deg","func":"msg.payload = {\n url: 'http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=The '+msg.payload.match[0].Name+' is '+msg.payload.match[0].Temp+' degrees&tl='+flow.get(\"goolgehome.lang\"),\n};\nmsg.payload.ip = flow.get(\"goolgehome.ip\");\nmsg.payload.volume = flow.get(\"goolgehome.volume\");\nreturn msg;","outputs":1,"noerr":0,"x":720,"y":340,"wires":[["3c40efc5.2d43"]]},{"id":"60b70a67.d91b34","type":"function","z":"158b1b00.fb8335","name":"The $device is on/off","func":"msg.payload = {\n url: 'http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=The '+msg.payload.match[0].Name+' is '+msg.payload.match[0].Status+'&tl='+flow.get(\"goolgehome.lang\"),\n};\nmsg.payload.ip = flow.get(\"goolgehome.ip\");\nmsg.payload.volume = flow.get(\"goolgehome.volume\");\nreturn msg;","outputs":1,"noerr":0,"x":720,"y":380,"wires":[["3c40efc5.2d43"]]},{"id":"6d33c273.052a8c","type":"function","z":"158b1b00.fb8335","name":"The $device is set to XX Deg","func":"msg.payload = {\n url: 'http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=The '+msg.payload.match[0].Name+' is set to '+msg.payload.match[0].SetPoint+' degrees&tl='+flow.get(\"goolgehome.lang\"),\n};\nmsg.payload.ip = flow.get(\"goolgehome.ip\");\nmsg.payload.volume = flow.get(\"goolgehome.volume\");\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":460,"wires":[["3c40efc5.2d43"]]},{"id":"e01e6da2.c7339","type":"switch","z":"158b1b00.fb8335","name":"Device Type","property":"payload.match[0].Type","propertyType":"msg","rules":[{"t":"cont","v":"Temp","vt":"str"},{"t":"eq","v":"Light/Switch","vt":"str"},{"t":"eq","v":"Thermostat","vt":"str"},{"t":"eq","v":"General","vt":"str"},{"t":"eq","v":"Error","vt":"str"}],"checkall":"true","outputs":5,"x":290,"y":440,"wires":[["37f94140.355a9e"],["568a63b7.83fc0c"],["6d33c273.052a8c"],["82787a49.f6f858"],["458fc401.dd55fc"]]},{"id":"568a63b7.83fc0c","type":"switch","z":"158b1b00.fb8335","name":"SubType","property":"payload.match[0].SubType","propertyType":"msg","rules":[{"t":"eq","v":"Switch","vt":"str"},{"t":"eq","v":"Selector Switch","vt":"str"}],"checkall":"true","outputs":2,"x":540,"y":400,"wires":[["60b70a67.d91b34"],["be2b1e.a6c114e"]]},{"id":"be2b1e.a6c114e","type":"function","z":"158b1b00.fb8335","name":"The $device is set to $levelname","func":"var levelnames = msg.payload.match[0].LevelNames;\nvar setlevel = msg.payload.match[0].Level;\n\nlevelnames = levelnames.split(\"|\");\nsetlevel = setlevel/10;\n\nvar Status = levelnames[setlevel];\n\nmsg.payload = {\n url: 'http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=The '+msg.payload.match[0].Name+' is set to '+Status+'&tl='+flow.get(\"goolgehome.lang\"),\n};\nmsg.payload.ip = flow.get(\"goolgehome.ip\");\nmsg.payload.volume = flow.get(\"goolgehome.volume\");\nreturn msg;","outputs":1,"noerr":0,"x":760,"y":420,"wires":[["3c40efc5.2d43"]]},{"id":"1a367f2c.ab9e61","type":"debug","z":"158b1b00.fb8335","name":"TTS","active":true,"console":"false","complete":"true","x":1190,"y":360,"wires":[]},{"id":"f244e1bd.254b3","type":"change","z":"158b1b00.fb8335","name":"Define User Variables","rules":[{"t":"set","p":"user.dom_ip","pt":"msg","to":"192.168.0.1","tot":"str"},{"t":"set","p":"user.dom_port","pt":"msg","to":"8080","tot":"str"},{"t":"set","p":"user.status_switch","pt":"msg","to":"81","tot":"str"},{"t":"set","p":"user.status_var","pt":"msg","to":"4","tot":"str"},{"t":"set","p":"user.desc_filter","pt":"msg","to":"GoogleHome: ","tot":"str"},{"t":"set","p":"goolgehome.ip","pt":"flow","to":"192.168.0.2","tot":"str"},{"t":"set","p":"goolgehome.lang","pt":"flow","to":"En-au","tot":"str"},{"t":"set","p":"goolgehome.volume","pt":"flow","to":"40","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":60,"wires":[["1e9dfe05.0c6ca2"]]},{"id":"60f156f9.9508b8","type":"comment","z":"158b1b00.fb8335","name":"TTS Block","info":"These are the calls to Googles Text To Speech Service (TTS), \nthey create a MP3 of the desired responses.\n\nApart from wording and variable mapping in the payload they are\nall similar, EXCEPT for the Selector Switch function.\n\nIt required more code to decode the current level and map it to the level the name.","x":720,"y":300,"wires":[]},{"id":"82787a49.f6f858","type":"switch","z":"158b1b00.fb8335","name":"SubType","property":"payload.match[0].SubType","propertyType":"msg","rules":[{"t":"eq","v":"kWh","vt":"str"}],"checkall":"true","outputs":1,"x":540,"y":480,"wires":[["4fb68787.cf3ed8"]]},{"id":"4fb68787.cf3ed8","type":"function","z":"158b1b00.fb8335","name":"The $device for today is xx kwh","func":"msg.payload = {\n url: 'http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q=The '+msg.payload.match[0].Name+' for today is '+msg.payload.match[0].CounterToday+'&tl='+flow.get(\"goolgehome.lang\"),\n};\nmsg.payload.ip = flow.get(\"goolgehome.ip\");\nmsg.payload.volume = flow.get(\"goolgehome.volume\");\nreturn msg;","outputs":1,"noerr":0,"x":750,"y":500,"wires":[["3c40efc5.2d43"]]},{"id":"57d4fb20.9ad4b4","type":"comment","z":"158b1b00.fb8335","name":"Device Filtering","info":"You can define new devices in these set of switches,\nyou will only need a \"SubType\" switch if you have more than one of that Type,\nand you need\\want them to say something different.\n\nMy Examples that needed sub-type\n\"Selector\" switches would only be on\\off, you would not here the level they are set to.\n\n\"Power Usage\" devices only have \"General\" for Type, not very definative,\nso although I do not have any other general type devices I am planning ahead for those.\n\nYou could filter on SubType alone, but you would need to adjust for differnt temp\nsensor makers. If you do this you will need to modify the \"Error Message\" on the previous\nfunction to write to SubType rather than Type.","x":420,"y":540,"wires":[]}]
Last edited by Wob76 on Wednesday 13 September 2017 2:08, edited 2 times in total.

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

Re: Google Home

Post by Bradds » Wednesday 13 September 2017 1:46

Wob76.

Great work mate, tried your flow and it works a charm. Never occurred to me to use the dom desc for regex.

Thanks.

Bradds.

Wob76
Posts: 58
Joined: Wednesday 19 April 2017 6:31
Target OS: Linux
Domoticz version:
Contact:

Re: Google Home

Post by Wob76 » Wednesday 13 September 2017 2:07

No problem Bradds, I am glad it works for you, I wouldn't have know where to start without your info :) I think the Alexa "Skill" does something similar with a Friendly Name in the Description, but it doesn't use regex I don't think.

My next step is to look at incorporating On/Off Commands in this flow.

I am also thinking of making a flow to incorporate status from a group of devices, for example, if I ask "What is the Status of the AC" it will return the power state, if "On" it will also report the mode it is on, fan speed, set temp and the zones that are on. Will save asking multiple questions. Also something like tell me what lights are on, or what doors are open etc.

Let me know if you add any improvements :)

Wob

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

Re: Google Home

Post by Bradds » Wednesday 13 September 2017 18:32

Wob,

I check multiple status of "doors" & "windows" by running a grab on each RID and adding it to the topic if open, then spitting out the result to GH.
Although not as elegant as your solution, it works.

Here is the flow for checking doors. I only have 5 on the system, so not a big deal.
It gets its call form a node filter as before (regex on separate flow) ("Check doors status") etc..

I have removed some nodes as I split requests depending whether they come from home or mobile, but it should give you the idea of what it achieves.

Code: Select all

[{"id":"fdc501fd.c4dd6","type":"http request","z":"788aa3af.5d48dc","name":"Get Office door Status","method":"GET","ret":"txt","url":"http://127.0.0.1:8080/json.htm?type=devices&rid=1126","tls":"","x":582.3943357467651,"y":742.4013233184814,"wires":[["ab7a6dbf.502a4"]]},{"id":"e8101b74.76bb38","type":"http request","z":"788aa3af.5d48dc","name":"Get Front door Status","method":"GET","ret":"txt","url":"http://127.0.0.1:8080/json.htm?type=devices&rid=1169","tls":"","x":578.9850845336914,"y":819.7312994003296,"wires":[["64ad0d66.0a8a24"]]},{"id":"aee3ba8d.c9eac8","type":"http request","z":"788aa3af.5d48dc","name":"Get Side gate Status","method":"GET","ret":"txt","url":"http://127.0.0.1:8080/json.htm?type=devices&rid=580","tls":"","x":586.9958267211914,"y":883.0289678573608,"wires":[["425a7a9d.b65564"]]},{"id":"77dc082.a85e4f8","type":"http request","z":"788aa3af.5d48dc","name":"Get Back door Status","method":"GET","ret":"txt","url":"http://127.0.0.1:8080/json.htm?type=devices&rid=99","tls":"","x":586.0053482055664,"y":924.2555313110352,"wires":[["f3158df6.d6ed4"]]},{"id":"eb75a70.695b958","type":"http request","z":"788aa3af.5d48dc","name":"Get Garage door Status","method":"GET","ret":"txt","url":"http://127.0.0.1:8080/json.htm?type=devices&rid=1165","tls":"","x":590.8989028930664,"y":971.0748672485352,"wires":[["253378f8.2210d8"]]},{"id":"d83ade13.d6731","type":"change","z":"788aa3af.5d48dc","name":"Change to NAME/STATUS","rules":[{"t":"move","p":"payload.result.0.Status","pt":"msg","to":"payload.STATUS","tot":"msg"},{"t":"move","p":"payload.result.0.Name","pt":"msg","to":"payload.NAME","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":951.0236663818359,"y":752.7699937820435,"wires":[["e9df69f9.4221d8"]]},{"id":"ab7a6dbf.502a4","type":"json","z":"788aa3af.5d48dc","name":"","x":752.2737884521484,"y":747.7699937820435,"wires":[["d83ade13.d6731"]]},{"id":"92295d80.5a873","type":"comment","z":"788aa3af.5d48dc","name":"HOME Door Configurations","info":"","x":926.7499847412109,"y":635.3413600921631,"wires":[]},{"id":"e9df69f9.4221d8","type":"switch","z":"788aa3af.5d48dc","name":"Open/Closed","property":"payload.STATUS","propertyType":"msg","rules":[{"t":"eq","v":"Open","vt":"str"},{"t":"eq","v":"Closed","vt":"str"}],"checkall":"false","outputs":2,"x":1215.3570938110352,"y":748.4127540588379,"wires":[["db726b58.288bd8"],["e8101b74.76bb38"]]},{"id":"64ad0d66.0a8a24","type":"json","z":"788aa3af.5d48dc","name":"","x":750.0000762939453,"y":822.3413314819336,"wires":[["8e57c5c4.6ff6f8"]]},{"id":"425a7a9d.b65564","type":"json","z":"788aa3af.5d48dc","name":"","x":760.0000762939453,"y":881.0913314819336,"wires":[["f7d27195.c8a95"]]},{"id":"f3158df6.d6ed4","type":"json","z":"788aa3af.5d48dc","name":"","x":761.2500762939453,"y":923.5913314819336,"wires":[["d6d57f22.62379"]]},{"id":"253378f8.2210d8","type":"json","z":"788aa3af.5d48dc","name":"","x":775.0000762939453,"y":972.3413314819336,"wires":[["884e860f.d2e2e8"]]},{"id":"8e57c5c4.6ff6f8","type":"change","z":"788aa3af.5d48dc","name":"Change to NAME/STATUS","rules":[{"t":"move","p":"payload.result.0.Status","pt":"msg","to":"payload.STATUS","tot":"msg"},{"t":"move","p":"payload.result.0.Name","pt":"msg","to":"payload.NAME","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":962.4999542236328,"y":823.5913314819336,"wires":[["6ca05def.8d5004"]]},{"id":"6ca05def.8d5004","type":"switch","z":"788aa3af.5d48dc","name":"Open/Closed","property":"payload.STATUS","propertyType":"msg","rules":[{"t":"eq","v":"Open","vt":"str"},{"t":"eq","v":"Closed","vt":"str"}],"checkall":"false","outputs":2,"x":1193.976276397705,"y":820.6626815795898,"wires":[["61237ee1.efb9f"],["aee3ba8d.c9eac8"]]},{"id":"f7d27195.c8a95","type":"change","z":"788aa3af.5d48dc","name":"Change to NAME/STATUS","rules":[{"t":"move","p":"payload.result.0.Status","pt":"msg","to":"payload.STATUS","tot":"msg"},{"t":"move","p":"payload.result.0.Name","pt":"msg","to":"payload.NAME","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":978.7499542236328,"y":884.8413314819336,"wires":[["61827a31.c2fdc4"]]},{"id":"61827a31.c2fdc4","type":"switch","z":"788aa3af.5d48dc","name":"Open/Closed","property":"payload.STATUS","propertyType":"msg","rules":[{"t":"eq","v":"Open","vt":"str"},{"t":"eq","v":"Closed","vt":"str"}],"checkall":"false","outputs":2,"x":1210.2263107299805,"y":880.6626958847046,"wires":[["ede4e04d.c776a"],["77dc082.a85e4f8"]]},{"id":"d6d57f22.62379","type":"change","z":"788aa3af.5d48dc","name":"Change to NAME/STATUS","rules":[{"t":"move","p":"payload.result.0.Status","pt":"msg","to":"payload.STATUS","tot":"msg"},{"t":"move","p":"payload.result.0.Name","pt":"msg","to":"payload.NAME","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":972.4999542236328,"y":927.3413314819336,"wires":[["7556f607.bdbd78"]]},{"id":"7556f607.bdbd78","type":"switch","z":"788aa3af.5d48dc","name":"Open/Closed","property":"payload.STATUS","propertyType":"msg","rules":[{"t":"eq","v":"Open","vt":"str"},{"t":"eq","v":"Closed","vt":"str"}],"checkall":"false","outputs":2,"x":1203.976276397705,"y":924.4126815795898,"wires":[["2748313c.a69bae"],["eb75a70.695b958"]]},{"id":"884e860f.d2e2e8","type":"change","z":"788aa3af.5d48dc","name":"Change to NAME/STATUS","rules":[{"t":"move","p":"payload.result.0.Status","pt":"msg","to":"payload.STATUS","tot":"msg"},{"t":"move","p":"payload.result.0.Name","pt":"msg","to":"payload.NAME","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":991.2499542236328,"y":976.0913314819336,"wires":[["591f3911.72cb58"]]},{"id":"591f3911.72cb58","type":"switch","z":"788aa3af.5d48dc","name":"Open/Closed","property":"payload.STATUS","propertyType":"msg","rules":[{"t":"eq","v":"Open","vt":"str"},{"t":"eq","v":"Closed","vt":"str"}],"checkall":"false","outputs":2,"x":1222.726276397705,"y":973.1626815795898,"wires":[["58d1f845.58cfe8"],["b86f5d04.fddde"]]},{"id":"61237ee1.efb9f","type":"function","z":"788aa3af.5d48dc","name":"NOT \"all doors are closed\" then ADD","func":"if (msg.topic != \"all doors are closed\") {\nmsg.topic = [msg.topic + \" and \" + msg.payload.NAME];\n}\nelse \n{\nmsg.topic = [msg.payload.NAME];\n}\nreturn msg;","outputs":1,"noerr":0,"x":1484.2857666015625,"y":808.0556535720825,"wires":[["aee3ba8d.c9eac8"]]},{"id":"b5539f30.c3769","type":"function","z":"788aa3af.5d48dc","name":"all doors are closed","func":"msg.topic = \"all doors are closed\";\nreturn msg;","outputs":1,"noerr":0,"x":335,"y":747.3413677215576,"wires":[["fdc501fd.c4dd6"]]},{"id":"bc085af1.c7f9b8","type":"function","z":"788aa3af.5d48dc","name":"add \"the\" XX \"is open\"","func":"msg.topic = \"the \" + msg.topic + \" is open\";\nreturn msg;","outputs":1,"noerr":0,"x":2160.154541015625,"y":952.7699584960938,"wires":[["bc65b31b.69589","3f9c8f54.eb9ca"]]},{"id":"db726b58.288bd8","type":"function","z":"788aa3af.5d48dc","name":"Change topic to name","func":"msg.topic = [msg.payload.NAME];\nreturn msg;","outputs":1,"noerr":0,"x":1436.6071319580078,"y":736.0913314819336,"wires":[["e8101b74.76bb38"]]},{"id":"ede4e04d.c776a","type":"function","z":"788aa3af.5d48dc","name":"NOT \"all doors are closed\" then ADD","func":"if (msg.topic != \"all doors are closed\") {\nmsg.topic = [msg.topic + \" and \" + msg.payload.NAME];\n}\nelse \n{\nmsg.topic = [msg.payload.NAME];\n}\nreturn msg;","outputs":1,"noerr":0,"x":1492.3214111328125,"y":864.6627607345581,"wires":[["77dc082.a85e4f8"]]},{"id":"2748313c.a69bae","type":"function","z":"788aa3af.5d48dc","name":"NOT \"all doors are closed\" then ADD","func":"if (msg.topic != \"all doors are closed\") {\nmsg.topic = [msg.topic + \" and \" + msg.payload.NAME];\n}\nelse \n{\nmsg.topic = [msg.payload.NAME];\n}\nreturn msg;","outputs":1,"noerr":0,"x":1502.3213424682617,"y":911.8056259155273,"wires":[["eb75a70.695b958"]]},{"id":"58d1f845.58cfe8","type":"function","z":"788aa3af.5d48dc","name":"NOT \"all doors are closed\" then ADD","func":"if (msg.topic != \"all doors are closed\") {\nmsg.topic = [msg.topic + \" and \" + msg.payload.NAME];\n}\nelse \n{\nmsg.topic = [msg.payload.NAME];\n}\nreturn msg;","outputs":1,"noerr":0,"x":1488.0355987548828,"y":963.2341537475586,"wires":[["bc085af1.c7f9b8"]]},{"id":"b86f5d04.fddde","type":"switch","z":"788aa3af.5d48dc","name":"check topic for \"all doors are closed\"","property":"topic","propertyType":"msg","rules":[{"t":"neq","v":"all doors are closed","vt":"str"},{"t":"eq","v":"all doors are closed","vt":"str"}],"checkall":"false","outputs":2,"x":1500.8923797607422,"y":1021.0914630889893,"wires":[["88b51e18.10e8b"],["bc65b31b.69589","3f9c8f54.eb9ca"]]},{"id":"72dcc6b3.ed7548","type":"function","z":"788aa3af.5d48dc","name":"All the doors are open","func":"msg.topic = \"All the doors are open\";\nreturn msg;","outputs":1,"noerr":0,"x":2158.41650390625,"y":1011.7579345703125,"wires":[["bc65b31b.69589","3f9c8f54.eb9ca"]]},{"id":"88b51e18.10e8b","type":"switch","z":"788aa3af.5d48dc","name":"check topic for all doors open","property":"topic","propertyType":"msg","rules":[{"t":"neq","v":"the Office Door and Front Door and Side Gate and Kitchen Door and Garage Door is open","vt":"str"},{"t":"eq","v":"the Office Door and Front Door and Side Gate and Kitchen Door and Garage Door is open","vt":"str"}],"checkall":"false","outputs":2,"x":1898.4163818359375,"y":1006.7577514648438,"wires":[["bc085af1.c7f9b8"],["72dcc6b3.ed7548"]]},{"id":"d6ca6d73.41127","type":"chromecast-play","z":"788aa3af.5d48dc","name":"","url":"","contentType":"","ip":"","x":2813.4560546875,"y":1049.797607421875,"wires":[[]]},{"id":"bc65b31b.69589","type":"function","z":"788aa3af.5d48dc","name":"All Doors Status to Voice Google home","func":"msg.payload = {\n    ip: '192.168.1.174',\n    url: 'http://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&textlen=32&client=tw-ob&q='+msg.topic+'&tl=En-gb',\n    contentType: 'audio/mp3',\n};\nreturn msg;","outputs":1,"noerr":0,"x":2513.741874694824,"y":1041.369080543518,"wires":[["d6ca6d73.41127"]]},{"id":"3f9c8f54.eb9ca","type":"function","z":"788aa3af.5d48dc","name":"Update DOORS Variable with topic","func":"msg.url = \"http://127.0.0.1:8080/json.htm?type=command&param=updateuservariable&vname=DOORS&vtype=2&vvalue=\"+ msg.topic;\nreturn msg;","outputs":1,"noerr":0,"x":2470.884864807129,"y":942.6190567016602,"wires":[["21baefc7.f0126"]]},{"id":"21baefc7.f0126","type":"http request","z":"788aa3af.5d48dc","name":"Update Doors Var","method":"GET","ret":"txt","url":"","tls":"","x":2747.17041015625,"y":942.7619018554688,"wires":[[]]},{"id":"ea00b9cc.4ae4e8","type":"inject","z":"788aa3af.5d48dc","name":"Test","topic":"","payload":"Doors status","payloadType":"str","repeat":"","crontab":"","once":false,"x":122,"y":748,"wires":[["b5539f30.c3769"]]},{"id":"ba39d30b.27961","type":"comment","z":"788aa3af.5d48dc","name":"Doors status request from Dom Var","info":"","x":166,"y":684,"wires":[]}]
Regards.
Bradds

Wob76
Posts: 58
Joined: Wednesday 19 April 2017 6:31
Target OS: Linux
Domoticz version:
Contact:

Re: Google Home

Post by Wob76 » Wednesday 13 September 2017 23:23

Thanks, I'll check it out, how are you identifying your phone, is it just a different verbal command? I was thinking I would just ask "at home" somewhere in the ifttt command?

Sent from my SM-G935F using Tapatalk


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

Re: Google Home

Post by Bradds » Thursday 14 September 2017 0:16

I use a separate google and IFTTT account for phone, (set this all up before multi user accounts were available in UK) same IFTTT setup with commands sent to MOBILE STATUS for phone & HOME STATUS Variables for GH.
I split them out in a filter node and send the text to a PUSHOVER node for the phone. I then use tasker notifications to only read out the reply's from dom on the phone. I doesn't come through the assistant app, but the effect is the same. It has the benefit of only sending info to the device that the request was made from. I don't know of any way to do it on the same account as IFTTT doesn't differentiate between them. I originally had it setup on a skill "tell home" but I didn't like having to say "Hey Google, tell home ......." Its bad enough having to say "hey google" all the time, without putting in an extra phrase as well. I have also set it up on a Pi2 with GA SDK and use the Audio Output node, this way you don't get the chromecast connection "ding" before an answer. Not figured out a way to do it with alexa yet, other than using the skill route. I just use habridge for alexa commands to switch stuff on on off, dim lights etc.. I mainly just use Google home and google assistant on the phone... good combo.

bryan241
Posts: 8
Joined: Tuesday 29 December 2015 16:06
Target OS: -
Domoticz version:
Contact:

Re: Google Home

Post by bryan241 » Tuesday 03 October 2017 12:40

This IFTTT solution looks nice, but what I don't like is to open up unsecured connections to domoticz.

From what I understand is that you need to use unsecured http url's to connect to domoticz.

Is there a way to make the communication secure?

I'm currently using ha bridge locally, but it only supports ON/OFF/DIM commands (as stated before).
I would like to be able to send custom commands, but it must be secure.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests