Hi! I've got a case where my MQTT produces following JSON:
{
"Information": {
"Model": "Fineoffset-WH2",
"ID": 151
},
"Metadata": {
"mic": "CRC",
"mod": "ASK",
"freq": 433.9912,
"rssi": -0.0843086,
"snr": 7.21689,
"noise": -7.3012
},
"Measurements": {
"Temperature": 24.5,
"Humidity": 67
}
}
Is there a way how I could include all the values of the Metadata so that they Key is used for the name and value of course for the value, instead of doing all individually?
The current way how I've implemented the Measurements, are individual methods, as shown here:
sensor:
- name: "Temperature"
state_topic: "si"
unique_id: "Storage_Temperature"
value_template: "{{ value_json.Measurements.Temperature }}"
unit_of_measurement: "°C"
device_class: "temperature"
device:
name: "Storage Temperature sensor"
manufacturer: "Telldus"
identifiers: "Storage Temperature Sensor"
model: "313159"
- name: "Humidity"
state_topic: "si"
unique_id: "Storage_Humidity"
value_template: "{{ value_json.Measurements.Humidity }}"
unit_of_measurement: "%"
device_class: "humidity"
device:
name: "Storage Temperature sensor"
manufacturer: "Telldus"
identifiers: "Storage Temperature Sensor"
model: "313159"