Hi there,
I’m now trying for hours to get that up and running and now complete lost any idea.
Here is the problem:
I’m sending via MQTT the following JSON payload:
{ "id": "01", "name": "WeatherStation", "sensors": [ { "id": "01", "type": "HUD21", "temperature": 26.09, "airPressure": 101573.00, "humidity": 12.09, "lightLevel": 45145.0, "batteryCharge": 12.09, "batteryVoltage": 12.12 }, { "id": "02", "type": "DHT21", "temperature": 26.09, "humidity": 56.73, "heatIndex": 34.22, "dewPointDHT": 34.22 } ] }
The message arrives in HA and I receive a number of error messages, that “Error parsing value: ‘value_json’ is undefined”.
However, if I use the template test configurator everything works fine. See picture below.
I tested various ideas in my configuration.yaml but nothing seems to work.
Here three different ideas:
-
platform: mqtt
name: “WeatherStation - Humidity - DHT”
state_topic: “WeatherStation/data”
unit_of_measurement: ‘%’
value_template: ‘{{ value_json.sensors.1.humidity }}’ -
platform: mqtt
name: “WeatherStation - Humidity - DHT”
state_topic: “WeatherStation/data”
unit_of_measurement: ‘%’
value_template: ‘{{ states.sensors.1.humidity }}’ -
platform: mqtt
name: “WeatherStation - HeatIndex - DHT”
state_topic: “WeatherStation/data”
unit_of_measurement: ‘HI’
value_template: ‘{{ states.sensor.sensors.1.heatIndex }}’ -
platform: mqtt
name: “WeatherStation - Dew Point - DHT”
state_topic: “WeatherStation/data”
unit_of_measurement: ‘°C’
value_template: “{{ value_json.state }}”
payload_available: “online”
payload_not_available: “offline”
json_template_attributes:
id: “{{ state.sensor.sensors.0.temperature }}”
Thanks for any hint!
Cheers
Stefan