hobbyquaker / node-red-contrib-zigbee

Node-RED Nodes for ZigBee Devices 🐝
MIT License
86 stars 15 forks source link

Setting lamp brightness with msg.payload #81

Closed tanker11 closed 4 years ago

tanker11 commented 4 years ago

Hello,

I have an issue setting an IKEA bulb brightness via mag.payload. I can set it when doing the following manual command: image

But if I wanted to set the brightness value by the payload value from another node, I fail. Something like this: image

Is there any simple way to let the command node accept the payload for setting a value in its JSON?

Thx,Robert

Sineos commented 4 years ago

Simply set the complete payload in a change node before the command node

tanker11 commented 4 years ago

Thanks for replying. I tried with change node as well as template to build the JSON structure. But I don't know what format the 'payload' field is accepting. Is it a string? Is it an object? Sorry I am not experienced enough to find out from the source. If you may had a working example accepting value from a node in 'payload' field would help a lot...

Sineos notifications@github.com ezt írta (időpont: 2019. dec. 20., P, 19:40):

Simply set the complete payload in a change node befor the command node

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hobbyquaker/node-red-contrib-zigbee/issues/81?email_source=notifications&email_token=AHVM6OY5X2LZFQWG4LVFZT3QZUGTHA5CNFSM4J56VWSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHNZTII#issuecomment-568039841, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHVM6OY6S3XP3TNLXYRENX3QZUGTHANCNFSM4J56VWSA .

Sineos commented 4 years ago

Try this:

[{"id":"4cc7d850.9984f","type":"inject","z":"2808bf91.f42188","name":"","topic":"","payload":"255","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":140,"wires":[["d4f49b2f.1cfac"]]},{"id":"d4f49b2f.1cfac","type":"change","z":"2808bf91.f42188","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"level\": $.payload,\"transtime\":0}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":140,"wires":[["1f9dde48.cc89b2"]]},{"id":"1f9dde48.cc89b2","type":"debug","z":"2808bf91.f42188","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":140,"wires":[]}]

tanker11 commented 4 years ago

Hello,

I really appreciate the help. I could make this object as well, but I don't know what to put in command node's payload field to use it up... :o Can you help in that part, too? It seems not recognising the content. In my example: "Parameter 'level' is missing" is the error message.

Thanks in advance

Sineos notifications@github.com ezt írta (időpont: 2019. dec. 21., Szo, 11:29):

Try this:

[{"id":"4cc7d850.9984f","type":"inject","z":"2808bf91.f42188","name":"","topic":"","payload":"255","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":140,"wires":[["d4f49b2f.1cfac"]]},{"id":"d4f49b2f.1cfac","type":"change","z":"2808bf91.f42188","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"level\": $.payload,\"transtime\":0}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":140,"wires":[["1f9dde48.cc89b2"]]},{"id":"1f9dde48.cc89b2","type":"debug","z":"2808bf91.f42188","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":140,"wires":[]}]

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hobbyquaker/node-red-contrib-zigbee/issues/81?email_source=notifications&email_token=AHVM6O7M5OM5JBRNXSUOBRDQZXVYRA5CNFSM4J56VWSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHOZO6Y#issuecomment-568170363, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHVM6O3QPQVVLVWISQMZXZTQZXVYRANCNFSM4J56VWSA .

Sineos commented 4 years ago

Hmm, just a weird idea: Try to use msg.parameters to pass your level / transtime object instead of msg.payload.

I don't own a device that requires such construct, so it is a bit of guess work.

tanker11 commented 4 years ago

I'll be honest: I don't know how to do that... But let's simplify the issue to the following, assuming that you have a device supporting a 'genOnOff' cluster:

Like this: [image: image.png] and this: [image: image.png] As you can see from the first screenshot, it does not work... It is all analogous to the more complex structure, so if I would make this one work, I guess the next level of complexity can easily be completed. :)

Below is the clipboard for the nodes (of course with my device, but you can easily modify for your physical device, which I guess have an onOff functionality.

[{"id":"9b7fe8d1.1cec8","type":"zigbee-command","z":"e2875448.111bc8","shepherd":"37bd7311.62c1ac","name":"command","target":"endpoint","cmdType":"command","group":"","ieeeAddr":"0x086bd7fffe587c36 Bulb1","ep":"1","cid":"genOnOff","cmd":"{{msg.payload}}","zclData":"{}","zclDataType":"json","attributesRead":"[]","attributesReadType":"json","attributesWrite":"{}","attributesWriteType":"json","manufSpec":0,"disableDefaultRsp":0,"x":1132.300048828125,"y":3208.949951171875,"wires":[[]]},{"id":"4ee6aac8.02daf4","type":"inject","z":"e2875448.111bc8","name":"","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":875.816650390625,"y":3206.0166015625,"wires":[["9b7fe8d1.1cec8"]]},{"id":"f2e2262.4647658","type":"inject","z":"e2875448.111bc8","name":"","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":878.816650390625,"y":3258.0166015625,"wires":[["9b7fe8d1.1cec8"]]},{"id":"37bd7311.62c1ac","type":"zigbee-shepherd","z":"","name":"zigbee shepherd","path":"/dev/ttyACM0","baudRate":"115200","rtscts":true,"channelList":[11],"led":"enabled"}]

Thanks

Sineos notifications@github.com ezt írta (időpont: 2019. dec. 21., Szo, 23:09):

Hmm, just a weird idea: Try to use msg.parameters to pass your level / transtime object instead of msg.payload.

I don't own a device that requires such construct, so it is a bit of guess work.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hobbyquaker/node-red-contrib-zigbee/issues/81?email_source=notifications&email_token=AHVM6O45TIBXO5DPFGMYKNLQZ2H23A5CNFSM4J56VWSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHPEPKI#issuecomment-568215465, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHVM6O4OAE2G3K6ETMG3TI3QZ2H23ANCNFSM4J56VWSA .

Sineos commented 4 years ago

For the simple on/off type of thing try: [{"id":"b27f391f.9af46","type":"change","z":"2808bf91.f42188","name":"Set command on","rules":[{"t":"set","p":"cmd","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":220,"wires":[["c3e94190.73b22"]]},{"id":"714321e0.2b259","type":"inject","z":"2808bf91.f42188","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":220,"wires":[["b27f391f.9af46"]]},{"id":"c3e94190.73b22","type":"zigbee-command","z":"2808bf91.f42188","shepherd":"6a60708c.5bef28","name":"command","target":"endpoint","cmdType":"command","group":"","ieeeAddr":"0x086bd7fffe587c36 Bulb1","ep":"1","cid":"genOnOff","cmd":"","zclData":"{}","zclDataType":"json","attributesRead":"[]","attributesReadType":"json","attributesWrite":"{}","attributesWriteType":"json","manufSpec":0,"disableDefaultRsp":0,"x":580,"y":220,"wires":[[]]},{"id":"6a60708c.5bef28","type":"zigbee-shepherd","z":"","name":"zigbee shepherd","path":"/dev/ttyACM0","baudRate":"115200","rtscts":true,"channelList":[11],"led":"enabled"}]

For the brightness stuff as per your original post try: [{"id":"4cc7d850.9984f","type":"inject","z":"2808bf91.f42188","name":"","topic":"","payload":"255","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":120,"wires":[["d4f49b2f.1cfac"]]},{"id":"d4f49b2f.1cfac","type":"change","z":"2808bf91.f42188","name":"","rules":[{"t":"set","p":"parameters","pt":"msg","to":"{\"level\": $.payload,\"transtime\":0}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":120,"wires":[["1f9dde48.cc89b2","c02496fd.68197"]]},{"id":"1f9dde48.cc89b2","type":"debug","z":"2808bf91.f42188","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":570,"y":120,"wires":[]},{"id":"c02496fd.68197","type":"zigbee-command","z":"2808bf91.f42188","shepherd":"6a60708c.5bef28","name":"command","target":"endpoint","cmdType":"command","group":"","ieeeAddr":"0x086bd7fffe587c36 Bulb1","ep":"1","cid":"genLevelCtrl","cmd":"moveToLevelWithOnOff","zclData":"{}","zclDataType":"json","attributesRead":"[]","attributesReadType":"json","attributesWrite":"{}","attributesWriteType":"json","manufSpec":0,"disableDefaultRsp":0,"x":580,"y":80,"wires":[[]]},{"id":"6a60708c.5bef28","type":"zigbee-shepherd","z":"","name":"zigbee shepherd","path":"/dev/ttyACM0","baudRate":"115200","rtscts":true,"channelList":[11],"led":"enabled"}]

tanker11 commented 4 years ago

I could make a try and it works!!! Thank you very much for teaching me how to do it.

IMPORTANT Note: after import, with current 0.16.4 version, by importing the above, it creates additional herdsman config nodes, which should be deleted before deploying, otherwise it screws up everything. For others, see #83

Sineos notifications@github.com ezt írta (időpont: 2019. dec. 22., V, 14:08):

For the simple on/off type of thing try: [{"id":"b27f391f.9af46","type":"change","z":"2808bf91.f42188","name":"Set command on","rules":[{"t":"set","p":"cmd","pt":"msg","to":"on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":220,"wires":[["c3e94190.73b22"]]},{"id":"714321e0.2b259","type":"inject","z":"2808bf91.f42188","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":220,"wires":[["b27f391f.9af46"]]},{"id":"c3e94190.73b22","type":"zigbee-command","z":"2808bf91.f42188","shepherd":"6a60708c.5bef28","name":"command","target":"endpoint","cmdType":"command","group":"","ieeeAddr":"0x086bd7fffe587c36 Bulb1","ep":"1","cid":"genOnOff","cmd":"","zclData":"{}","zclDataType":"json","attributesRead":"[]","attributesReadType":"json","attributesWrite":"{}","attributesWriteType":"json","manufSpec":0,"disableDefaultRsp":0,"x":580,"y":220,"wires":[[]]},{"id":"6a60708c.5bef28","type":"zigbee-shepherd","z":"","name":"zigbee shepherd","path":"/dev/ttyACM0","baudRate":"115200","rtscts":true,"channelList":[11],"led":"enabled"}]

For the brightness stuff as per your original post try: [{"id":"4cc7d850.9984f","type":"inject","z":"2808bf91.f42188","name":"","topic":"","payload":"255","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":120,"wires":[["d4f49b2f.1cfac"]]},{"id":"d4f49b2f.1cfac","type":"change","z":"2808bf91.f42188","name":"","rules":[{"t":"set","p":"parameters","pt":"msg","to":"{\"level\": $.payload,\"transtime\":0}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":120,"wires":[["1f9dde48.cc89b2","c02496fd.68197"]]},{"id":"1f9dde48.cc89b2","type":"debug","z":"2808bf91.f42188","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":570,"y":120,"wires":[]},{"id":"c02496fd.68197","type":"zigbee-command","z":"2808bf91.f42188","shepherd":"6a60708c.5bef28","name":"command","target":"endpoint","cmdType":"command","group":"","ieeeAddr":"0x086bd7fffe587c36 Bulb1","ep":"1","cid":"genLevelCtrl","cmd":"moveToLevelWithOnOff","zclData":"{}","zclDataType":"json","attributesRead":"[]","attributesReadType":"json","attributesWrite":"{}","attributesWriteType":"json","manufSpec":0,"disableDefaultRsp":0,"x":580,"y":80,"wires":[[]]},{"id":"6a60708c.5bef28","type":"zigbee-shepherd","z":"","name":"zigbee shepherd","path":"/dev/ttyACM0","baudRate":"115200","rtscts":true,"channelList":[11],"led":"enabled"}]

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/hobbyquaker/node-red-contrib-zigbee/issues/81?email_source=notifications&email_token=AHVM6O22NCEJWPVOGOEFEADQZ5RDRA5CNFSM4J56VWSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHPPOPY#issuecomment-568260415, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHVM6O4O3XD2SM7GQ7X3LODQZ5RDRANCNFSM4J56VWSA .

Sineos commented 4 years ago

Glad that I could help 👍

Please close the issue if you feel it is finished.

tanker11 commented 4 years ago

Great and quick help