Hello Again!
How do I change an object into msg.payload?
The node (homekit) spits out an object ```
{
"On": true
}
in msg.payload
I want to translate this to a simple msg.payload "true" or "false" to write to my MQTT server
thank you!!
Hello Again!
How do I change an object into msg.payload?
The node (homekit) spits out an object ```
{
"On": true
}
in msg.payload
I want to translate this to a simple msg.payload "true" or "false" to write to my MQTT server
thank you!!
You can use a Change node set to Move msg.payload.On To msg.payload. Note that is Move, not Set.
However I have just noticed that you are also asking for it to be converted from a logic level to a string. Are you sure you need to do that? Try it without first and see what you get.
If you do need it as a string then instead set the change node to Set msg.payload, select J: as the To type and then
msg.payload.On ? "true" : "false"
perfect! thank you Colin
(and you were right, I didn't need to convert to string)
follow up:
How do I do it the other way?
creating an object (On:true) from msg.payload?
The "move" change node doesn't work...
Martin
Found it...
MQTT is sending a string, not a boolean...So i did a JSON convert first, now it works
Bonjour
J'ai le même problème avec le KNX
inject on/off fonctionne
homekit fonctionne pas
[{"id":"f6d712c4.d97f2","type":"knx-device","z":"71a21c8a.db9864","controller":"e52198d6.e79f58","mode":"manual","groupaddresses":"","name":"lampe","groupaddress":"0/1/6","statusga":"2/1/6","dpt":"DPT1","x":1070,"y":400,"wires":[]},{"id":"280b9330.6d83ec","type":"homekit-service","z":"71a21c8a.db9864","accessory":"bdf57a7e.61d9e8","name":"lampe","serviceName":"Switch","x":370,"y":300,"wires":[["7b818f46.c3d92","d801f2.f7eb0e1"]]},{"id":"206253fe.5d188c","type":"inject","z":"71a21c8a.db9864","name":"On","topic":"","payload":"true","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":360,"wires":[["f6d712c4.d97f2","d801f2.f7eb0e1"]]},{"id":"d8464fa0.86d04","type":"inject","z":"71a21c8a.db9864","name":"Off","topic":"","payload":"false","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":400,"wires":[["f6d712c4.d97f2","d801f2.f7eb0e1"]]},{"id":"d801f2.f7eb0e1","type":"debug","z":"71a21c8a.db9864","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1070,"y":340,"wires":},{"id":"7b818f46.c3d92","type":"change","z":"71a21c8a.db9864","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"msg","to":"true","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"false","fromt":"msg","to":"false","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":260,"wires":[["f6d712c4.d97f2"]]},{"id":"e52198d6.e79f58","type":"knx-controller","z":"","ipAddr":"192.168.8.132","ipPort":"3671","physAddr":"1.1.159"},{"id":"bdf57a7e.61d9e8","type":"homekit-accessory","z":"","accessoryName":"lampes","pinCode":"111-11-111","port":"","manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","accessoryType":"8"}]
homekit problème
[{"id":"db2285a6.4b1228","type":"knx-device","z":"1b9feac0.80b585","controller":"e52198d6.e79f58","mode":"manual","groupaddresses":"","name":"lampe","groupaddress":"0/1/6","statusga":"2/1/6","dpt":"DPT1","x":1150,"y":760,"wires":[]},{"id":"b1eb906c.ff687","type":"homekit-service","z":"1b9feac0.80b585","accessory":"bdf57a7e.61d9e8","name":"lampe","serviceName":"Switch","x":410,"y":660,"wires":[["7868b10b.16b47","4578b954.2a1908"]]},{"id":"b3bfdcf4.71853","type":"inject","z":"1b9feac0.80b585","name":"On","topic":"","payload":"true","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":250,"y":720,"wires":[["db2285a6.4b1228","7868b10b.16b47"]]},{"id":"accee2e2.8b788","type":"inject","z":"1b9feac0.80b585","name":"Off","topic":"","payload":"false","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":250,"y":760,"wires":[["db2285a6.4b1228","7868b10b.16b47"]]},{"id":"7868b10b.16b47","type":"debug","z":"1b9feac0.80b585","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1150,"y":700,"wires":},{"id":"4578b954.2a1908","type":"change","z":"1b9feac0.80b585","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"true","fromt":"msg","to":"true","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":700,"y":640,"wires":[["db2285a6.4b1228"]]},{"id":"e52198d6.e79f58","type":"knx-controller","z":"","ipAddr":"192.168.8.132","ipPort":"3671","physAddr":"1.1.159"},{"id":"bdf57a7e.61d9e8","type":"homekit-accessory","z":"","accessoryName":"lampes","pinCode":"111-11-111","port":"","manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","accessoryType":"8"}]