How to control rfx com device with node red using HA

Hello
I am completely new to HA and node red.
I have started to read quite a few node red script and managed (I think) to get the script I wanted:

Open the windows after the alarm clocks goes and if the sun already rose.
My issue is how to ask HA to open the windows knowing that they are a SOMFY device controled by rfxcom.
which node should be used? and how. The only solution I may have found with “call service” node is asking me to “Sends a raw event on radio” . I haven’t foud the code to send and I think its a rolling code which means I won’t find it. I am not using the node red pakage for rfx because
-I first want to learn the HA / red node logic
-I suppose that If use red node functions independently of HA the rolling code may find itself out of sync at a certain point… unless I add node red as a new remote but my device may note support to many remote.
So I would prefer to stick with HA thru red node.
HA as buttons to move the windows and it works great so I suppose I should find a way to trigger the same event as these buttons.
thru YAML ?
thanks for your advice

I don’t have an answer but you should know there are additional specialized nodes you can add. On the right top menu choose manage palette → install tab, then search for the node you want to install. I just searched google for “nodered somfy”

Nope, because that supposes that HA and NodeRed can both be connected and using the USB device at the same time, which is not possible.

As for How - this in my RFX In flow:

[{"id":"c033a41c.8a82c8","type":"rfx-lights-in","z":"14d24653.cce13a","name":"RFX Lights","port":"32c78c31.961204","topicSource":"all","topic":"","x":100,"y":60,"wires":[["472ea41a.8a277c"]]},{"id":"5904b83b.af5e18","type":"rfx-doorbell-in","z":"14d24653.cce13a","name":"RFX Doorbell","port":"32c78c31.961204","topicSource":"all","topic":"","x":110,"y":120,"wires":[["472ea41a.8a277c","4e9846d5.9e7b68"]]},{"id":"374d3427.be949c","type":"rfx-meter","z":"14d24653.cce13a","name":"RFX Meter","port":"32c78c31.961204","topicSource":"all","topic":"","x":100,"y":200,"wires":[["472ea41a.8a277c"]]},{"id":"edc661f3.48312","type":"rfx-sensor","z":"14d24653.cce13a","name":"RFX Sensor","port":"32c78c31.961204","topicSource":"all","topic":"","x":110,"y":280,"wires":[["472ea41a.8a277c"]]},{"id":"f2bf95f1.f21088","type":"rfx-detector-in","z":"14d24653.cce13a","name":"RFX Alarm","port":"32c78c31.961204","topicSource":"all","topic":"","outputHeartbeats":false,"x":100,"y":360,"wires":[["472ea41a.8a277c"]]},{"id":"16bcbc7c.2e0414","type":"rfx-PT2262-in","z":"14d24653.cce13a","name":"PT2262 Devices","port":"32c78c31.961204","deviceList":"4774fc7c.21e7e4","topicSource":"all","topic":"","x":180,"y":440,"wires":[["472ea41a.8a277c","86459039.cc30f"]]},{"id":"472ea41a.8a277c","type":"function","z":"14d24653.cce13a","name":"","func":"var topic = \"dhjm/rfxgateway/\" + msg.topic;\nmsg.new_topic = topic;\nvar out = {};\n//out.data = msg.payload;\n//msg.payload = out;\nmsg.topic = topic;\nif (typeof msg.raw !== 'undefined') {\n    out.data = msg.payload;\n    out.raw = msg.raw;\n    msg.payload = out;\n}\nreturn msg;","outputs":1,"noerr":0,"x":380,"y":80,"wires":[["4e9846d5.9e7b68","111625d3.9a936a","3ca4d25e.29941e"]]},{"id":"111625d3.9a936a","type":"mqtt out","z":"14d24653.cce13a","name":"","topic":"","qos":"","retain":"true","broker":"e2d4663.ba31a98","x":640,"y":160,"wires":[]},{"id":"32c78c31.961204","type":"rfxtrx-port","z":"","port":"/dev/ttyUSB0","enableDebug":false,"rfyVenetianMode":"EU"},{"id":"4774fc7c.21e7e4","type":"PT2262-device-list","z":"","name":"Found Devices","devices":[]},{"id":"e2d4663.ba31a98","type":"mqtt-broker","z":"","broker":"192.168.2.9","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""}]

This is my RFX Out flow

[{"id":"c548bdf4.b0a78","type":"mqtt in","z":"caf0c94d.3b5e68","name":"","topic":"dhjm/rfxgateway/command","qos":"2","datatype":"json","broker":"e2d4663.ba31a98","x":150,"y":40,"wires":[["d35d04ca.cc7b68"]]},{"id":"d35d04ca.cc7b68","type":"switch","z":"caf0c94d.3b5e68","name":"","property":"payload.device","propertyType":"msg","rules":[{"t":"nempty"}],"checkall":"true","repair":false,"outputs":1,"x":350,"y":40,"wires":[["90b2d12d.64a24"]]},{"id":"90b2d12d.64a24","type":"function","z":"caf0c94d.3b5e68","name":"","func":"if (typeof msg.payload.address == 'undefined') {\n    return null;\n}\nif (typeof msg.payload.data == 'undefined') {\n    return null;\n}\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":40,"wires":[["227e7717.9ec9c8"]]},{"id":"227e7717.9ec9c8","type":"switch","z":"caf0c94d.3b5e68","name":"","property":"payload.device","propertyType":"msg","rules":[{"t":"eq","v":"light","vt":"str"},{"t":"eq","v":"doorbell","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":280,"y":120,"wires":[["2fde47bb.cdf9d8"],["a40d56bb.1ad6e8"]]},{"id":"2fde47bb.cdf9d8","type":"function","z":"caf0c94d.3b5e68","name":"","func":"msg.topic = msg.payload.address;\nvar o = msg.payload;\nmsg.payload = {};\nmsg.payload = o.data;\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":120,"wires":[["ff47f4be.821368","4e165f83.159e2","fadbdb64.5f4648"]]},{"id":"ff47f4be.821368","type":"rfx-lights-out","z":"caf0c94d.3b5e68","name":"AC/ARC Control","port":"32c78c31.961204","topicSource":"msg","retransmit":"once","retransmitInterval":"10","topic":"","x":640,"y":120,"wires":[]},{"id":"f340fd6c.a6998","type":"rfx-doorbell-out","z":"caf0c94d.3b5e68","name":"Doorbell Control","port":"32c78c31.961204","topicSource":"msg","topic":"","x":630,"y":180,"wires":[]},{"id":"a40d56bb.1ad6e8","type":"function","z":"caf0c94d.3b5e68","name":"","func":"msg.topic = msg.payload.address;\nvar o = msg.payload;\nmsg.payload = {};\nmsg.payload = o.data;\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":160,"wires":[["f340fd6c.a6998","4e165f83.159e2"]]},{"id":"fadbdb64.5f4648","type":"function","z":"caf0c94d.3b5e68","name":"","func":"var t = msg.topic;\nmsg.topic = \"dhjm/rfxgateway/\" + t;\nreturn msg;","outputs":1,"noerr":0,"x":280,"y":260,"wires":[["32ac634f.f5816c"]]},{"id":"32ac634f.f5816c","type":"mqtt out","z":"caf0c94d.3b5e68","name":"","topic":"","qos":"","retain":"true","broker":"e2d4663.ba31a98","x":300,"y":320,"wires":[]},{"id":"e2d4663.ba31a98","type":"mqtt-broker","z":"","broker":"192.168.2.9","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"32c78c31.961204","type":"rfxtrx-port","z":"","port":"/dev/ttyUSB0","enableDebug":false,"rfyVenetianMode":"EU"}]

Here is a binary motion sensor picked up by RFX:

  - platform: mqtt
    name: "Greenroom Motion"
    state_topic: "dhjm/rfxgateway/AC/0x00018D7C/2"
    device_class: motion
    payload_on: "On"
    payload_off: "Off"
    off_delay: 30

Here is the binary sensor for the doorbell:

#Doorbells
  - platform: mqtt
    name: "Front Door Doorbell"
    state_topic: "dhjm/rfxgateway/BYRON_SX/0xBF"
    payload_on: 1
    off_delay: 10

Here is an example of how to do a switch:

  - platform: mqtt
    command_topic: dhjm/rfxgateway/command
    name: "Garden Audio"
    optimistic: true
    payload_off: >
      {"device":"light","address":"AC/0x00030CE/4","data":"Off"}
    payload_on: >
      {"device":"light","address":"AC/0x00030CE/4","data":"On"}
    state_off: "Off"
    state_on: "On"
    state_topic: dhjm/rfxgateway/AC/0x00030CE/4

Thank you
Yes I found those, but as said I wanted to go through HA rather than node red contrib module because I awas afraid that 2 different command may lead to a de-synchronsation of the rolling codes.
I was wrong indeed the codes are managed by rfxcom box so I could use node red contrib.
→ I tried to install the rfxcom contrib but it does not work, there is an error at the installation step .
SO will check what andrew jones is proposing.

Thank you. Yes you are right about the rolling, what lead my wrong is the “Sends a raw event on radio” parameter. but since the rolling codes are managed by the rfxcom box This shouldn’t happen.
I will try to follow your advices.

Instead of installing the rfx contrib inside node-red using the palette manager, you should instead add it to the config of the addon.

Change:

npm_packages: []

to

npm_packages:
  - node-red-contrib-rfxcom

That will ensure it (and all it’s dependencies) is installed every time the addon is updated.

Thank you
It worked immediately this time.

1 Like

to complete examples given by Andrew here what I found on other forums for covers

cover:
  - platform: mqtt
    name: "volet du Salon"
    command_topic: "VoletSalon"
    qos: 0
    retain: true
    payload_open: "u"
    payload_close: "d"
    payload_stop: "s"
    optimistic: false

https://forum.hacf.fr/t/volet-somfy-rts/2097/29

haven’t applied it yet so I can’t tell what would need to be adapted, but it could help anyone having same question as me.

Red node contrib beeing installed I tried it first and ran into one big issue:

It cannot work at the same time as HA.
So either Home assistant controls the covers or Node red integration, but not both.

So when it works controling a somfy curtain is done by using the following type of code

RFY/080043/02

where 080043 is the ID as reported in HA documention for RFXCOM integration and 02 is the Unit code

I saw, if I am not wrong that you used nodes from node-red-contrib-rfxcom in your flow.
Is there something to do to have both HA and red node see the rfxcom device. It seems that there is a conflict between both of them to use the same usb port at the same time.

You cannot have multiple things accessing the same USB device at the same time. That is why I publish the stuff received in NodeRed from the RFXComm to MQTT, and set up (manually) MQTT switches and sensors inside HomeAssistant.

NodeRed has full control of the device, and HomeAssistant can control switches and receive data using MQTT.

To summarize

  • We can use node red with the node-red-contrib-rfxcom palette.
    But in this case it is not possible to control the covers from rfxcom integration in HA. And that’s why we should use mqtt to control the covers from HA.
    This require to manually set up the cover controls in HA

  • Another option that I just found out is to use the

call service node
2021-12-17 20_44_56-Node-RED - Home Assistant

and set it up as follow using the covers entities created by the rfxcom integration

I missed this option because there is a Domain called RFXtrx which mislead me.

So far This option also works quite well and allows to control the covers from both red node and HA

1 Like

Ok Thank’s for the help

Hi, old topic but maybe anyone could help me.
I try to control my RFTtrx from Node-RED.
I have got the rfx-nodes connected and working in Node-RED but how do I know/find out how to control a certain 433MHz wall plug?

Hi - I’m the author of the node-red-contrib-rfxcom node you use to control the RFXtrx using Node-RED. If you have the remote control for the wall plug, you should create a flow with an rfx-lights-in node set to ‘listen for commands sent to any address’ wired to a debug node. Press the remote control and you should see a message displayed in the debug pane. The message Topic is the address you need to access the socket, and the message Payload is the command - for example ‘AC/0x0012564f/2’ ‘On’.

If you don’t have the remote, then it’s more complicated and will depend on the model of wall plug.