Newbie needs help with mqtt configuration

Hi, I am switching from iobroker to homeassistant. In iobroker mqtt topics are automatically discovered, but in homeassistant this does not seem to be the case.
I need to get data from a mqtt publisher.
The topic is smartyreader_enovos/act_pwr_imported_p_plus, and the payload is
{"act_pwr_imported_p_plus_value":1.58,"act_pwr_imported_p_plus_unit":"kW"}

So what I try since 2 days, is to read these data into homeassisatnt
in my configuration.yaml file I added the following

mqtt: 
  sensor: !include_dir_merge_list mqtt/sensor/
  binary_sensor: !include_dir_merge_list mqtt/binary_sensor/
  switch: !include_dir_merge_list mqtt/switch/
  light: !include_dir_merge_list mqtt/light/

then I created the folder mqtt, with the subfolders sensor, binary_sensor, switch and light.

I the create the file /homeassistant/mqtt/sensor/Power_mqtt.yaml .
So my expectation is that this file will be read upon restart
The content of the file is the following

sensor:
  - name: "Enovos_import_power_act"
    unique_id : enovos_act_power_consumption
    state_topic: "smartyreader_enovos/act_pwr_imported_p_plus"
    value_template: "{{ value_json.act_pwr_imported_p_plus_value }}"
    unit_of_measurement: "kW" 

so I think I should see a device cakked Enovos_import_power_act, but I do not see it.
I switched on debug mode in mqtt, and checked the los, but I do not see anything

does anyone knows where the pronlem comes from ?
also, can I group different sensors in different files ? The enovos device sends about 40 topics, so I need to read them all, and then i have several devices like these.
Can I create different yaml files, all starting with sensor: if not, how to split the configuration in different files

Is that topic retained?
If not, HA will only update the value of the sensor once a payload is published, and only once.

hi, thanks.
the payload is send every minute, but is not retained.
How do I see if the configuration file is taken into account ?
Is my configuration in the configuration yaml file correct ?
If so, do I have to add sensor: at the top of every configuration file in the folder mqtt/sensor ?
I guess that I should see the sensor in the devices, or the entities list when it is correctly configured ?

Now that you mention it, no.
You didn’t get errors in the logs?

no erors in the logs

i changed content of the mqtt config file to


- name: "Enovos_import_power_act"
  unique_id : enovos_act_power_consumption
  state_topic: "smartyreader_enovos/act_pwr_imported_p_plus"
  value_template: "{{ value_json.act_pwr_imported_p_plus_value }}"
  unit_of_measurement: "kW"

so without sensor:

still no device/entitie, and still no error in the logs. I also activated debugging in mqtt , should I see more details in the logs, or are debugging information stored elsewhere ?

you should try installing the Home Assistant MQTT Explorer addon to check these MQTT topics and sensors

It is this that is the problem

There is a thread on the forum that explains how to use it, but I can’t find it right now.

indeed when using

sensor: !include_dir_merge_list mqtt/sensor/

in the configuration yaml file, in the mqtt.yaml file i should not add the line

sensor:

but start with the list of names like this

- name: "Enovos_import_power_act"
  unique_id : enovos_act_power_consumption
  device_class: energy
  state_topic: "smartyreader_enovos/act_pwr_imported_p_plus"
  value_template: "{{ value_json.act_pwr_imported_p_plus_value }}"
  unit_of_measurement: "kW"
- name: "Enovos_import_energy"
  unique_id : enovos_energy_consumption
  device_class: energy
  state_class: total_increasing
  state_topic: "smartyreader_enovos/act_energy_imported_p_plus"
  value_template: "{{ value_json.act_energy_imported_p_plus_value }}"
  unit_of_measurement: "kWh"

thanks for everybody’s help