MQTT sensor from MQTT

I want to make an MQTT sensor from a MQTT message, I tried to make an yaml mqtt sensor, but I can’t get is to work

I get this message from my MQTT broker,

Message 85 recieved on Heatpump at 15:58

{
“devices”: "A,
“payload”: {
“Input”: 27.56,
“Output”: 23.94,
“Flow”: 0.17,
“Watt”:2593
}
}

Hello smitexgithub,

Thanks for coming here and asking a question.
Would you be so kind as to adjusting the format of your code so that we can read it properly & check the YAML spacing, etc. Editing your original is the preferred way. It is very hard for us to tell what is what when the text formatter jumbles everything like that.
Use the </> button or this:
Here is an example of how to fix it from the site FAQ Page.
How to help us help you - or How to ask a good question.

What is the MQTT topic and which value should the sensor display? Input, Output, Flow, or Watt?

Example

mqtt:
  sensor:
    - name: Heat Pump Power
      unique_id: hp_pwr_abc123
      state_topic: your/mqtt/topic
      value_template: "{{ value_json.Payload.Watt }}"
      device_class: power
      unit_of_measurement: W

i want to see all of them but first I want to find out how it works. I already managed to see some values from my Espeasy units, so that works

this is what I see in MQTT Explorer, and I want to use Heatpump and all the devices to Input, Output, flow and Watt, I hope you can help

mqtt:
  sensor:
    - name: Heat Pump Power
      unique_id: hp_pwr_abc123
      state_topic: Heatpump
      value_template: "{{ value_json.Payload.Watt }}"
      device_class: power
      unit_of_measurement: W
      json_attributes_topic: Heatpump
      json_attributes_template: "{{ value_json.Payload | tojson }}"

Reference

MQTT Sensor

Thanx 123 Taras,
unfortunaly I can’t see any values in the sensor. The enetity Heat Pump Power is made, but it gives an Unknown. Do I have to do something with “devices”,“A”???


see picture

Sorry, that’s my mistake. On closer inspection of your MQTT Explorer screenshot, I see that the key word is payload not Payload.

mqtt:
  sensor:
    - name: Heat Pump Power
      unique_id: hp_pwr_abc123
      state_topic: Heatpump
      value_template: "{{ value_json.payload.Watt }}"
      device_class: power
      unit_of_measurement: W
      json_attributes_topic: Heatpump
      json_attributes_template: "{{ value_json.payload | tojson }}"

Simply change it in your MQTT Sensor’s configuration then execute Developer Tools → YAML → Reload Manually Configured MQTT Entities.

Hello, 123 Taras,
I have made the correction and it works, Thanx very much, I was searching for this answer a very long time, THANX, Greetz Peter

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.