# Node-RED google home integration

**URL:** <https://discourse.nodered.org/t/node-red-google-home-integration/4829>\
**Category:** Share Your Projects\
**Created:** [13 November 2018 09:25 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829 "2018-11-13T09:25:31Z")\
**Posts on this page:** 20\
**Page:** 10

<div class="post-metadata">

**Author:** ![andrei-tatar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei-tatar/32/3780_2.png) [@andrei-tatar](https://discourse.nodered.org/u/andrei-tatar)\
**Post date:** [11 February 2019 20:20 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/186 "2019-02-11T20:20:20Z")

</div>

Don't think it's related to language.  
Sure helps. And what does the `updates` object contain?

---

<div class="post-metadata">

**Author:** ![aerobert](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@aerobert](https://discourse.nodered.org/u/aerobert)\
**Post date:** [11 February 2019 20:35 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/187 "2019-02-11T20:35:03Z")

</div>

It contains `{ '3f7e8703.c86ea8': { online: true, on: true } }`  
Looks like the `devices.find` fails.  
I also tried `devices.find(function (d) { return d.id == id; });`, `devices.find(d => d.id == this.id)` with `this.` and without. Changing `===` to `==` did not work either.

---

<div class="post-metadata">

**Author:** ![andrei-tatar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei-tatar/32/3780_2.png) [@andrei-tatar](https://discourse.nodered.org/u/andrei-tatar)\
**Post date:** [11 February 2019 20:49 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/188 "2019-02-11T20:49:10Z")

</div>

What version of node.js are you using? Try using the latest LTS (version 10). What plugins are you using?  
Either the node.js you are using doesn't have the find method (I doubt it, it should be since v4), or some plugin overrides it in a very weird way.  
Open node and run `[{id:1},{id:2}].find(i => i.id === 2)`. It should ouput `{ id: 2 }`.

---

<div class="post-metadata">

**Author:** ![aerobert](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@aerobert](https://discourse.nodered.org/u/aerobert)\
**Post date:** [11 February 2019 20:49 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/189 "2019-02-11T20:49:59Z")

</div>

`var device = devices.filter(d => id === d.id)[0]` works... 🤔

---

<div class="post-metadata">

**Author:** ![aerobert](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@aerobert](https://discourse.nodered.org/u/aerobert)\
**Post date:** [11 February 2019 20:50 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/190 "2019-02-11T20:50:45Z")

</div>

> [@andrei-tatar](#):
>
> [{id:1},{id:2}].find(i =\> i.id === 2)

Yeah, this works!  
I have nothing installed but node-red as far as i know.

---

<div class="post-metadata">

**Author:** ![andrei-tatar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei-tatar/32/3780_2.png) [@andrei-tatar](https://discourse.nodered.org/u/andrei-tatar)\
**Post date:** [11 February 2019 20:51 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/191 "2019-02-11T20:51:12Z")

</div>

In that case... what other plugins do you have (other than node-red-contrib-nora)?

---

<div class="post-metadata">

**Author:** ![aerobert](https://avatars.discourse-cdn.com/v4/letter/a/7c8e57/32.png) [@aerobert](https://discourse.nodered.org/u/aerobert)\
**Post date:** [11 February 2019 20:53 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/192 "2019-02-11T20:53:46Z")

</div>

node-red-contrib-fritz  
node-red-contrib-fritzbox-presence  
node-red-contrib-ibm-watson-iot  
node-red-contrib-opcua  
node-red-node-pi-sense-hat

I try deactivating one by one

EDIT:  
I found the reason: `shelljs`  
Link in its the readme file: [https://www.npmjs.com/package/shelljs](https://www.npmjs.com/package/shelljs)  
It was located in the `node_modules` folder. I moved it somewhere else and now it works like a charm!  
Seems like this is automatically added to the node-red installation on the RPi.  
But i'm still not sure why it happend inside docker on my windows machine.  
How could somebody just overwrite neseccary standard functions...  
Thanks for your help! I will donate as soon as my new credit card arrives 😉  
Keep going your great work!  
Greetings Robert

---

<div class="post-metadata">

**Author:** ![andrei-tatar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei-tatar/32/3780_2.png) [@andrei-tatar](https://discourse.nodered.org/u/andrei-tatar)\
**Post date:** [11 February 2019 21:31 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/193 "2019-02-11T21:31:46Z")

</div>

You're welcome! 🙂

It is kinda weird... I'll look into it, but I don't think shelljs is the culprit. Maybe some other thing that depends on it and fails if it's missing...

---

<div class="post-metadata">

**Author:** ![andrei-tatar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei-tatar/32/3780_2.png) [@andrei-tatar](https://discourse.nodered.org/u/andrei-tatar)\
**Post date:** [27 February 2019 13:47 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/194 "2019-02-27T13:47:17Z")

</div>

And we reached at some point 100 online users 🥳

Some stats:  
335 registered users  
5662 monthly conversations (1 error - probably during a deploy)  
633 devices (3 offline): 289 lights, 176 switches, 70 scenes, 47 outlets, 39 thermostats, 8 blinds, 4 speakers

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d002d52fed8831009954bee6449e1871ca209bf5.png)

Btw, now and then I see some errors during the sync/update. For example when you try to send the ambient humidity for the thermostat with a value greater than 100%. Keep in mind that sync/update objects that don't respect the schema are rejected all together.

---

<div class="post-metadata">

**Author:** ![LondisDunleer](https://avatars.discourse-cdn.com/v4/letter/l/90ced4/32.png) [@LondisDunleer](https://discourse.nodered.org/u/LondisDunleer)\
**Post date:** [27 February 2019 18:57 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/195 "2019-02-27T18:57:47Z")

</div>

Hi All!

I just started using this today and I'm a bit stuck.

I've a temperature (parsed number from a sonoff) I want to pass into the thermostat Node.

Is there a guide on this apart from the one pager setup on the git?

---

<div class="post-metadata">

**Author:** ![JamieBrickston](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@JamieBrickston](https://discourse.nodered.org/u/JamieBrickston)\
**Post date:** [27 February 2019 20:54 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/196 "2019-02-27T20:54:22Z")

</div>

Hi All,

I'm trying this for the first time today and I noticed that although Google Home will think it turned off a light, sometimes this fails to go through (however the light still shows as off in google home). When this happens, I can see the following error in Node Red:

"nora (GrXDY): disconnected (io client disconnect)"

Does anyone know what's causing this? Is the server just having issues?

As a secondary question, is it a bug that google home will show the light as being turned off, when the request never reached node red?

Thanks for any help!

---

<div class="post-metadata">

**Author:** ![andrei-tatar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei-tatar/32/3780_2.png) [@andrei-tatar](https://discourse.nodered.org/u/andrei-tatar)\
**Post date:** [28 February 2019 07:26 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/197 "2019-02-28T07:26:02Z")

</div>

> [@LondisDunleer](#):
>
> I've a temperature (parsed number from a sonoff) I want to pass into the thermostat Node.

You just need to send a payload (to the thermostat node) that contains a `temperature` property as a number.  
`[{"id":"a05c5394.b829a","type":"inject","z":"5ae7227d.929fac","name":"","topic":"","payload":"{\"temperature\":25}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":160,"wires":[["94a56f8d.a8a4"]]},{"id":"94a56f8d.a8a4","type":"nora-thermostat","z":"5ae7227d.929fac","devicename":"Thermostat","roomhint":"","name":"","modes":"off,heat,on","unit":"C","topic":"","passthru":false,"nora":"7253437d.6deb9c","x":410,"y":160,"wires":[[]]},{"id":"7253437d.6deb9c","type":"nora-config","z":"","name":"nora config","group":"home"}]`

> [@JamieBrickston](#):
>
> I'm trying this for the first time today and I noticed that although Google Home will think it turned off a light, sometimes this fails to go through (however the light still shows as off in google home). When this happens, I can see the following error in Node Red:
> 
> "nora (GrXDY): disconnected (io client disconnect)"

Are you sure the disconnected event is at the exact same time you turned off the light? Does your node-red instance restart? The disconnect happens once a day when the heroku dyno is restarted. I can't stop that happening but node-red should reconnect in a few seconds... If you happen to issue a command in those seconds a day, google home will tell you your device is not available (see below).  
Also the light node in node-red shows the state in the status of the node. Can you check if that's in sync?  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/3/3591987f4218d95a3ce22ba77e02650d059dd4e3.png)

> [@JamieBrickston](#):
>
> As a secondary question, is it a bug that google home will show the light as being turned off, when the request never reached node red?

The way it works is that if node-red is not connected to NORA, google will say the light is not available. Also in google home, the device will show as unavailable. Soon as node-red connects again to NORA, the state is synced from node-red to NORA to Google Home (so make sure your node is kept in sync with the actual device state and google will be in sync too).  
It's very unlikely that google home said something happened and the message never reached node-red. But there is a small timeout (I think 5 seconds) until NORA detects that you're instance of node-red is not connected anymore - if the connection isn't closed properly. That's because of how the internet works.

You can start with a very simple flow (inject -\> light -\> debug) and see if that works. If this works, it might be something else in your flow. Something like this:  
`[{"id":"ca96c565.ff7748","type":"inject","z":"88c7a7ea.ec29c8","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":120,"wires":[["39a01118.9df90e"]]},{"id":"7d5a0282.f61a6c","type":"inject","z":"88c7a7ea.ec29c8","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":160,"wires":[["39a01118.9df90e"]]},{"id":"39a01118.9df90e","type":"nora-switch","z":"88c7a7ea.ec29c8","devicename":"Switch","roomhint":"","name":"","passthru":false,"nora":"7253437d.6deb9c","topic":"","onvalue":"true","onvalueType":"bool","offvalue":"false","offvalueType":"bool","x":300,"y":140,"wires":[["c550c657.33a9e8"]]},{"id":"c550c657.33a9e8","type":"debug","z":"88c7a7ea.ec29c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":470,"y":140,"wires":[]},{"id":"7253437d.6deb9c","type":"nora-config","z":"","name":"nora config","group":"home"}]`

---

<div class="post-metadata">

**Author:** ![JamieBrickston](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@JamieBrickston](https://discourse.nodered.org/u/JamieBrickston)\
**Post date:** [28 February 2019 22:59 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/198 "2019-02-28T22:59:26Z")

</div>

> Are you sure the disconnected event is at the exact same time you turned off the light?

It's hard to give a definite yes, but I watched the logs and sat turning the light on/off until it failed and I would see that message around the same time.

> The disconnect happens once a day when the heroku dyno is restarted.

I haven't had time to look at it today, but basically I was getting disconnects every few minutes (I don't know if there's a debug log in node red somewhere that would still have this recorded?). This doesn't seem to be happening this evening.

> Does your node-red instance restart?

No.

> If you happen to issue a command in those seconds a day, google home will tell you your device is not available (see below).

This is what I would expect.

> Also the light node in node-red shows the state in the status of the node. Can you check if that's in sync?

No, it would go out of sync. So for example google would say that it just turned off the light, however the light would still be on physically and in node red.

EDIT: However, if I waited a few seconds and refreshed the light on the google home app, it would show the correct state of the light.

> It's very unlikely that google home said something happened and the message never reached node-red. But there is a small timeout (I think 5 seconds) until NORA detects that you're instance of node-red is not connected anymore - if the connection isn't closed properly. That's because of how the internet works.

So Nora does respond to googles server before it gets back anything back my from Node red, correct?

I'm battling with a head cold at the minute so I'm a bit fuzzy, sorry if I wasn't clear here or missed anything important.

Thanks for your work on this btw, apart from this issue yesterday, Nora's fantastic!

J

---

<div class="post-metadata">

**Author:** ![andrei-tatar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei-tatar/32/3780_2.png) [@andrei-tatar](https://discourse.nodered.org/u/andrei-tatar)\
**Post date:** [1 March 2019 08:05 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/199 "2019-03-01T08:05:07Z")

</div>

> [@JamieBrickston](#):
>
> EDIT: However, if I waited a few seconds and refreshed the light on the google home app, it would show the correct state of the light.

Also Google Home widgets don't update realtime. I noticed if you open a light (or other widget) and send a change from node-red or from another google home, it won't update.

> [@JamieBrickston](#):
>
> So Nora does respond to googles server before it gets back anything back my from Node red, correct?

Yes, it does. A command from Google updates the internal state immediately and after that it's sent to node-red and back to google home, but that only if there is an active connection to node-red. I did think about making it so that commands go to node-red first, not sure why I left it this way... Maybe in a future version.

> [@JamieBrickston](#):
>
> Thanks for your work on this btw, apart from this issue yesterday, Nora's fantastic!

Glad to hear 🙂

---

<div class="post-metadata">

**Author:** ![JamieBrickston](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@JamieBrickston](https://discourse.nodered.org/u/JamieBrickston)\
**Post date:** [5 March 2019 00:00 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/200 "2019-03-05T00:00:38Z")

</div>

Ah ok, so whatever was happening with my install causing constant disconnects was the culprit. That seems to have resolved itself and everything is running smoothly now 🙂

I noticed the "speaker" node. Is there any chance this might be able to broadcast messages in the future? I have the home phone hooked into node-red now, so I could get google home to say the callers name out loud 😆

---

<div class="post-metadata">

**Author:** ![andrei-tatar](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei-tatar/32/3780_2.png) [@andrei-tatar](https://discourse.nodered.org/u/andrei-tatar)\
**Post date:** [5 March 2019 08:06 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/201 "2019-03-05T08:06:16Z")

</div>

> [@JamieBrickston](#):
>
> I noticed the "speaker" node. Is there any chance this might be able to broadcast messages in the future? I have the home phone hooked into node-red now, so I could get google home to say the callers name out loud 😆

Nope, it's something entirely different. However, there already is this available:

> **[node-red-contrib-google-home-notify](https://www.npmjs.com/package/node-red-contrib-google-home-notify)**
>
> Node-Red nodes for google-home-notify library. With this node you can cast any String (up to 200 chars) to any google cast device.. Latest version: 0.0.7, last published: 5 years ago. Start using node-red-contrib-google-home-notify in your project by...

or this:

> **[node-red-contrib-google-home-notify-volume-adjustable](https://www.npmjs.com/package/node-red-contrib-google-home-notify-volume-adjustable)**
>
> Node-Red nodes for google-home-notify library. With this node you can cast any String (up to 200 chars) to any google cast device.. Latest version: 0.0.11, last published: 3 years ago. Start using node-red-contrib-google-home-notify-volume-adjustable...

---

<div class="post-metadata">

**Author:** ![JamieBrickston](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@JamieBrickston](https://discourse.nodered.org/u/JamieBrickston)\
**Post date:** [18 March 2019 23:10 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/202 "2019-03-18T23:10:16Z")

</div>

Thanks for that! I have the google home calling out who's calling the landline now 😛

Here's one for you. I created a control to control my heating. The heating works over SMS, so I have no feedback to go into the google control.

If I turn it off, then it sends an off SMS to the controller, if I turn it on it sends an on SMS. Now, the issue is that if the control is off, and I tell google home to turn the heating off, it does nothing as the control is already off. However someone may have turned on the heating outside of the node red switch and I want it to send the SMS.

Have you any suggestions on making the switch always work? So if the control is off and it gets an off command it still runs?

---

<div class="post-metadata">

**Author:** ![binary](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@binary](https://discourse.nodered.org/u/binary)\
**Post date:** [19 March 2019 13:35 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/203 "2019-03-19T13:35:16Z")

</div>

This is an interesting topic (MQTT pun!), but it has already been done...

See [gbridge.io](http://gbridge.io)

Hosted:  
4 devices for free  
Unlimited devices for a monthly donation

There is a free docker image available to set up your own server; you just need to connect it with your own Google developer account.

I am currently testing using the free account, and have found it to be 100% reliable during two weeks testing.

My next step is to try the docker configuration.

[gbridge.io](http://gbridge.io) uses MQTT for control; very easy to configure using node red on Raspberry Pi.

Perhaps you could review the above project; are you proposing a different solution?

---

<div class="post-metadata">

**Author:** ![realjax](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/realjax/32/895_2.png) [@realjax](https://discourse.nodered.org/u/realjax)\
**Post date:** [20 March 2019 11:17 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/204 "2019-03-20T11:17:45Z")

</div>

Seems to me it is the other way around 😄[gbridge.io](http://gbridge.io) is interesting, but it has already been done before by Andrei.

However, the documentation provided by [gbridge.io](http://gbridge.io) is excellent!!

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [20 March 2019 18:50 UTC](https://discourse.nodered.org/t/node-red-google-home-integration/4829/205 "2019-03-20T18:50:58Z")

</div>

Does it really matter who did what first?  
They are both great contributions, and both work equally well.  
I appreciate the efforts of both developers, and both deserve a big thanks.

[Previous page](https://discourse.nodered.org/t/node-red-google-home-integration/4829.md?page=9)

[Next page](https://discourse.nodered.org/t/node-red-google-home-integration/4829.md?page=11)
