Shelly Plus 1PM with Add-on and DS18B20 temperature sensor help

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.

  1. 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.
  1. Install MQTT broker as an HA Addon, and restart HA

  2. Install MQTT as an HA Integration, and restart HA

  3. 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)

  1. Add the following into your configuration.yaml file in the /config directory of HA.
mqtt: !include mqtt.yaml
  1. 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.

  1. 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

2 Likes

It works!!

I’d like to add why I did struggle a bit to log in to the MQTT broker. The problem was the port selection, which I first had to search for in Home Assistant.

Many thanks!
Br,
Steven

1 Like

I’m struggling to configure a simple reed on addon digital in.

Do you have any idea how should be yaml configuration? Just want to check when garage door is open or closed.

Thanks

I’ve only done temperature sensors, so not sure if it also is similar for your binary situation. What hardware are you using and how is it connected? Are you using this Shelly Add-on? https://www.shelly.com/en/products/shop/shelly-plus-add-on

Yes, using that one.

Ok. And what is the sensor type?

Reed sensor, connected as digital. Peripheral is a button due to main Shelly 1+ being configured as momentary press.

So does it expose its open/close state through MQTT? You need to follow through the MQTT configuration steps with broker too.

Can you see the state of the reed sensor in the shelly app, as the sensor opens and closes?

Opened a new post with all info. Let me know if more is required.

I’m using mosquitto.org for connectivity over MQTT. Unfortunately, the Shelly Add-On has some issues. The temperature sensor works because the DS18B20 probe is an active device. However, I’m using a pressure sensor which outputs an analog voltage to the Add-On’s ADC. The Add-On fails to send an updated value. Not good. Doesn’t send raw values and only sends a “percentage”. I can send the same data using an Ardunio ESP32 Uno, so looks like I’ll have to dump all the Shelly hardware!

That sounds like a different use case. It might be best to describe your use case and issues in a new thread so others may assist you.