Unable to create the entities (MQTT)

Hello,
I have a problem again.
I would like to read out my “xiaomi flower sensor” via Bluetooth with the help of a Zero-W.
These values should then be sent to HA via MQTT.
So far, a lot of things work but unfortunately I can’t manage to create the entities.
For example, when I read out the MQTT data with Node-Red, I get all the information I want.

However, I cannot create the sensor in configuration.yaml so that I can use the data.
Does anyone have a tip or an idea how the configguration.yaml must look so that I can use the data?
Many thanks in advance.

Christoph

Here is another picture of the MQTT data received on the HA.

and here also from the MQTT Explorer

You need to create an MQTT Sensor. You can do that by adding the following in configuration.yaml in the sensor: section of the file.

sensor:
  - platform: mqtt
    name: MiFlora 5
    state_topic: miflora/Sensor05
    value_template: "{{ value_json.moisture }}"
    json_attributes_topic: miflora/Sensor05
  1. Save the file and then execute Configuration > Server Controls > Check Configuration.
  2. If it does not report any errors, execute Configuration > Server Controls > Reload manually configured MQTT entities

Initially the sensor’s value will be unknown however as soon as your Node-Red flow publishes a new payload, the sensor will display information that will look something like this in Developer Tools > States:

Screenshot from 2021-04-07 12-39-14

1 Like

Fantastic, that helped, I have no idea what I have tried so far without success. :+1:
I was probably too impatient afterwards and didn’t wait long enough for new data to arrive.

Now, of course, I have another question:
However, it is not so urgent and is more cosmetic in nature.
Can I also create a Lovelace Card in this way? All the data is supplied under Attributes.
Thank you very much for your competent and quick help.

1 Like

Yes, you can use the Entities card which allows you to display an entity’s state value or the value of any of its attributes.

It would look something like this:

      - type: entities
        title: Flower Sensor 5
        show_header_toggle: false
        entities:
          - type: attribute
            entity: sensor.miflora_5
            attribute: moisture
            name: Soil Moisture
            icon: 'mdi:water'
          - type: attribute
            entity: sensor.miflora_5
            attribute: temperature
            name: Temperature
            icon: 'mdi: thermometer'
          - type: attribute
            entity: sensor.miflora_5
            attribute: light
            name: Light Level
            icon: 'mdi:brightness-5'
          - type: attribute
            entity: sensor.miflora_5
            attribute: conductivity
            name: Conductivity
            icon: 'mdi:lightning-bolt'
          - type: attribute
            entity: sensor.miflora_5
            attribute: battery
            name: Battery Level
            icon: 'mdi:battery'
1 Like

Wow that’s a perfect, quick and convenient answer.
Many, many thanks.
However, I still have a small error in the view.

Only the moisture value is displayed.
I will try a little more until I hopefully get it right.

views:
  - title: main
    icon: mdi:home-outline
    cards:
     - type: glance
       title: Flower Sensor 5
       show_header_toggle: false
       columns: 5
       entities:
          - type: attribute
            entity: sensor.miflora_5
            attribute: moisture
            name: Soil Moisture
            icon: 'mdi:water'
          - type: attribute
            entity: sensor.miflora_5
            attribute: temperature
            name: Temperature
            icon: 'mdi:thermometer'
          - type: attribute
            entity: sensor.miflora_5
            attribute: light
            name: Light Level
            icon: 'mdi:brightness-5'
          - type: attribute
            entity: sensor.miflora_5
            attribute: conductivity
            name: Conductivity
            icon: 'mdi:lightning-bolt'
          - type: attribute
            entity: sensor.miflora_5
            attribute: battery
            name: Battery Level
            icon: 'mdi:battery'

You changed it from an Entities card to a Glance card (which doesn’t support attributes).

1 Like

All because I didn’t work accurately enough.
Now it works.
You are my personal hero, thank you :+1:

1 Like