Page 1 of 1

Moving Alexa support from HA-bridge to NodeRed (node-red-contrib-virtual-smart-home)

Posted: Thursday 10 February 2022 1:10
by burkhard
Hello

For more flexibility I try to move the Alexa support for my Domoticz
from HA-bridge (on RPi2) to NodeRed (on RPi3B+). On the new RPi3 is running:
Domoticz, Mosquitto as MQTT broker and NodeRed. All are runnig fine and work together.
I have exported and imported the Domoticz configuration from RPi2 to RPi3. So I have
an test environment on the RPi3 but!! without attached Zwave controller and RFXCom.
I see an different behavior:
if press on :8080/#/LightSwitches testlampe -> on I get: Error sending switch command, check device/hardware (idx=724) !
(correct because the RFXCom is not connected) but:
if I say "Alexa switch testlampe on" the bulb symbol :8080/#/LightSwitches changed to on (no hardware error hint).

In NodeRed I see from Domoticz:out :
{
"Battery" : 255,
"LastUpdate" : "2022-02-09 22:38:36",
"RSSI" : 12,
"description" : "",
"dtype" : "Light/Switch",
"hwid" : "4",
"id" : "00014324",
"idx" : 724,
"name" : "testlampe",
"nvalue" : 1,
"stype" : "Switch",
"svalue1" : "0",
"switchType" : "On/Off",
"unit" : 1
}

from Alexa I got:

powerState: "ON"
source: "alexa"
directive: "TurnOn"
name: "testlampe"
type: "SWITCH"
rawDirective: object

In a function node in NodeRed I translate name: "testlampe" to IDX and powerState: to "nvalue" and send the
payload via MQTT to Domoticz:in

switch (msg.payload.powerState)
{
case "ON":
msg.payload = {"idx":724,"nvalue":1,"svalue":"0"};
break;

case "OFF":
msg.payload = {"idx":724,"nvalue":0,"svalue":"0"};
break;
}
return msg;

As described above: only the bulb symbol changed, no real switch command initated.
My question is: which of the in Domoticz:out recorded values are necessary to send to Domoticz
to initiate a switchcommand and where I can found the values (for the other devices) in Domoticz?

Re: Moving Alexa support from HA-bridge to NodeRed (node-red-contrib-virtual-smart-home)

Posted: Thursday 10 February 2022 8:37
by waltervl

Re: Moving Alexa support from HA-bridge to NodeRed (node-red-contrib-virtual-smart-home)

Posted: Thursday 10 February 2022 9:30
by FireWizard
Hello @burkhard

Your Node-RED flow looks okay, except the command sent to Domoticz.

Add the "command":"switchcmd" to your JSON string.

The "command" defaults to "udevice". So if you omit the "command" then it defaults to "udevice" and it will update the Domoticz device.
This is exactly what happens.

So change:

msg.payload = {"idx":724,"nvalue":1,"svalue":"0"}; into
msg.payload = {"command":"switchcmd","idx":724,"nvalue":1,"svalue":"0"};

and also

msg.payload = {"idx":724,"nvalue":0,"svalue":"0"}; into
msg.payload = {"command":"switchcmd","idx":724,"nvalue":0,"svalue":"0"};

Regards

Re: Moving Alexa support from HA-bridge to NodeRed (node-red-contrib-virtual-smart-home)

Posted: Thursday 10 February 2022 16:54
by burkhard
Thanks to FireWizard and waltervl
This was to easy - I was blind ....

Regards Burkhard