How to get a special value from an MQTT Topic

Hi,

I have a Shelly HT where I want to show the Temperature in HomeAssistant.

With an MQTT Browser I was able to find the Topic:

shellyplusht-gartenhuette/status/temperature:0

image

How can I get now the Temperature in “Celsius” to HomeAssistant?

Best Regards,
Johannes

Create an MQTT sensor -

using:

mqtt:
  sensor:
    - name: "My Temperature"
      state_topic: "shellyplusht-gartenhuette/status/temperature"
      value_template: "{{ value_json['tC']|float(0) }}"
      device_class: temperature
      state_class: measurement
      unique_id: mytemp-f1cbba8a-ba45-47c6-a05a-1fc52cfa3215
      unit_of_measurement: "°C"

Thanks,

I just had to tweak it a bit and add a :0 to the topic.

    - name: "Gartenhuette_Temperatur"
      state_topic: "shellyplusht-gartenhuette/status/temperature:0"
      value_template: "{{ value_json['tC']|float(0) }}"
      device_class: temperature
      state_class: measurement
      unique_id: mytemp-f1cbba8a-ba45-47c6-a05a-1fc52cfa3215
      unit_of_measurement: "°C"

Br,
Johannes

1 Like

Yeah I wasn’t sure if that was part of the topic or not. It’s not a typical way of doing an MQTT topic.

How do I read out the battery (percent)?

image

Br,
Johannes

{{ value_json['battery']['percent']|int(0) }}
    - name: "Gartenhuette_Battery"
      state_topic: "shellyplusht-gartenhuette/status/devicepower:0"
      value_template: "{{ value_json['battery']['percent']|int(0) }}"
      device_class: battery
      state_class: measurement
      unique_id: mybattery-089acdc1-9f7d-4a2d-87b2-f3894ac3b824
      unit_of_measurement: "%"