DIY MQTT device not listed in entities list

Hi,
I’m stuck with a problem with DIY mqtt device becouse I have configured a MQTT light in the configuration.yaml file following the documentation, but the light is not visible in the entities list as expected and I cannot add the widget in the dashboard.
Here my configuration.yaml file:


# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes
http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.30.33.0/24
# Text to speech
tts:
  - platform: google_translate

mqtt:
  light:
  - name: alogenasalotto
    state_topic: "home/sala/alogena"
    command_topic: "home/sala/alogena/set"
    payload_on: "ON"
    payload_off: "OFF"
    optimistic: false
    qos: 0
    retain: true


automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

The light is only on/off, not dimmerable.

I use hassio with version versions: Home Assistant 2023.8.4 Supervisor 2023.08.1 Operating System 10.5

Could you help me? Could you suggest me the right procedure to add an mqtt device?

Thanks a lot
Fabio

According to the example in the documentation, it should be like this:

mqtt:
  - light:
      name: alogenasalotto
      state_topic: "home/sala/alogena"
      command_topic: "home/sala/alogena/set"
      payload_on: "ON"
      payload_off: "OFF"
      optimistic: false
      qos: 0
      retain: true

If this is the first MQTT entity you have ever added to your system, you need to restart Home Assistant so that it will create it

Thank you for the reply, but it still not working. I’ve also tried to put the example of mqtt switch in the configuration file, but the switch is not added as entity and I can’t setup it in the widget in the dashboard.

Post the new MQTT configuration you have created and check the Log for any errors related to your MQTT configuration.

It’s the example in the documentation

mqtt:
  - switch:
      unique_id: bedroom_switch
      name: "Bedroom Switch"
      state_topic: "home/bedroom/switch1"
      command_topic: "home/bedroom/switch1/set"
      availability:
        - topic: "home/bedroom/switch1/available"
      payload_on: "ON"
      payload_off: "OFF"
      state_on: "ON"
      state_off: "OFF"
      optimistic: false
      qos: 0
      retain: true

I didn’t find any errors in the logs. I’have also changed the log level to debug, but nothing usefull.

I have solved the problem. The problem was that I have not activated/configurated the integration of mqtt as described here, but only installed the mqtt broker. Thank you for the help.

I didn’t ask if you had installed the MQTT integration because I thought it was self-evident. Without it, Home Assistant cannot communicate via MQTT or create MQTT entities.