Google home <-> Node-red <-> Domoticz (without 3rd party)
Posted: Thursday 10 June 2021 2:01
I was searching for a way to combine my Google Nest mini with Domoticz and didn't want a 3rd party site in between.
While searching i came across this solution, and within 1 day i had this working flawlessy, directly from Google home to Domoticz.
You can find the Node-red nodes page here, including a very good instruction how to set this up.
https://www.npmjs.com/package/node-red- ... -smarthome
The only thing you realy need is a (sub)domain name, that you can redirect to your home ip address. (point A-record to your home ip..)
A number ip address will not work, because google needs a secure connection, and you can only secure domain names, not numbered ip addresses.
I use a Raspberry Pi for Domoticz and Node-red, and have 1 port forwarded in my modem to this Pi.
The only problem i had was with securing my connection, but after many tries i had this secure connection established with my pi.
(losening the directory permissions where the keys are located was the solution, so Node-red had permission to find the secure keys)
So now when i give a command to my Google Nest, Google return a action to my Raspberry Pi, this goes to Node-Red, and Node-Red send a action to Domticz.

1. this switch node get the status for the Google home devices in Domticz.
2. this node convert the domoticz output to Google home input. Like this for a dimmer..
If a device status is changed in Domoticz, this will also be updated within Google home.
3. are the Google home nodes. When you create a node, a device is automatic added to your Google home app and can be controlled by his name.
4. is converting the Google home node output, to Domticz input. Like this for a dimmer..
For every controlled device in Domoticz, i have added a dummy device that get the output from Node-red. When this dummy device is called, it will check the status of the real device, and change this if needed. This works the most stable for controlling the devices with the Google home flow..
(Otherwise you have the risc for looping outputs and inputs in Node-red.)
5. is triggered one time when you have changed the nodes and deploy the flow again. This node will call a custom event in Domoticz.
The custom event update the devices with the same status that they allready have. The status is then send to Node-red (1) and the Google home nodes (3) will be updated with the actual status.
I hope the above information is usefull for others that are searching for a Google home and Domoticz combination and don't want to use a 3rd party site.
While searching i came across this solution, and within 1 day i had this working flawlessy, directly from Google home to Domoticz.
You can find the Node-red nodes page here, including a very good instruction how to set this up.
https://www.npmjs.com/package/node-red- ... -smarthome
The only thing you realy need is a (sub)domain name, that you can redirect to your home ip address. (point A-record to your home ip..)
A number ip address will not work, because google needs a secure connection, and you can only secure domain names, not numbered ip addresses.
I use a Raspberry Pi for Domoticz and Node-red, and have 1 port forwarded in my modem to this Pi.
The only problem i had was with securing my connection, but after many tries i had this secure connection established with my pi.
(losening the directory permissions where the keys are located was the solution, so Node-red had permission to find the secure keys)
So now when i give a command to my Google Nest, Google return a action to my Raspberry Pi, this goes to Node-Red, and Node-Red send a action to Domticz.

1. this switch node get the status for the Google home devices in Domticz.
2. this node convert the domoticz output to Google home input. Like this for a dimmer..
Code: Select all
var aan = msg.payload.nvalue;
var dim = msg.payload.Level;
if (aan === 1) {
msg.payload = {
on: true,
brightness: dim
}
return msg;
}
else if (aan === 0) {
msg.payload = {
on: false,
brightness: dim
}
return msg;
}
else if (aan === 2) {
msg.payload = {
on: true,
brightness: dim
}
return msg;
}
3. are the Google home nodes. When you create a node, a device is automatic added to your Google home app and can be controlled by his name.
4. is converting the Google home node output, to Domticz input. Like this for a dimmer..
Code: Select all
var aan = msg.payload.on;
var dim = msg.payload.brightness;
var idx = 126;
if (aan === true){
msg.payload = {"command": "switchlight", "idx": idx, "switchcmd": "Set Level", "level": dim};
} else {
msg.payload = {"command": "switchlight", "idx": idx, "switchcmd": "Off"};
}
return msg;
(Otherwise you have the risc for looping outputs and inputs in Node-red.)
Code: Select all
if (device.name == 'sh-Lamp bank') then
local lamp = domoticz.devices('Lamp bank')
if (lamp.state ~= device.state) then
if (device.state == 'On') then
lamp.switchOn()
else
lamp.switchOff()
end
end
if (lamp.level ~= device.level) then
lamp.setLevel(device.level)
end
end
Code: Select all
// init device statussen
msg.payload = {"command" : "customevent", "event" : "InitSmarthome" , "data" : "init devices Smarthome" };
return msg;
Code: Select all
sw = domoticz.devices('Lamp bank')
if (sw.state == 'On') then
sw.switchOn()
else
sw.switchOff()
end