Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Alexa, Google Home and Siri

Moderator: leecollings

pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by pvklink »

Hi I want to add an injector to my working script.
Only thing Google needs is an switch and true or false.. but it does not work..
Am i missing something?
I tried
true or false as a string, as a bolean etc.

Code: Select all

[{"id":"747e1438.04074c","type":"tab","label":"Google assistant","disabled":false,"info":""},{"id":"bc0205d0.81bbc8","type":"mqtt in","z":"747e1438.04074c","name":"uit domoticz naar GA","topic":"domoticz/out","qos":"0","datatype":"auto","broker":"a9c9d504.f88908","x":180,"y":80,"wires":[["8c7c1488.7446d8"]]},{"id":"8c7c1488.7446d8","type":"json","z":"747e1438.04074c","name":"","property":"payload","action":"","pretty":false,"x":190,"y":200,"wires":[["9537254a.fd20e8"]]},{"id":"9537254a.fd20e8","type":"function","z":"747e1438.04074c","name":"Function convert on off","func":"msg.topic = msg.payload.idx\nif (msg.payload.nvalue === 1)\n{\n    msg.payload = true\n}\nelse if (msg.payload.nvalue === 0)\n{\n    msg.payload = false\n}\n    return msg;","outputs":1,"noerr":0,"x":160,"y":380,"wires":[["1c99040c.87d98c"]]},{"id":"1c99040c.87d98c","type":"switch","z":"747e1438.04074c","name":"switch","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"112","vt":"str"},{"t":"eq","v":"92","vt":"str"},{"t":"eq","v":"42","vt":"str"},{"t":"eq","v":"151","vt":"str"},{"t":"eq","v":"66","vt":"str"},{"t":"eq","v":"1002","vt":"str"},{"t":"eq","v":"170","vt":"str"},{"t":"eq","v":"171","vt":"str"},{"t":"eq","v":"172","vt":"str"},{"t":"eq","v":"173","vt":"str"},{"t":"eq","v":"174","vt":"str"},{"t":"eq","v":"53","vt":"str"},{"t":"eq","v":"155","vt":"str"}],"checkall":"true","repair":false,"outputs":13,"x":390,"y":380,"wires":[[],[],[],[],[],["8679b420.292958"],[],[],[],[],[],[],[]]},{"id":"8679b420.292958","type":"nora-light","z":"747e1438.04074c","devicename":"lantaarn","lightcolor":false,"brightnesscontrol":false,"passthru":false,"statepayload":true,"brightnessoverride":"","roomhint":"Huiskamer","name":"lantaarn","nora":"3d11a1da.6954ae","topic":"lantaarn","onvalue":"true","onvalueType":"bool","offvalue":"false","offvalueType":"bool","x":620,"y":360,"wires":[["33db208f.8e908"]]},{"id":"a738327c.0a664","type":"function","z":"747e1438.04074c","name":"Function ON/OFF","func":"var idx = msg.topic\nif ( msg.payload === true )\n{\nmsg.payload = { \"command\": \"switchlight\", \"idx\": idx, \"switchcmd\": \"On\" };\n}\nelse if ( msg.payload === false )\n{\nmsg.payload = { \"command\": \"switchlight\", \"idx\": idx, \"switchcmd\": \"Off\" };\n}\nreturn msg\n","outputs":1,"noerr":0,"x":690,"y":160,"wires":[["8b743554.dfd338"]]},{"id":"8b743554.dfd338","type":"template","z":"747e1438.04074c","name":"Gen MQTT On/Off","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"command\": \"switchlight\", \"idx\": {{payload.idx}}, \"switchcmd\": \"{{payload.switchcmd}}\" }","output":"str","x":910,"y":160,"wires":[["cef071c5.a9d16"]]},{"id":"cef071c5.a9d16","type":"mqtt out","z":"747e1438.04074c","name":"uit GA naar domoticz","topic":"domoticz/in","qos":"","retain":"","broker":"a9c9d504.f88908","x":1080,"y":60,"wires":[]},{"id":"1926c93c.ff7e37","type":"inject","z":"747e1438.04074c","name":"collect current light status","topic":"","payload":"Started!","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"","x":410,"y":680,"wires":[["98ed3c34.69207"]]},{"id":"98ed3c34.69207","type":"http request","z":"747e1438.04074c","name":"MQTT-Broadcast-Domoticz","method":"POST","ret":"txt","paytoqs":false,"url":"http://192.168.20.35:82/json.htm?type=command&param=switchlight&idx=1002&switchcmd=On","tls":"","persist":false,"proxy":"","authType":"","x":720,"y":680,"wires":[["f64674ef.253bc8"]]},{"id":"f64674ef.253bc8","type":"debug","z":"747e1438.04074c","name":"","active":true,"tosidebar":true,"console":false,"complete":"false","x":970,"y":680,"wires":[]},{"id":"e7650896.cd30d8","type":"comment","z":"747e1438.04074c","name":"1a standaard json mqtt bericht","info":"v==","x":680,"y":120,"wires":[]},{"id":"ee2ca9e.30a3d58","type":"comment","z":"747e1438.04074c","name":"of 1b Uservariabele IFTTTvar","info":"","x":1100,"y":260,"wires":[]},{"id":"33db208f.8e908","type":"json","z":"747e1438.04074c","name":"","property":"payload","action":"","pretty":false,"x":910,"y":220,"wires":[["685384e0.e7cc1c"]]},{"id":"11a973b6.e8cacc","type":"json","z":"747e1438.04074c","name":"","property":"payload","action":"","pretty":false,"x":1270,"y":220,"wires":[["cef071c5.a9d16"]]},{"id":"685384e0.e7cc1c","type":"function","z":"747e1438.04074c","name":"maak bericht","func":"var msg_value = msg.payload;\nvar msg_id = msg.topic;\n\nif ( msg_value === \"true\" ) \n    {var waarde = \"On\"}\nelse if ( msg_value === \"false\" )\n    {var waarde = \"Off\"}\n\nvar uservar = '[{\"obj\": \"' + msg_id + '\",\"act\":\"' + waarde + '\"}]';\n\nmsg.payload = {\"value\": uservar};\nmsg.payload.command = \"setuservariable\";\nmsg.payload.idx = 13;\n\nreturn msg\n","outputs":1,"noerr":0,"x":1070,"y":220,"wires":[["11a973b6.e8cacc"]]},{"id":"53399957.8636c8","type":"comment","z":"747e1438.04074c","name":"Ik wil ook nog een injector met true or false en direct naar Google asiss dit werkt niet","info":"","x":330,"y":560,"wires":[]},{"id":"b8d48e9c.24bb1","type":"inject","z":"747e1438.04074c","name":"","topic":"1002","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":460,"wires":[["1c99040c.87d98c"]]},{"id":"28bfb576.d7829a","type":"inject","z":"747e1438.04074c","name":"","topic":"1002","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":520,"wires":[["1c99040c.87d98c"]]},{"id":"a9c9d504.f88908","type":"mqtt-broker","z":"","name":"mqttdomoticz","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"3d11a1da.6954ae","type":"nora-config","z":"","name":"nora config","group":"","notify":false}]
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Devious
Posts: 20
Joined: Sunday 30 December 2018 19:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Oss NL
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by Devious »

I use a Raspberry Pi 3B+ with Raspbian version 10 buster
User avatar
FireWizard
Posts: 1863
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by FireWizard »

@Devious.

Can you try the method as described under Mosquitto in the following link:
https://gist.github.com/xoseperez/e2333 ... 422760cb87
In the 4th line, replace mosquitto-stretch.list by mosquitto-buster.list

Let's see if this works.
Devious
Posts: 20
Joined: Sunday 30 December 2018 19:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Oss NL
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by Devious »

FireWizard wrote: Monday 09 December 2019 23:29 @Devious.

Can you try the method as described under Mosquitto in the following link:
https://gist.github.com/xoseperez/e2333 ... 422760cb87
In the 4th line, replace mosquitto-stretch.list by mosquitto-buster.list

Let's see if this works.
Yes, that did the trick!
Thank U
User avatar
FireWizard
Posts: 1863
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by FireWizard »

Hello @pvklink

You wrote:
Hi I want to add an injector to my working script.
Only thing Google needs is an switch and true or false.. but it does not work..
Am i missing something?
I'm not 100% sure, what you try to achieve, but the topic you send to the switch (1002) is probably a different topic then the topic for "lantaarn".

Also, there is an error in your "Function" node, called "maak bericht".

Change it as follows:

Code: Select all

var msg_value = msg.payload;
var msg_id = msg.topic;
var waarde

if ( msg_value === "true" ) 
    {waarde = "On"}
else if ( msg_value === "false" )
    {waarde = "Off"}

var uservar = '[{"obj": "' + msg_id + '","act":"' + waarde + '"}]';

msg.payload = {"value": uservar};
msg.payload.command = "setuservariable";
msg.payload.idx = 13;

return msg
But I'm not sure, if this is the "showstopper".

Regards
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by pvklink »

That flow now works. Only thing i cant get to work is to inject an on/off command directly in to a google node...
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
User avatar
FireWizard
Posts: 1863
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by FireWizard »

Hi,

I will try that tomorrow with one of my nodes and will let you know.

Regards
User avatar
FireWizard
Posts: 1863
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by FireWizard »

Hello@pvklink

I have tested to inject directly into Google Assistant.
I still do not understand what you try to achieve.

I succeeded in the following

Two "Inject" nodes, one for Switching "On" and 1 for Switching "Off".
The first one injected a boolean "true" as payload and the second injected a boolean "false" as payload.
Both had a topic set, which was the idx number of one of my switches. They were wired together to the input of the "Switch" node.

This functions:

1. Press the inject node "On" and the Google node indicates "on", but the switch in Domoticz is not activated. So the lamp stays Off.
2. Press the inject node "Off" and the Google node indicates "off", but the switch in Domoticz is not deactivated.

Tick the box indicated by: "If msg arrives on input, pass through to output: "

1. Press the inject node "On" and the Google node indicates "off", but the switch in Domoticz is activated. So the lamp goes On.
2. Press the inject node "Off" and the Google node indicates "off", but the switch in Domoticz is deactivated and the lamp goed Off

However to avoid a loop you have to insert a RBE node to block unchanged values.

So you can switch on/off by the inject node the Google Assistant status OR send On/Off commands to Domoticz, but not both.
Can you explain what the purpose is of those 2 "Inject" nodes?

Regards
manjh
Posts: 748
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by manjh »

I have a setup with 2 Google Home devices, Google Home Assistant, running through NORA and Node-Red, into Domoticz.
For testing purposes I have set up a second R-Pi with Domoticz and Node-Red.
I would like to link this to the same Google Assistant.
Questions:
1. does Google Assistant support two NORA entities?
2. can I use the same NORA token for the two?
Hans
User avatar
FireWizard
Posts: 1863
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by FireWizard »

Hi,

You wrote:
I have a setup with 2 Google Home devices, Google Home Assistant, running through NORA and Node-Red, into Domoticz.
For testing purposes I have set up a second R-Pi with Domoticz and Node-Red.
So that means you have two Node Red instances, one on each RPi.
I assume you have installed the nora node, also in the second RPI?
Questions:
1. does Google Assistant support two NORA entities?
I think so, but have not tested it. In order to get a token, you have to log in, with either your Google account or your Github account.
It doesn't matter, which one you use, as you will receive the same token.
The only option is to revoke the token. There is no option to generate a second, or third, etc, token.

I found the following at:
https://github.com/andrei-tatar/node-red-contrib-nora
The Group is used if you want to use multiple connections to the same NORA account (if you use multiple Node-RED instances).
I assume that you have to fill in the same "Group" in both nora config configurations.
Questions:
2. can I use the same NORA token for the two?
As said above, I cannot find any possibility to get another token.

I suggest, try it that way and post the results.

Another interesting thread you will find here: https://discourse.nodered.org/t/node-re ... n/4829/238

@pvklink

In this thread my findings are confirmed, but you will find also a solution.

Regards
Last edited by FireWizard on Thursday 12 December 2019 16:54, edited 1 time in total.
manjh
Posts: 748
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by manjh »

I requested a second token by using a different mail address.
Problem is adding the second Nora entity to Google Home Assistant. I already have Nora linked, and there seems to be no way to add another...
Hans
User avatar
FireWizard
Posts: 1863
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by FireWizard »

Hi

If you have a different Rpi on which another Node Red is running, you can fill in your new token.
Did you do that and you mean it will not connect?

I didn't see a solution of adding more than 1 Nora Entity in Google Home Assistant.

Did you also try to use the same token, as on your first RPi and setting the "Group" (Using the same name in both)?

Regards
Last edited by FireWizard on Thursday 12 December 2019 17:49, edited 1 time in total.
manjh
Posts: 748
Joined: Saturday 27 February 2016 12:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: NL
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by manjh »

FireWizard wrote: Thursday 12 December 2019 15:12
Another interesting thread you will find here: https://discourse.nodered.org/t/node-re ... n/4829/238

@pvklink

In this thread my findings are confirmed, but you will find also a solution.

Regards
Yes, by entering the token in the group field, Google Home now communicates with both Nora entities.
It works, but I am not sure about exactly why/
On the first Nora (production entity), I have a token in the token field only.
On the second (the test entity), I entered the token in both fields.
It works.
I will be playing around with it a little to see what happens...
Hans
User avatar
FireWizard
Posts: 1863
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by FireWizard »

Hi,

I understand, that you were not able to add a second Nora entity.

On your 1st. RPi (production) you created a token with your Google account, which is your email address, let's say [email protected]. On your phone or tablet, which will have the same account, [email protected], you installed the Google Home Assistent app and you connected Google Home with Nora. As soon you have done this, nora disappears from the (long) list.
But Nora and Google Home Assistent are connected.

Next step, you asked for a second token, for your test RPi. You got that and inserted that in the Nora config. Now we have to connect this. This token is registered under, let's say, [email protected]. Probably you have used your phone or tablet, with account [email protected].

If you use another device with account [email protected] or you change the account of your device, it should work.
But this is not what you want.

I had expected, that you should enter the token in the token field on both RPi's and a common "Group" name, e.g. "Home" in the "Group" field. And not a token in one of the "Group" fields.
I cannot find much about it, but we continue.

Regards
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by pvklink »

Already solved the problem by inject into mqtt instead of the google node


FireWizard wrote: Wednesday 11 December 2019 15:37 Hello@pvklink

I have tested to inject directly into Google Assistant.
I still do not understand what you try to achieve.

I succeeded in the following

Two "Inject" nodes, one for Switching "On" and 1 for Switching "Off".
The first one injected a boolean "true" as payload and the second injected a boolean "false" as payload.
Both had a topic set, which was the idx number of one of my switches. They were wired together to the input of the "Switch" node.

This functions:

1. Press the inject node "On" and the Google node indicates "on", but the switch in Domoticz is not activated. So the lamp stays Off.
2. Press the inject node "Off" and the Google node indicates "off", but the switch in Domoticz is not deactivated.

Tick the box indicated by: "If msg arrives on input, pass through to output: "

1. Press the inject node "On" and the Google node indicates "off", but the switch in Domoticz is activated. So the lamp goes On.
2. Press the inject node "Off" and the Google node indicates "off", but the switch in Domoticz is deactivated and the lamp goed Off

However to avoid a loop you have to insert a RBE node to block unchanged values.

So you can switch on/off by the inject node the Google Assistant status OR send On/Off commands to Domoticz, but not both.
Can you explain what the purpose is of those 2 "Inject" nodes?

Regards
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by pvklink »

when refreshing the app it did change, so problem solved!
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Gravityz
Posts: 587
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by Gravityz »

for people trying to inject commands into nora nodes

i am doing this for color lights like this
just give the variables in the function node the right value and of you go.
for switches you only need the first one and for dimmers the first and second one
msg.payload = {
"on": status,
"brightness": brightness,
"color": { "spectrumHsv" :
{ "hue": hue,
"saturation": saturation,
"value": 1 } } };
Devious
Posts: 20
Joined: Sunday 30 December 2018 19:02
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Oss NL
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by Devious »

I use Node-red to control the lights and that works well.

Is there a way to send text to Node-red?

I want to make the home mini's speak out the text sent from Domoticz.
The part Node-red -> Home mini is working.
The part Domoticz -> Node-red is missing.
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by pvklink »

i use node-red-contrib-cast to let my nest hub speaker talk
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Gravityz
Posts: 587
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: Domoticz Google Assistant integration with node-red Easy Free Controlicz alternative!

Post by Gravityz »

he means from domoticz to Node-red.

what i would do is make a generic text device, put text in there and let domoticz send a MQTT broadcast for that switch.
i would think the status gets send through MQTT which you can pick up in Node-RED
other option is you let domoticz send a telegram and pick that up in Node-Red
i use telegram to send status updates so that would be perfect for the job
pick the right node in node-red because i remember they are not all the same and simple to operate
i think i used this one node-red-contrib-telegrambot

lot's of options in the settings-notifications from domoticz.
pick something you know can be received in Node-Red
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest