I've created a thermometer sensor using an ESP8166 with MQTT to publish temperature updates. The JSON emitted is in the format:
{
"temperature": "53.4"
}
In Home Assistant, I created a sensor in configuration.yaml:
sensor:
- platform: mqtt
name: Backyard Temperature
unique_id: a1234
state_topic: home/temperature
value_template: '{{ value_json.temperature }}'
unit_of_measurement: F
The sensor is correctly sending the JSON payload, and MQTT subscriptions running on my desktop are receiving the updates, but the value is never updated on the Home Assistant dashboard (the state remains as the literal "Unknown").
Here's what the rendered group looks like. Odd there's a switch on the group heading.
Can anyone see what I'm missing? According to the documentation, I've done everything for this to work.
After uninstalling/reinstalling the Mosquitto broker, I realized that I hadn't checked the discovery option. With that set, it is working as expected. D'oh!