How to show a zigbee2mqtt payload on a dashboard

Hi, I’am new to HA and I made a homemade zigbee device with a input ( button ) and a output (led) and a input value that shows the battery voltage. I paired the device and the button and led is working prefect in my automation. The voltage I don’t find as a entity. But I can see the voltage in → settings → device → “devicename” → devive info → MQTT info → if I go then to the 10 most recently received message(s) I get the info:

  • Received 16:26:02

    • QoS: 0
    • Payload:

click: null
l2: 3.24
linkquality: 183
state_l1: ‘OFF’
voltage_l2: 3.2

  • Received 16:26:02

    • QoS: 0
    • Payload:

click: null
l2: 3.24
linkquality: 183
state_l1: ‘OFF’
voltage_l2: 3.2

  • Received 16:27:02

    • QoS: 0
    • Payload:

click: null
l2: 3.24
linkquality: 183
state_l1: ‘OFF’
voltage_l2: 3.2

You can see that there is no click on the button, l2 is the voltage of 3.24V, state_l1 is the led = OFF
and the voltage_l2 is 3.2V is the rounded value of l2.

Now I like the set the voltage on my dashboard, but I don’t find that entity in home assitant.

How can I do that?
Many thanks

Check on your device info if it is a disabled sensor.

I had a look at the device and the sensor is enabled. But now I see that the voltage is a attribute of the click entity. If i use the click entity I see only if I click on the button and not the voltage value. How can I see an attribute of an entity?

So , the info received from MQTT is from the click entity : and there is also the voltage as attribute

  • Received 16:26:02
    • QoS: 0
    • Payload:

click: null
l2: 3.24
linkquality: 183
state_l1: ‘OFF’
voltage_l2: 3.2

see also picture:

vis

Can you look with mqtt explorer (https://mqtt-explorer.com/) on what topic you receive that message, and post the actual json ?

Visvoeder = {“click”:null,“l2”:3.18,“linkquality”:191,“state_l1”:“OFF”,“voltage_l2”:3.2}

so try this, under mqtt:

  sensor:
    - name: "visvoeder "
      state_topic: "Visvoeder"   
      value_template: >- 
        {{ value_json.voltage_l2 }}
      unit_of_measurement: 'V'
      unique_id: "visvoeder_voltage"     

I added it to configuration.yaml and restart HA. Now I have to wait…

Everything is back in HA
If I go to developer tools then I see :

The visvoeder is unknown ???

if there was no message yet, it will be unknown until the first message received.

yes there is already defferent messages

vis

I changed the “voltage_l2” to “l2” to see if I can change to the other attribute. But I get also unknown.

  sensor:
    - name: "visvoeder "
      state_topic: "Visvoeder"   
      value_template: "{{ value_json.voltage_l2 }}"
      unit_of_measurement: 'V'
      unique_id: "visvoeder_voltage"        

afbeelding

I still have the same unknown value.
In MQTT explorer I put also the json file to publish and still unknown value as result.

it looks that it is working with you, but here still the same.

can it be in the configuration.yaml that I made a mistake?

 How can you send a piece of yaml code, so that it looks good?

Format your code properly:

    
mqtt:
  sensor:
    - name: "Kwartverbruik sim"
      state_topic: "sm/kwsim"
      qos: 0
      unit_of_measurement: "W15min"
    - name: "spanning L1"     
      state_topic: "sm/kwL1"
      qos: 0
      unit_of_measurement: "V"
    - name: "spanning L3" 
      state_topic: "sm/kwL3"
      qos: 0
      unit_of_measurement: "V"
    - name: "energy used" 
      state_topic: "sm/dagU"
      qos: 0
      unit_of_measurement: "Wh"  
      state_class: total
      device_class: energy
    - name: "energy returned" 
      state_topic: "sm/dagR"
      qos: 0
      unit_of_measurement: "Wh"  
      state_class: total
      device_class: energy  
    - name: "Gas teller" 
      state_topic: "sm/gas"
      qos: 0
      unit_of_measurement: "m³"
      state_class: total
      device_class: gas    
    - name: "regenwaterput" 
      state_topic: "rw/proc"
      qos: 0 
      unit_of_measurement: "%"
    - name: "tvlift" 
      state_topic: "tv/op-neer"
      qos: 0   
    - name: "visvoeder"
      state_topic: "Visvoeder"   
      value_template: "{{ value_json.voltage_l2 }}"
      unit_of_measurement: 'V'
      unique_id: "visvoeder_voltage" 

This is what is in my cofiguration.yaml under MQTT

you are sure the state_topic is Visvoeder, and not visvoeder ? MQTT is case-sensitive.

this is wat mqtt explorer gives: