Created a sensor but can't find it in the GUI

Probably a noob question but as I’m not yet very experienced with HA I’ll have to ask before I bang my head against the wall

I’ve created a NodeRed flow to read M-Bus Meters and export their data to MQTT:


Data is visible in MQTT:

 # https://www.home-assistant.io/integrations/sensor.mqtt/
 
 mqtt:
   sensor:
     - name: "Apartment Energy Meter - Total"
       unique_id: "apartment_energy_meter_total"
       state_topic: "mbus/apartment/sensor"
       value_template: "{{ value_json.sn.MeterReading.total }}"
       unit_of_measurement: "kWh"
       device_class: energy
       device:
         name: "Apartment Energy Meter"
     - name: "Benito Energy Meter - Total"
       unique_id: "benito_energy_meter_total"
       state_topic: "mbus/benito/sensor"
       value_template: "{{ value_json.sn.MeterReading.total }}"
       unit_of_measurement: "kWh"
       device_class: energy
       device:
         name: "Benito Energy Meter"

Now I’ld expect to see an entity, but none show’s even though I’ve restarted a few times. If I search entities or devices for ‘benito’ or ‘apartment’ I get nothing…

please tell me wtf I’m havin my noob moment … LOL

state_topic: "mbus/apartment/sensors"

Same for the other topic.

The entities should still exist though. Just with a state of unknown and they would have generated errors in Settings → System → Logs.

Also if this is the first time you have used the mqtt sensor integration you will need to restart HA.

There is a list of all entities in Developer Tools → States as well as Settings → Devices & Services → Entities.

1 Like

Hi Tom, thanks for your reply…

What are you telling me with the marking in the screenshot and your comment ‘Same for the other topic’?


I’ve choosen ‘sensors’ because Tasmota does it like that as well…

EDIT: Big extraloud LOL… What a classic! Now that I checked the configuration.yaml again I saw my typo!!! But sadly still nothing after another restart :frowning:

Bildschirmfoto 2024-10-12 um 2.34.03 PM

Are there any relevant errors in Settings → System → Logs?

Yes it does:

Logger: homeassistant.components.mqtt.entity
Quelle: components/mqtt/entity.py:329
Integration: MQTT (Dokumentation, Probleme)
Erstmals aufgetreten: 14:41:43 (2 Vorkommnisse)
Zuletzt protokolliert: 14:41:43

Device must have at least one identifying value in 'identifiers' and/or 'connections' for dictionary value @ data['device'] for manually configured MQTT sensor item, in /config/configuration.yaml, line 18 Got {'name': 'Apartment Energy Meter - Total', 'unique_id': 'apartment_energy_meter_total', 'state_topic': 'mbus/apartment/sensors', 'value_template': '{{ value_json.sn.MeterReading.total }}', 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'device': {'name': 'Apartment Energy Meter'}}
Device must have at least one identifying value in 'identifiers' and/or 'connections' for dictionary value @ data['device'] for manually configured MQTT sensor item, in /config/configuration.yaml, line 26 Got {'name': 'Benito Energy Meter - Total', 'unique_id': 'benito_energy_meter_total', 'state_topic': 'mbus/benito/sensors', 'value_template': '{{ value_json.sn.MeterReading.total }}', 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'device': {'name': 'Benito Energy Meter'}}

I will search for the string:

Device must have at least one identifying value in 'identifiers' and/or 'connections' for dictionary value

and report back…

Or just delete these lines from your config:

       device:
         name: "Apartment Energy Meter"

and

       device:
         name: "Benito Energy Meter"

Thanks a lot @tom_l

Found my solution here

# https://www.home-assistant.io/integrations/sensor.mqtt/
 
 mqtt:
   sensor:
     - name: "Apartment Energy Meter - Total"
       unique_id: "apartment_energy_meter_total"
       state_topic: "mbus/apartment/sensors"
       value_template: "{{ value_json.sn.MeterReading.total }}"
       unit_of_measurement: "kWh"
       device_class: energy
       device:
         name: "SBC AWD3D5W10"
         identifiers: energymeterapartment
         manufacturer: SaiaBurgess
         model: AWD3D5W10
     - name: "Benito Energy Meter - Total"
       unique_id: "benito_energy_meter_total"
       state_topic: "mbus/benito/sensors"
       value_template: "{{ value_json.sn.MeterReading.total }}"
       unit_of_measurement: "kWh"
       device_class: energy
       device:
         name: "NZR DHZ 5/63"
         identifiers: energymeterbenito
         manufacturer: NZR
         model: 'NZR DHZ 5/63'

And have finally moved the above snippet to it’s own file:

 sensor: !include sensors.yaml

P.S.: for those interested: I’ve shared my NodeRed Flow in this thread.

1 Like

@tom_l

now that I moved it into sensors.yaml being included via:

sensor: !include sensors.yaml

from configurations.yaml it seems to have disappeared… WTF am I not getting here?

That config is not part of the sensor: integration. It is part of the mqtt: integration. Everything in your configuration.yaml file that is hard up against the left hand margin is a separate integration.

You can do this:

in configuration.yaml

mqtt: !include mqtt.yaml

then put the config (minus the first line, mqtt:, in that file (which you will have to create).

Thanks a ton @tom_l

configuration.yaml is now clean:

 # Loads default set of integrations. Do not remove.
 default_config:
 
 # Load frontend themes from the themes folder
 frontend:
   themes: !include_dir_merge_named themes
 
 automation: !include automations.yaml
 script: !include scripts.yaml
 scene: !include scenes.yaml
 sensor: !include sensors.yaml
 mqtt: !include mqtt.yaml
 template: !include templates.yaml

and mqtt.yaml is like this:

 ---
 # https://www.home-assistant.io/integrations/sensor.mqtt/
 
 #mqtt:
   sensor:
     - name: "Apartment Energy Meter - Total"
       unique_id: "apartment_energy_meter_total"
       state_topic: "mbus/apartment/sensors"
       value_template: "{{ value_json.sn.MeterReading.total }}"
--- lines cut ---

Mind the commented “#mqtt:

1 Like