A sketch for an ESP 8266 based micro controller and an DS18B20 temperature sensor to measure the temperature of a pond or pool using Home Assistant and MQTT.
I use the Mosquitto Broker which fits my requirements perfectly. You can also find an official Docker Image of it. I recommend a GUI based client like MQTT Explorer or MQTT.fx for testing purposes.
Once the sensor is running, you'll find three new topics on your broker:
(see also: MQTT Discovery) homeassistant/sensor/sensorPondT/config
{
"device_class":"temperature",
"name":"Pond Temperature",
"object_id":"pond_temperature",
"state_topic":"homeassistant/sensor/sensorPondT/state",
"availability_topic":"homeassistant/sensor/sensorPondT/status",
"json_attributes_topic":"homeassistant/sensor/sensorPondT/attributes",
"unit_of_measurement":"°C",
"value_template":"{{ value_json.temperature}}"
}
homeassistant/sensor/sensorPondT/state
{"temperature":14.9375}
This topic imcludes additional attributes which will be added to the configured sensor. "homeassistant/sensor/sensorPondT/attributes"
{
"battery_voltage":2.9455078125,
"battery_status":89.2578125,
"RSSI":-81
}
This indicates if the sensor is availble or not.
homeassistant/sensor/sensorPondT/status
online | offline
- type: gauge
entity: sensor.pond_temperature
name: Pond Temperature
unit: "°C"
needle: true
min: -5
max: 35
severity:
red: 0
yellow: 10
green: 20