Your manually configured MQTT (Everything) needs attention. - when using !include

The new version of Home Assistant needs an update to MQTT, and its kind of nice that it gives a warning:

Now, I found this thread which gives the solution:

Unfortunately, this solution does not work in my case.

Why not?

I have a lot of MQTT Devices. So I do things in my configuration.yaml like:

##########
# SENSOR #
##########
  
sensor: !include sensor.yaml

#mqtt:
#  broker: core-mosquitto
 # broker: a0d7b954-mqtt
 # port: 1883   
 # username: mqtt_user
 # password: !secret mqtt_password
 # client_id: home-assistant

mqtt: !include mqtt.yaml
# binary_sensor:
#    name: "Laserjet_4000 Print Queue"
#    payload_on: "ON"
#    state_topic: "hass/printers/Laserjet_4000"
  

Notice how I have an include for my sensor.yaml - and I also created a net-new mqtt.yaml to follow the new format requirements for mqtt. Finally, I commented out my mqtt devices, and moved every single mqtt device I have into mqtt.yaml, which contains lines like:

#############
# MQTT YAML #
#############

switch:
   name: "Bedroom Fan"
   command_topic: "cmnd/bedroomfan/power"  # Need to change "sonoff" later as I add more of these.
   state_topic: "stat/bedroomfan/POWER"
   qos: 1
   payload_on: "ON"
   payload_off: "OFF"
   retain: false

But this does not work.

It passes the YAML check and should nest as:

mqtt:
  switch:
    name: "Bedroom Fan"
    ...

Which I believe should be valid, and should work according to the new format. Unfortunately, doing this clears the warnings completely - and completely breaks every MQTT device I have so that they never load.

I have been googling, and going through the docs, and I am a bit at a loss for how to migrate my MQTT devices to the new stuff - and maintain includes to keep my code organized. I don’t really want to have one giant configuration.yaml file.

I am obviously missing something, but I cant figure out what it is.

No error in your log file?

Nothing error related to MQTT, no.

I will configure it again (I had to revert) and re-run it and check Splunk.

I wouldn’t worry too much. I have the same messages, for Sensor(s), light(s) and switch(s).
As I’ve long ago reformatted my configuration.yaml to the new syntax, as defined here, I can
only assume that these are false positives.

My YAML Syntax was off. This post had the details I needed to get it sorted out. I needed to nest like with like, and only put the names in the configuration.yaml itself.

Well, it seems I was wrong. I thought everything looked fine after a core restart but:

There is nothing in the logs to indicate anything is wrong. The YAML passes the checks from the Dev Console. Guess I will have to restore from backup and try again.

Well, I think I found the problem. It was the yaml syntax and spacing, and the solution is going to suck. By way of example:

What I did:

###################
# Upstairs Washer #
###################

   name: "Washer State"
   state_topic: "hass/state/washer"
   icon: mdi:washing-machine

What I SHOULD have done:

###################
# Upstairs Washer #
###################

  - name: "Washer State"
    state_topic: "hass/state/washer"
    icon: mdi:washing-machine

It is subtle, but the spacing in the first paragraph is wrong (AND I forgot the dash), so while it passed the YAML code check, it never actually loaded. The second one works.

However, the suckage, is that I have a ton of sensors that now have bad YAML indentation, and I will need to go through them one by one until the syntax works. At least I get a generic error now, so that gives me something to start with.

At least all my MQTT switches loaded without issue once I realized my mistake.

The Config check is pretty simple.
If you want to be sure Home Assistant itself will load properly after restart - a better option is - to use the SSH and Web Terminal add-on.

Open the Web Terminal and type:

ha core check

It should take at least 10x longer than the Check Config button - and will either return “OK” or a list of errors.

EDIT: Fixed command

1 Like

All works now, and that ha core check is awesome, you are absolutely right about it being much more verbose than the check in the GUI. It popped up some other bugs I wasn’t aware of.

1 Like

Hi, how to modify my cover integration ? Here is how it looks like now:
the configuration.yaml
cover: !include cover.yaml

and the cover.yaml have these:

- platform: mqtt
  name: "persiana"
  state_topic: "shellies/shellyswitch25-68C63AF9080F/roller/0"
  command_topic: "shellies/shellyswitch25-68C63AF9080F/roller/0/command"
  position_topic: "shellies/shellyswitch25-68C63AF9080F/roller/0/pos"
  set_position_topic: "shellies/shellyswitch25-68C63AF9080F/roller/0/command/pos"
  #availability_topic: "shellies/shellyswitch25-68C63AF9080F/online"
  payload_available: "true"
  payload_not_available: "false"
  qos: 1
  retain: false
  payload_open: "open"
  payload_close: "close"
  payload_stop: "stop"
  position_open: 100
  position_closed: 0
  optimistic: false

It will probably look something like this:

mqtt:
  -  name: "persiana"
     state_topic: "shellies/shellyswitch25-68C63AF9080F/roller/0"
     command_topic: "shellies/shellyswitch25-68C63AF9080F/roller/0/command"
     position_topic: "shellies/shellyswitch25-68C63AF9080F/roller/0/pos"
     set_position_topic: "shellies/shellyswitch25-68C63AF9080F/roller/0/command/pos"
     #availability_topic: "shellies/shellyswitch25-68C63AF9080F/online"
     payload_available: "true"
     payload_not_available: "false"
     qos: 1
     retain: false
     payload_open: "open"
     payload_close: "close"
     payload_stop: "stop"
     position_open: 100
     position_closed: 0
     optimistic: false

Note, I almost certainly have the wrong spacing for the YAML above, but that should be the general format overall.