maxwellhadley / node-red-contrib-rfxcom

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

PT2262-in to boolean true #120

Closed UweNB closed 2 years ago

UweNB commented 2 years ago

hello maxwell,

i am stuck. i have a 4 channel remote here, i would like to use it to control 4 philips Hue smartplugs.

The smartplugs only respond to boolean true or false I recognize by PT2262-in the codes of the remote control, make there the payload aon and aoff (for channel A of the remote control). Then I wanted to convert aon to true, or aoff to false. This does not work - what am I doing wrong?

Thanks!

[{"id":"6d1d9681110c0f63","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"ab34b5e4825ad361","type":"rfx-PT2262-in","z":"6d1d9681110c0f63","name":"A","port":"38cca044.fc7bd","deviceList":"0dd3cb0011ea3ee6","topicSource":"all","topic":"","x":370,"y":520,"wires":[["89dd8f1cc1d86731","ea479ab9fd64d83b"]]},{"id":"371d14f4.d4172c","type":"inject","z":"6d1d9681110c0f63","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":1440,"y":140,"wires":[[]]},{"id":"9b087db62fdd9c27","type":"debug","z":"6d1d9681110c0f63","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1080,"y":180,"wires":[]},{"id":"04a60a5ec1aba301","type":"hue-light","z":"6d1d9681110c0f63","name":"Hue smart plug 4","bridge":"36b93868f3cfa2da","lightid":"12","colornamer":true,"skipevents":false,"universalevents":false,"x":810,"y":180,"wires":[["9b087db62fdd9c27"]]},{"id":"dd1009a273f3a32a","type":"inject","z":"6d1d9681110c0f63","name":"Ein","props":[{"p":"topic","v":"true","vt":"bool"},{"p":"payload.on","v":"true","vt":"bool"}],"repeat":"","crontab":"45 16 * * *","once":false,"onceDelay":0.1,"topic":"","x":450,"y":120,"wires":[["04a60a5ec1aba301"]]},{"id":"fdd6419b583ca648","type":"inject","z":"6d1d9681110c0f63","name":"Aus","props":[{"p":"topic","v":"false","vt":"bool"},{"p":"payload.on","v":"false","vt":"bool"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":448,"y":197,"wires":[["04a60a5ec1aba301"]]},{"id":"8347968e984cd988","type":"hue-light","z":"6d1d9681110c0f63","name":"Hue smart plug 4","bridge":"36b93868f3cfa2da","lightid":"12","colornamer":true,"skipevents":false,"universalevents":false,"x":1090,"y":540,"wires":[[]]},{"id":"89dd8f1cc1d86731","type":"switch","z":"6d1d9681110c0f63","name":"On","property":"aon","propertyType":"msg","rules":[{"t":"eq","v":"a-on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":570,"y":500,"wires":[["598aeaddc23327b4"]]},{"id":"598aeaddc23327b4","type":"change","z":"6d1d9681110c0f63","name":"","rules":[{"t":"set","p":"aon","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":500,"wires":[["8347968e984cd988"]]},{"id":"ea479ab9fd64d83b","type":"switch","z":"6d1d9681110c0f63","name":"Off","property":"aoff","propertyType":"msg","rules":[{"t":"eq","v":"a-on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":570,"y":560,"wires":[["1761ec836e15bda6"]]},{"id":"1761ec836e15bda6","type":"change","z":"6d1d9681110c0f63","name":"","rules":[{"t":"set","p":"aoff","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":560,"wires":[["8347968e984cd988"]]},{"id":"8ab515158182b412","type":"inject","z":"6d1d9681110c0f63","name":"","props":[{"p":"payload"},{"p":"topic","v":"true","vt":"flow"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":650,"y":80,"wires":[["04a60a5ec1aba301"]]},{"id":"38cca044.fc7bd","type":"rfxtrx-port","port":"/dev/ttyUSB0","rfyVenetianMode":"US"},{"id":"0dd3cb0011ea3ee6","type":"PT2262-device-list","name":"Kanal A","devices":[{"device":["PT2262"],"payload":"aoff","rawData":"0x104554","pulseWidth":350},{"device":["PT2262"],"payload":"aon","rawData":"0x10555f","pulseWidth":350}]},{"id":"36b93868f3cfa2da","type":"hue-bridge","name":"HueMagic Bridge","bridge":"192.168.1.23","key":"IwnC3vTIm1b5YA9x1YgVMeFJ9MqvWBHPlJHFejnf","interval":"3000","disableupdates":false}]

maxwellhadley commented 2 years ago

I have never used the Hue nodes, but I think something like the following should work. I have used a switch node to route the PT2262 output to one of two change nodes. these change the payload to an object that I think is what the hue node is looking for, either {on: true} or {on: false}. I have left the topic and status alone. I don't know how the Hue node decides which address to use.

You should replace the debug node with your Hue node

[{"id":"ab34b5e4825ad361","type":"rfx-PT2262-in","z":"6d1d9681110c0f63","name":"A","port":"f7e48e28.54285","deviceList":"0dd3cb0011ea3ee6","topicSource":"all","topic":"","x":112.00002861022949,"y":146.0000228881836,"wires":[["4d635045.12f6c"]]},{"id":"1af7ad20.d74323","type":"debug","z":"6d1d9681110c0f63","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":533.1181373596191,"y":148.16670608520508,"wires":[]},{"id":"4d635045.12f6c","type":"function","z":"6d1d9681110c0f63","name":"","func":"if (msg.payload === \"aon\") {\n msg = {on: true}\n} else if (msg.payload === \"aoff\") {\n msg = {on: false}\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":309.56249237060547,"y":149.69445037841797,"wires":[["1af7ad20.d74323"]]},{"id":"f7e48e28.54285","type":"rfxtrx-port","port":"/dev/tty.usbserial-A1R1A6A","enableDebug":true,"rfyVenetianMode":"EU"},{"id":"0dd3cb0011ea3ee6","type":"PT2262-device-list","name":"Kanal A","devices":[{"device":["PT2262"],"payload":"aoff","rawData":"0x104554","pulseWidth":350},{"device":["PT2262"],"payload":"aon","rawData":"0x10555f","pulseWidth":350}]}]

UweNB commented 2 years ago

Hello Maxwell,

i have found a another solution. pls close that issue.

Happy new year for you and your family!