MQTT Auto discovery for cover entity


I’m currently designing some motorized curtains based on an ESP2866. I’m trying to implement MQTT auto discovery in the code of the ESP but the documentation is rather sparse when it comes to cover entities auto discovery.

I have set up 3 topics : homeassistant/cover/curtains/set (command topic), homeassistant/cover/curtains/state (state topic) and homeassistant/cover/curtains/config (config topic).

Here is the initial payload I’m publishing to the config topic:

{"name": "Curtains", "device_class": "cover", "command_topic": "homeassistant/cover/curtains/set", "state_topic": "homeassistant/cover/curtains/state", "retain": "true"}

All other parameters needed for the cover entity correspond to the default values so I did not included them in the payload.
However, no cover entity is showing up in the developer entities panel. MQTT discovery is enabled and working well with other devices.

What am I missing ?

Thanks a lot !

Digging into the logs, this seems to be the particular error:

2020-07-06 22:22:25 ERROR (MainThread) [homeassistant.util.logging] Exception in async_discover when dispatching 'mqtt_discovery_new_cover_mqtt': ({'name': 'curtains', 'device_class': 'cover', 'command_topic': 'homeassistant/cover/curtains/set', 'state_topic': 'homeassistant/cover/curtains/state', 'retain': 'true', 'platform': 'mqtt'},)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/", line 183, in async_discover
    config = PLATFORM_SCHEMA(discovery_payload
  File "/usr/local/lib/python3.7/site-packages/voluptuous/", line 208, in __call__
    return self._exec((Schema(val) for val in self.validators), v)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/", line 287, in _exec
    raise e if self.msg is None else AllInvalid(self.msg, path=path)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/", line 283, in _exec
    v = func(v)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/", line 817, in validate_callable
    return schema(data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/", line 594, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.7/site-packages/voluptuous/", line 432, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: value is not allowed for dictionary value @ data['device_class']

I don’t think you can have a device class in a cover definition. Also I don’t think you need “retain” in the config payload.

Thank you for the reply. It made me investigate the allowed values for device_class and it turns out cover isn’t one of them but curtain is. I made the modification in the initial config payload and it works like a charm.

Where can I get a detailed description of MQTT AutoDiscovery Cover/Curtain? And about other objects…
There is little information in the official documentation MQTT - Home Assistant.
And nothing is said about curtains