MQTT Sensor no value - spaces in topic?

I configured a sensor like this but it shows no values:

   - name: "Temperature Heizung"
     state_topic: "1-Wire-Gateway/Bus 2/Sensor 2"
     unit_of_measurement: "°C"
     value_template: "{{value_json.temperature}}"

I couldn’t find the error.
in mqtt the topic name is:

1-Wire-Gateway/Bus 2/Sensor 2 

(I can’t customize it)

The MQTT-source is the following device called “WLAN /LAN Gateway Modbus TCP/IP für 1-Wire Temperatur Sensoren” (
It worked formerly in another HomeAutomation-Software (FHEM) - So I think it’s either a non valid configuration in HomeAssistant by me or an error in the module. Maybe the spaces-character in the topic are not supported. But I can’t customize it, so I have to make it work with the spaces.


Screenshot 2

As always: Sorry for bad english :smile:

Hi Bernd - welcome to the Home Assistant forums. In order for people to help you with your issue, can you edit your post so the yaml is inside preformatted text tags? These are accessed by clicking on the </> symbol in the toolbar when editing. You’ll end up with text formatted like this:

  - text
    in here :)

Also please post the json data for your sensor from MQTT Explorer - again inside the correct tags. Since yaml is position sensitive it just assists people in reading and checking.

Lastly have a read of this post - it mentions using text tags as well as other helpful stuff: How to help us help you - or How to ask a good question - #3

Thanks for the formatting-advice. Maybe now it’s readable.

Change the following line in the MQTT Sensor’s configuration:

     value_template: "{{value_json.temperature}}"

to this:

     value_template: "{{ value[:-3] }}"

According to the screenshot of MQTT Explorer, the payload published to the topic 1-Wire-Gateway/Bus 2/Sensor 2 is not in JSON format. The payload is merely a string like this:

25.50 °C

What you want is just the numeric part of the value (25.50) so that’s why I suggest you use:

{{ value[:-3] }}

because it slices off the payload’s last 3 characters.


Thank you, Taras! Tested, workes :slight_smile:

1 Like