MQTT Shelly

Hi.
I’m a MQTT-newbie and have a question.

How do I get the temperature data (tC) into HA ?
This is from MQTT explorer :

{
    "id": 123,
    "src": "shellyplus1pm-a8032abe3b04",
    "dst": "shelly4hass",
    "result": {
        "ble": {},
        "cloud": {
            "connected": true
        },
        "input:0": {
            "id": 0,
            "state": false
        },
        "mqtt": {
            "connected": true
        },
        "switch:0": {
            "id": 0,
            "source": "SHC",
            "output": true,
            "apower": 2998.2,
            "voltage": 234.2,
            "current": 14.256,
            "aenergy": {
                "total": 20736.977,
                "by_minute": [
                    19891.172,
                    49588.504,
                    6505.53
                ],
                "minute_ts": 1643644343
            },
            "temperature": {
                "tC": 75.2,
                "tF": 167.4
            }
        },

One possibility would be adding this to your sensor.yaml:

- platform: mqtt
  state_topic: 'Your state topic from MQTT explorer here'
  name: 'Your desired sensor name here'
  value_template: '{{ value_json.result["switch:0"].temperature.tC }}'

Thanks for your reply ! :slight_smile:

I couldnt get it to work, but i ended up with a working code after some testing :

- platform: mqtt
  state_topic: "shellyplus1pm-vvb/status/switch:0"
  name: "VVB temperatur"
  unit_of_measurement: "°C"
  value_template: '{{ value_json.temperature.tC }}'