MQTT sensor Temperature GPU

Hello everybody,

I have a problem with mqtt sensor and the temperature of GPU from my Pi.

First, I’m running Home Assistant 0.190.4 with docker on a Raspberry Pi3B+. Mosquitto is installed on this Pi and I have a script for publish the temperature of the GPU on a topic.

When I listen to the topic from the developer tools MQTT, I can see the value (temp=50.1’C for example)

In my configuration.yaml, I declare a mqtt sensor with a value_template like this
'{{ value | replace("temp=", "") | replace("''C", "") }}'

but the value show permanently unknown.

Anybody for any ideas?

Thanks

It would help if we knew what you receive on that topic. You do a lot of replace, but we don’t know the original.

The value that I receive is like
temp=58.1'C

This is the result of the command
/opt/vc/bin/vcgencmd measure_temp

Do you have the mqtt topic correct?

Can we see your full sensor config?

Yes the topic is correct, it’s work when I listen to the topic from the mqtt developers tools

Here is my complete config for this sensor

sensor:
  - platform: mqtt
    name: Temperature GPU
    state_topic: raspberry/temperature/GPU
    unit_of_measurement: "°C"
    value_template: '{{ value | replace("temp=", "") | replace("''C", "") }}'

Capture

Your state topic is incorrect.

This:

state_topic: raspberry/temperature/GPU

is not the same as this:

state_topic: raspberry/temperature/gpu

Capitalisation is important.

This is the solution.
Tank you!