I thought I’d share my experience here with configuring these sensors using MQTT. For the high level steps, since through my journey I found this wasn’t obvious and maybe there’s other ways I’m not aware of.
- Connect the DS18B20’s to the Shelly Addon
- My hardware has red/yellow/black wires which attach to terminals VCC/data/GND respectively
- Power it up, add the device using Shelly App on your phone, as usual for shellies.
- Confirm that the Shelly App now shows you one temperature per probe. If not, the rest of these steps aren’t going to work.
-
Install MQTT broker as an HA Addon, and restart HA
-
Install MQTT as an HA Integration, and restart HA
-
Connect to Web interface of Shelly device (Shelly Plus 1PM in my case)
-
Find the MQTT settings section, and enable MQTT, including following:
a) MQTT Control
b) RPC over MQTT
c) RPC status notifications over MQTT
d) Generic status update over MQTT -
Enter the IP Address of your HA (or where you installed the MQTT Broker)
-
Enter the username and password to authenticate to MQTT broker with. For me, this was a user I’d created already in HA (one benefit of installing the broker on your HA system)
- Add the following into your configuration.yaml file in the /config directory of HA.
mqtt: !include mqtt.yaml
- Create mqtt.yaml in that same /config directory and add your sensor definitions, for example:
sensor:
- name: "Probe 100"
state_topic: "shellyplus1pm-121212343434/status/temperature:100"
unit_of_measurement: "°C"
device_class: temperature
value_template: "{{ value_json.tC | round(1) }}"
payload_available: "online"
payload_not_available: "offline"
- name: "Probe 101"
state_topic: "shellyplus1pm-121212343434/status/temperature:101"
unit_of_measurement: "°C"
device_class: temperature
value_template: "{{ value_json.tC | round(1) }}"
payload_available: "online"
payload_not_available: "offline"
- name: "Probe 102"
state_topic: "shellyplus1pm-121212343434/status/temperature:102"
unit_of_measurement: "°C"
device_class: temperature
value_template: "{{ value_json.tC | round(1) }}"
payload_available: "online"
payload_not_available: "offline"
Name field is what ever friendly name you want to give the sensor.
The state_topic contains a device id and path details. I have shown an obfuscated device id, but you should see something very similar whilst connected to the Shelly web server in step 4 above, which for me shows up as both MQTT Prefix, and also Client ID in that screen. The path, /status/temperature:n is as per the API https://shelly-api-docs.shelly.cloud/gen2/Addons/ShellySensorAddon
BTW. Without that value_template line, you get all the JSON values sent by the shelly to the broker, and it would look something like:
{"id": 100,"tC":22.5, "tF":72.5}
That should also give you an idea about how to modify value_template if you prefer the Fahrenheit readings. Remember to adjust the other settings from Celsius too.
- Using HA developer tools, check the YAML configuration, and if okay, then load the settings by using the MANUALLY CONFIGURED MQTT ENTRIES link. Should get the green tick.
You can then go to entities, and find the newly created sensor, and see some values. One nice little debug I saw along the way, you can confirm if MQTT and broker receiving updates from your Shelly device, by going to HA Settings, Integration, MQTT, Configure, and scroll down to the “Listen to a topic” section. Try entering your valid state_topic (like in step 6) and hit the Start Listening button, see if you get values. New values are only sent when the temperature changes though, so it might take some time.
I think I remembered all the steps, but I encourage comments and suggestions if you feel there’s improvements/omissions here.
Thanks