Issue with sending temperature to homekit node

Hi all,

Can't figure this out...:slight_smile:
I am trying to send a temperature from a zigbee2mqtt node to a HomeKit node using a change, but it gives me an error:

[{"id":"f4763e3d.c019b8","type":"zigbee2mqtt-in","z":"ecabaa55.339ab8","name":"Soveværelse Temp.","server":"abca54b8.bf83a8","friendly_name":"0x00158d000208dcc9","device_id":"0x00158d000208dcc9","state":"temperature","outputAtStartup":true,"x":110,"y":1900,"wires":[["81c72799.78011","ac5adc35.77057","f98d5b2.a4831a8"]]},{"id":"f98d5b2.a4831a8","type":"change","z":"ecabaa55.339ab8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"CurrentTemperature\":{{payload}}}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":1860,"wires":[["4f53bc1d.399d7c","eaee04be.664ae8"]]},{"id":"4f53bc1d.399d7c","type":"homekit-service","z":"ecabaa55.339ab8","isParent":true,"bridge":"8b72c53e.f04088","accessoryCategory":"SENSOR","parentService":"","name":"Soveværelse temp.","serviceName":"TemperatureSensor","topic":"","filter":false,"manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","characteristicProperties":"{}","x":650,"y":1860,"wires":[[],[]]},{"id":"abca54b8.bf83a8","type":"zigbee2mqtt-server","z":"","name":"","host":"localhost","mqtt_port":"1883","mqtt_username":"xxx","mqtt_password":"xxx","base_topic":"zigbee2mqtt"},{"id":"8b72c53e.f04088","type":"homekit-bridge","z":"","bridgeName":"States","pinCode":"xxx-xx-xxx","port":"","allowInsecureRequest":false,"manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","customMdnsConfig":false,"mdnsMulticast":true,"mdnsInterface":"","mdnsPort":"","mdnsIp":"","mdnsTtl":"","mdnsLoopback":true,"mdnsReuseAddr":true,"allowMessagePassthrough":true}]

I get "Invalid 'to' JSON property" in the debug window. If I exchange the {"CurrentTemperature":{{payload}}} with an actual temperature - let's say {"CurrentTemperature":22} - it works fine.
I realize that this probably is something simple I am missing, but I will be very grateful for any help:-)
Cheers,
Peter

You can not use mustache in a json, in the change node. use JSONata instead

[{"id":"b8c635da.ed89a8","type":"change","z":"4ed02988.12fff8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"CurrentTemperature\": payload}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":300,"wires":[[]]}]

Worked perfectly. Thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.