maxwellhadley / node-red-contrib-rfxcom

node-RED nodes to access an RFXtrx433 transceiver
BSD 2-Clause "Simplified" License
22 stars 13 forks source link

RFXCOM: payload works not fine anymore #115

Closed UweNB closed 2 years ago

UweNB commented 3 years ago

Hello Maxwell

A question about RFXCOM. I had to reinstall my Raspi and then also updated "node-red-contrib-rfxcom".

Now when I use the flow below, I used to get payload - in that case the hexcode of a 433Mhz-button. Now only "msg.payload : undefined undefined" The Flow: [{"id":"3a1a8ad3.503b36","type":"debug","z":"ef1a4eb9.47191","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":840,"y":300,"wires":[]},{"id":"b2bf8c6a.0e459","type":"rfx-PT2262-in","z":"ef1a4eb9.47191","name":"","port":"2199cf8d.d5c68","deviceList":"60e7b171.09773","topicSource":"all","topic":"","x":490,"y":300,"wires":[["3a1a8ad3.503b36"]]},{"id":"2199cf8d.d5c68","type":"rfxtrx-port","port":"/dev/ttyUSB0","enableDebug":false,"rfyVenetianMode":"EU"},{"id":"60e7b171.09773","type":"PT2262-device-list","name":"Blacky","devices":[]}]

what am I doing wrong? Maybe I already did something wrong during the installation.

Thanks a lot

UweNB commented 2 years ago

Hello Max,

can you help me? The goal is, if I press exactly this 433Mhz button, a light will be switched on. But no matter what I do: each button with its hex code triggers the flow.

What am I doing wrong?

Thanks!

maxwellhadley commented 2 years ago

Sorry I missed this - life has been chaotic for months!

Somehow or other, the PT2262 device list node 'Blacky' is empty. It should have a list of entries matching the binary data to your choice of topic & payload. If it cant find a match, msg.topic and msg.payload will both be 'undefined', and the binary value can be found in msg.raw.data.

I think this is your problem.

Sorry again about the response time for this!!

UweNB commented 2 years ago

Hi Maxwell,

yes, my mistake, had imported it and apparently there was an error to version 2.XX - or I did something wrong. But now the correct playload "on" is transferred by "Blacky"! Thanks for the hint!

But now I still can't get any further. I have a flow with which I can switch a socket on and off. But I can't manage to use the playload from the "Blacky" button in such a way that the socket switches on when I press "Blacky" and switches off again after a certain amount of time.

Do you have any ideas, Maxwell? I'm really at the end of my knowledge :(

Thank you, Florian

[ { "id": "ce25cf38.62ac2", "type": "rfx-PT2262-out", "z": "2a3c7e27b459e280", "name": "", "port": "11cc440c.fcc32c", "deviceList": "76f8758d.aa710c", "topicSource": "msg", "retransmit": "none", "retransmitInterval": 20, "topic": "", "x": 690, "y": 280, "wires": [] }, { "id": "8d49d8a8.22dc78", "type": "inject", "z": "2a3c7e27b459e280", "name": "", "repeat": "", "crontab": "", "once": false, "topic": "TEST/SOCKET/1", "payload": "On", "payloadType": "str", "x": 437, "y": 239, "wires": [ [ "ce25cf38.62ac2" ] ] }, { "id": "62a26abf.17fcd4", "type": "inject", "z": "2a3c7e27b459e280", "name": "", "repeat": "", "crontab": "", "once": false, "topic": "TEST/SOCKET/1", "payload": "Off", "payloadType": "str", "x": 437, "y": 319, "wires": [ [ "ce25cf38.62ac2" ] ] }, { "id": "e407cb7a0c164463", "type": "debug", "z": "2a3c7e27b459e280", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 610, "y": 420, "wires": [] }, { "id": "ab34b5e4825ad361", "type": "rfx-PT2262-in", "z": "2a3c7e27b459e280", "name": "TestBlacky", "port": "2199cf8d.d5c68", "deviceList": "60e7b171.09773", "topicSource": "all", "topic": "", "x": 400, "y": 420, "wires": [ [ "e407cb7a0c164463" ] ] }, { "id": "11cc440c.fcc32c", "type": "rfxtrx-port", "port": "/dev/ttyUSB0" }, { "id": "76f8758d.aa710c", "type": "PT2262-device-list", "name": "Test Devices", "devices": [ { "device": [ "TEST", "SOCKET", "1" ], "payload": "Off", "rawData": "0x145454", "pulseWidth": 325 }, { "device": [ "TEST", "SOCKET", "1" ], "payload": "On", "rawData": "0x145451", "pulseWidth": 325 } ] }, { "id": "2199cf8d.d5c68", "type": "rfxtrx-port", "port": "/dev/ttyUSB0", "enableDebug": false, "rfyVenetianMode": "EU" }, { "id": "60e7b171.09773", "type": "PT2262-device-list", "name": "Blacky", "devices": [ { "device": [ "PT2262" ], "payload": "on", "rawData": "0xcb5ba1", "pulseWidth": 350 } ] } ]

maxwellhadley commented 2 years ago

Florian - if I understand you correctly, you want an incoming PT2262-in message from 'Blacky' to send first an On and then 3 seconds later an Off, to the PT2262-out using 'Test Devices'. I think this does what you want:

[ { "id": "ce25cf38.62ac2", "type": "rfx-PT2262-out", "z": "c504c42c.c48a28", "name": "", "port": "38cca044.fc7bd", "deviceList": "76f8758d.aa710c", "topicSource": "msg", "retransmit": "none", "retransmitInterval": 20, "topic": "", "x": 458.8958740234375, "y": 213.99999618530273, "wires": [] }, { "id": "8d49d8a8.22dc78", "type": "inject", "z": "c504c42c.c48a28", "name": "", "repeat": "", "crontab": "", "once": false, "topic": "TEST/SOCKET/1", "payload": "On", "payloadType": "str", "x": 205.8958740234375, "y": 172.99999618530273, "wires": [ [ "ce25cf38.62ac2" ] ] }, { "id": "62a26abf.17fcd4", "type": "inject", "z": "c504c42c.c48a28", "name": "", "repeat": "", "crontab": "", "once": false, "topic": "TEST/SOCKET/1", "payload": "Off", "payloadType": "str", "x": 205.8958740234375, "y": 252.99999618530273, "wires": [ [ "ce25cf38.62ac2" ] ] }, { "id": "e407cb7a0c164463", "type": "debug", "z": "c504c42c.c48a28", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "true", "targetType": "full", "statusVal": "", "statusType": "auto", "x": 653.8958702087402, "y": 472.0000400543213, "wires": [] }, { "id": "ab34b5e4825ad361", "type": "rfx-PT2262-in", "z": "c504c42c.c48a28", "name": "TestBlacky", "port": "38cca044.fc7bd", "deviceList": "60e7b171.09773", "topicSource": "all", "topic": "", "x": 94.89587783813477, "y": 315.0000219345093, "wires": [ [ "2f2e7b25.3d7494" ] ] }, { "id": "20a20449.6f330c", "type": "trigger", "z": "c504c42c.c48a28", "name": "", "op1": "On", "op2": "Off", "op1type": "str", "op2type": "str", "duration": "3", "extend": false, "overrideDelay": false, "units": "s", "reset": "", "bytopic": "all", "topic": "topic", "outputs": 1, "x": 595.4409561157227, "y": 370.9444751739502, "wires": [ [ "e407cb7a0c164463", "ce25cf38.62ac2" ] ] }, { "id": "371d14f4.d4172c", "type": "inject", "z": "c504c42c.c48a28", "name": "Simulate Blacky Button Press", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "PT2262", "payload": "on", "payloadType": "str", "x": 148.43751525878906, "y": 462.97223377227783, "wires": [ [ "2f2e7b25.3d7494" ] ] }, { "id": "2f2e7b25.3d7494", "type": "change", "z": "c504c42c.c48a28", "name": "Change topic to TEST/SOCKET/1", "rules": [ { "t": "set", "p": "topic", "pt": "msg", "to": "TEST/SOCKET/1", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 355.44447326660156, "y": 362.1180839538574, "wires": [ [ "20a20449.6f330c" ] ] }, { "id": "38cca044.fc7bd", "type": "rfxtrx-port", "port": "/dev/ttyUSB0", "rfyVenetianMode": "US" }, { "id": "76f8758d.aa710c", "type": "PT2262-device-list", "name": "Test Devices", "devices": [ { "device": [ "TEST", "SOCKET", "1" ], "payload": "Off", "rawData": "0x145454", "pulseWidth": 325 }, { "device": [ "TEST", "SOCKET", "1" ], "payload": "On", "rawData": "0x145451", "pulseWidth": 325 } ] }, { "id": "60e7b171.09773", "type": "PT2262-device-list", "name": "Blacky", "devices": [ { "device": [ "PT2262" ], "payload": "on", "rawData": "0xcb5ba1", "pulseWidth": 350 } ] } ]

UweNB commented 2 years ago

Hello Max!

Thank you very much, that's it! Now I understand the "mechanics" behind it - at least I think I do :)

What is still open is how do I get the whole thing to react only to the "Blacky" switch?

That's what I get back in the debug window:

10/4/2021, 09:42:12node: e407cb7a0c164463 PT2262 : msg.payload : string[2] "on"

10/4/2021, 09:42:12node: 0129434d0f298893 TEST/SOCKET/1 : msg : Object { status: object, topic: "TEST/SOCKET/1", payload: "On", _msgid: "26138b7d24bbfba3" } 10/4/2021, 09:42:15node: 0129434d0f298893

TEST/SOCKET/1 : msg : Object { status: object, topic: "TEST/SOCKET/1", payload: "Off", _msgid: "26138b7d24bbfba3" }

I don't know what to set under "only listen for addresses matching a pattern" PT2262/? The payload "on" does not work ...

Thanks for your help, I really appreciate it. Hopefully your circumstances will get better and less "chaotic" as you wrote!

All the best and thanks Florian

maxwellhadley commented 2 years ago

The dialog text is a bit misleading. The 'address' is the message topic to be matched, not the payload. When I wrote this, I expected that it would be necessary to always start the topics of PT2262 message nodes with 'PT2262/', so the dialog text and the nodes instructions are written that way. However, as you have discovered yourself, it isn't actually necessary, the topic can be anything.

The simplest sort of match is the string prefix, as described in the help text for the node, but MQTT-style 'wildcards' can be used, if you are also using MQTT. If not, just use prefix matching. For example, you might name the 'Blacky' device to PT2262/Remote

However, there is a complication. All PT2262-in nodes internally receive all radio messages. They look up the raw data in the deice list they are using, and if there is an entry for the raw data value, they use the topic & payload it provides. This topic is matched against the address prefix, and if it matches, the message is output. If there is no corresponding entry in the device list, the raw message is always output. This may give problems if you are using more than one device list. I suggest you use only a single device list, combining both the 'blacky' and 'test devices' entries - they don't clash

UweNB commented 2 years ago

Hello Max, interesting effect: if I enter Blacky under "Address", the Flow does not respond - but to any other 433MHz device.

What exactly would I have to enter so that it only reacts to Blacky?

In this respect, I don't quite understand your explanation (not my native language, sorry).

Thank you very much!

maxwellhadley commented 2 years ago

Try something like this. I have added a switch node between the rfx-PT2262-in node and the change topic node. The switch rules say if msg.tpoic starts with PT2262/Remote, pass the message to the first output, otherwise pass the message to the second output (which is not connected, so the message is ignored). If the raw data received is matched in the 'Blacky' device list, the PT2262 node output message topic & payload will be set, and the message goes to the first output of the switch only if the topic matches. If the raw data does not match, then the PT2262 node output message will not have a topic at all so the switch node does not pass it on to the change node.

[{"id":"ce25cf38.62ac2","type":"rfx-PT2262-out","z":"c504c42c.c48a28","name":"","port":"f7e48e28.54285","deviceList":"76f8758d.aa710c","topicSource":"msg","retransmit":"none","retransmitInterval":20,"topic":"","x":879.8958969116211,"y":284.9999780654907,"wires":[]},{"id":"8d49d8a8.22dc78","type":"inject","z":"c504c42c.c48a28","name":"","repeat":"","crontab":"","once":false,"topic":"TEST/SOCKET/1","payload":"On","payloadType":"str","x":499.89591217041016,"y":151,"wires":[["ce25cf38.62ac2"]]},{"id":"62a26abf.17fcd4","type":"inject","z":"c504c42c.c48a28","name":"","repeat":"","crontab":"","once":false,"topic":"TEST/SOCKET/1","payload":"Off","payloadType":"str","x":478.89588165283203,"y":263.00002002716064,"wires":[["ce25cf38.62ac2"]]},{"id":"e407cb7a0c164463","type":"debug","z":"c504c42c.c48a28","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":891.8958969116211,"y":558.0000581741333,"wires":[]},{"id":"ab34b5e4825ad361","type":"rfx-PT2262-in","z":"c504c42c.c48a28","name":"TestBlacky","port":"f7e48e28.54285","deviceList":"60e7b171.09773","topicSource":"single","topic":"PT2262/Remote","x":98.89588165283203,"y":487.00006008148193,"wires":[["4f1440c1.2dceb"]]},{"id":"20a20449.6f330c","type":"trigger","z":"c504c42c.c48a28","name":"","op1":"On","op2":"Off","op1type":"str","op2type":"str","duration":"3","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":773.4410095214844,"y":454.9444799423218,"wires":[["e407cb7a0c164463","ce25cf38.62ac2"]]},{"id":"371d14f4.d4172c","type":"inject","z":"c504c42c.c48a28","name":"Simulate Blacky Button Press","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"PT2262/Remote/1","payload":"on","payloadType":"str","x":165.43751525878906,"y":303.97227573394775,"wires":[["4f1440c1.2dceb"]]},{"id":"2f2e7b25.3d7494","type":"change","z":"c504c42c.c48a28","name":"Change topic to TEST/SOCKET/1","rules":[{"t":"set","p":"topic","pt":"msg","to":"TEST/SOCKET/1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":438.44461822509766,"y":595.1180381774902,"wires":[["20a20449.6f330c","4bcda5cc.f3527c"]]},{"id":"4f1440c1.2dceb","type":"switch","z":"c504c42c.c48a28","name":"Test msg.topic starts with PT2262/Remote","property":"topic","propertyType":"msg","rules":[{"t":"regex","v":"^PT2262/Remote","vt":"str","case":true},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":445.4515686035156,"y":405.5731506347656,"wires":[["2f2e7b25.3d7494"],[]]},{"id":"4bcda5cc.f3527c","type":"debug","z":"c504c42c.c48a28","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":747.2292323112488,"y":702.625002861023,"wires":[]},{"id":"f7e48e28.54285","type":"rfxtrx-port","port":"/dev/tty.usbserial-A1R1A6A","enableDebug":true,"rfyVenetianMode":"EU"},{"id":"76f8758d.aa710c","type":"PT2262-device-list","name":"Test Devices","devices":[{"device":["TEST","SOCKET","1"],"payload":"Off","rawData":"0x145454","pulseWidth":325},{"device":["TEST","SOCKET","1"],"payload":"On","rawData":"0x145451","pulseWidth":325}]},{"id":"60e7b171.09773","type":"PT2262-device-list","name":"Blacky","devices":[{"device":["PT2262","Remote","1"],"payload":"on","rawData":"0xcb5ba1","pulseWidth":350}]}]

UweNB commented 2 years ago

Hello Max,

Unfortunately, it doesn't work like that. There is no reaction - neither to the "Blacky" transmitter nor to any other 433 MHz input.

Do you have any other ideas?

Thank you very much!