Populate MQTT sensor with value - HOW?

Hello everyone,

after trying for quite some time, I am ready to give up.
I am trying to set up my bed sensor. The sensor is meant to send its data via MQTT.

I have created the following two sensors but they keep showing up as “unavailable”:

mqtt:
  sensor:
    - name: "Bed"
      state_topic: "home/bedroom/bed"
      unit_of_measurement: "kg"
      availability_topic: "home/bedroom/bed/available"
      availability_mode: latest
      value_template: '{{ value_json.bed | float }}'
      icon: "mdi:bed"
      qos: 0
      state_class: measurement 
      
    - name: "Bed Raw"
      state_topic: "home/bedroom/bed/raw"
      unit_of_measurement: "raw"
      availability_topic: "home/bedroom/bed/available"

The upper one looks more complicated but is only the result of me trying out different things.

I can get a value when I listen to the topic home/bedroom/bed. I can also see the sensor reporting when I use MQTT explorer.

But I do not know how to get the data into my sensor. The documentation does not help me as everything that is shown there, I have tried, in my opinion. Can anyone point to my mistake?

Thanks for the help

home-> bedroom → bed : 2 topics

open the 2 topics, and copy the value here, so we can see what the messages contain.

Apologies for the ambiguity.
“Bed” is the sensor I want. It only has a subtopic “raw” that is not really needed at the moment. I’d still try to create a sensor for “raw” as well as the instructions said it might come in useful. Even though I do not see how.

I think this is all that is needed.

mqtt:
  sensor:
    - name: "Bed"
      state_topic: "home/bedroom/bed"
      unit_of_measurement: "kg"
      icon: "mdi:bed"
      qos: 0
      state_class: measurement   

1 Like

I do not know which part of my additional attempts broke it, but I assume it has something to do with the availability part.
Oh well, it works now. Thank you for your help! I appreciate it :slight_smile: