Closed thunder-62 closed 7 years ago
brightness works by including a properties object as defined at node-tradfri-argon. Perhaps I need to describe it a bit clearer..
I.e. as stated in the description: msg.payload = { tradfri_id: 1234, type: 'group', instruction: { state: 'on', color: 'f5faf6', brightness: 255 }} Note: if you've defined the device in the node, tradfri_id and type are not required in input. E.g. msg.payload = {instruction: { state: 'on', color: 'f5faf6', brightness: 255 }}
That should work. If it doesn't, please let me know (it hasn't been tested thoroughly)
I've thought about it a bit more.. I'll redesign it (but will maintain backlevel support) to make it easier to use
hmm... an object without id and type fires an exception on my setup...
7.6.2017, 12:10:53node: Test msg : string[54] "msg.payload.type, device or group has not been defined"
[{"id":"2bc5bbe.5453844","type":"inject","z":"e3b4d5fe.874ec8","name":"","topic":"brightness","payload":"200","payloadType":"num","repeat":"","crontab":"","once":false,"x":220,"y":1120,"wires":[["7bb3b76e.608ac8"]]},{"id":"7bb3b76e.608ac8","type":"function","z":"e3b4d5fe.874ec8","name":"ttttt","func":"switch(msg.topic){\ncase \"state\":\n flow.uhuState = msg.payload;\n break;\n\ncase \"brightness\":\n flow.uhuBrightness=msg.payload;\n break;\n}\nmsg.topic=\"\";\nmsg.payload={instruction: { state: flow.uhuState, brightness: flow.uhuBrightness}};\nreturn msg;","outputs":1,"noerr":0,"x":770,"y":1140,"wires":[["bade471b.109628","a18230ea.60c06"]]},{"id":"a766d740.43c218","type":"inject","z":"e3b4d5fe.874ec8","name":"","topic":"state","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"x":200,"y":1160,"wires":[["7bb3b76e.608ac8"]]},{"id":"c78a5af1.a2c018","type":"inject","z":"e3b4d5fe.874ec8","name":"","topic":"state","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"x":199,"y":1209,"wires":[["7bb3b76e.608ac8"]]},{"id":"91ea8f14.cf89e","type":"inject","z":"e3b4d5fe.874ec8","name":"","topic":"brightness","payload":"50","payloadType":"num","repeat":"","crontab":"","once":false,"x":210,"y":1080,"wires":[["7bb3b76e.608ac8"]]},{"id":"bade471b.109628","type":"tradfri-out","z":"e3b4d5fe.874ec8","name":"Test","dtype":"device","tradfri_id":"65538","hub":"4ed8aa7c.430d84","output":false,"x":950,"y":1140,"wires":[]},{"id":"a18230ea.60c06","type":"debug","z":"e3b4d5fe.874ec8","name":"","active":true,"console":"false","complete":"false","x":960,"y":1200,"wires":[]},{"id":"4ed8aa7c.430d84","type":"tradfri-config","z":"","name":"here","hubip":"192.168.1.1","sid":"tttt","coap":"/usr/local/bin/coap-client"}]
OK, I'll do some tests tonight. This is a correct behaviour if you have not selected a device/group within the node - did the dropdown say "By msg.tradfri_id" or did you select a group/device?
I selected a device.
Ok, I've done better testing and new updates to the code. I've also tried to simplify the usage when steering through an incoming message. New options are available - color for groups and transition time. Check the README for details. Please verify and close if it works :-)
it works like a charm... Thank you for the great work...
Toggle is a very good idea either...
Great - thanks for verifying
on/off works like a charm.
Would it be possible to implement an easy way to set brightness and colour the same way as on/off? putting together the ja object is a bit cryptic and makes the node-red flows somewhat difficult to read.