我有一个python代码,可将2个值发送到同一通道。 “ sensor / X”和“ sensor / Y”,我想将它们合并为一个Json对象 {X:传感器/ X的值,Y:传感器/ Y的值}。
我已经完成了该节点:
[{"id":"6497f22a.847fd4","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"7843571.5b8c028","type":"debug","z":"6497f22a.847fd4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":650,"y":600,"wires":[]},{"id":"400510c2.75256","type":"json","z":"6497f22a.847fd4","name":"","property":"payload","action":"","pretty":false,"x":410,"y":600,"wires":[["7843571.5b8c028"]]},{"id":"3af33205.2fc486","type":"inject","z":"6497f22a.847fd4","name":"","topic":"","payload":"{\"topic\":\"tele/Mysonoff_TH10/SENSOR\",\"payload\":\"{\\\"Time\\\":\\\"2018-12-21T16:51:09\\\",\\\"AM2301\\\":{\\\"Temperature\\\":69.4,\\\"Humidity\\\":33.9},\\\"TempUnit\\\":\\\"F\\\"}\",\"qos\":0,\"retain\":false,\"_topic\":\"tele/Mysonoff_TH10/SENSOR\",\"_msgid\":\"dae7f7bc.36e5f8\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":880,"y":1360,"wires":[[]]},{"id":"fd6553d8.f5fda","type":"mqtt in","z":"6497f22a.847fd4","name":"","topic":"sensor/#","qos":"2","datatype":"auto","broker":"2ad9c0c8.618a48","x":230,"y":600,"wires":[["400510c2.75256"]]},{"id":"2ad9c0c8.618a48","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
但是它不起作用。.我可能确定我必须在javacript中编写一个函数来执行此操作,以便指定将如何写入json,但是此时我有点迷失了。 >
谢谢