I have the following JSON coming from MQTT broker:
{"end_device_ids":
{"device_id": "eui-70b3d57ed004d388",
"application_ids": {"application_id": "mqtt-rpi3b"},
"dev_eui": "70B3D57ED004D388",
"join_eui": "0000000000000000",
"dev_addr": "260C0875" },
"received_at": "2022-02-27T23:45:18.013631675Z",
"uplink_message":
{"session_key_id": "AX88sOZsNTkoN5rZ+Rzx/Q==",
"f_port": 1,
"f_cnt": 80,
"frm_payload": "SGVsbG8sIHdvcmxkIQ==",
"decoded_payload":
{"degreesC": 20.20263671875,
"humidity": 38.1103515625
}
}
}
If I convert it to JavaSript with JSON node in Node-Red, and build a Function node to pull out the temp and humidity, it works perfectly, and I get the following in the Node-Red Debug window:
2/28/2022, 9:59:23 AMnode: a99be1c0d3d3695dv3/mqtt-rpi3b@ttn/devices/eui-70b3d57ed004d338/up : msg.payload : array[1]
array[1]
0: object
Temp: 20.60546875
Humidity: 49.51171875
Now I donât know how to set it up in configuration.yaml to get valid temp and humidity data. I tried
- platform: mqtt
state_topic: v3/mqtt-rpi3b@ttn/devices/eui-70b3d57ed004d338/#
name: "Temp DS"
value_template: '{{ value_json.uplink_message.decoded_payload.degreesC }}'
unit_of_measurement: "°C"
- platform: mqtt
state_topic: v3/mqtt mqtt-rpi3b@ttn/devices/eui-70b3d57ed004d338/#
name: "Hum_DS"
value_template: '{{ value_json.uplink_message.decoded_payload.humidity }}'
unit_of_measurement: "%"
But all I get is âunknownâ data. What might I be doing wrong?