Problem adding mqtt switch to Hassio

I am using the embedded mqtt. I have added the following to the configuration.yaml file:

mqtt:

switch:

  • platform: mqtt
    name: “Bedroom Switch”
    state_topic: “test/light2”
    command_topic: “test/light2/set”
    availability_topic: “test/light2/available”
    payload_on: “ON”
    payload_off: “OFF”
    optimistic: false
    qos: 0
    retain: true

I ran the CHECK CONFIG and it reported Valid.

When I restart HA i get the message INVALID CONFIG:

The following components and platforms could not be set up:
mqtt
switch.mqtt
Please check your config

What am I doing wrong?

Have you added a MQTT line to your configuration.yaml too? MQTT - Home Assistant.

Yes I added mqtt:

Did you install the MQTT add-on and did you use a username and password?

Yes I installed the Mosquito add on but I can’t remember if I used a username and password. I don’t think I did. I have one esp8266 device which reported it connected to mqtt and I didn’t use a username and password to set it up I just put in the IP address of the home assistant raspberry pi.

You should add MQTT this way then:

mqtt:
  broker: localhost
  port: 1883
  client_id: hassio
  keepalive: 60
  username: redacted
  password: redacted
  protocol: 3.1.1

Hi,
I am struggling trying to figure out how to create an user to MQTT in Hassio.
Could you please, help me pointing the directions?
Thanks!

I figured it out!

You should add the username and password in Hass.Io \ Mosquitto broker \ Options.

How? I see the config, but it’s cryptic. Where is there a username and password option?