MQTT Cover with more states (Opening and Closing)

Hi team,

I’m maintaining a customized mqtt cover, and right now I see that the only ‘real’ difference with the official MQTT cover is the additional states that it includes: Closing and Opening.

Many of other Covers include these states, and I guess it should be just a matter of a few lines to add these states to the official MQTT Cover. Would it make sense to include these states?


Yes, I don’t use cover because of this limitation. I’d also want to see the “Stopped” state.

Yes, for stopped I’m using UNKNOWN, but it has some limitations. Actually the code changes I did are quite simple, and the init for the covers already have that logic, so it’s only a matter of adding the proper overriding functions in the mqtt part.


I was agreeing with you … I think the extra states should be included in the official cover.
Garage doors have the following states:

  • Closed

  • Opening

  • Open

  • Closing

  • Stopped

  • Unknown

It is also appropriate to warn anyone in the garage before any door movement is initiated, so I would add:

  • Beeping

It would also be nice if HA supported a “Garage” entity which could have multiple Garage Doors with binary states of “Secure” / “notSecure”

1 Like

Bump. I just tested the MQTT cover to see if it can speed up reading Shelly 2.5 in cover mode status and I was disappointed that when I configure the position topic it only reports two states, open or close. I have a script that sets position and relies on opening and closing detection so that it doesn’t interrupt if the blinds are currently moving.

So would it be possible to allow state topic together with position topic so that intermediate states are possible?

Yes, same problem for me.
Right now the shelly only send position when the movement is over.
So it would be really nice that the state_topic is not completly ignored and the opening/closing states are still processed, but closed/opended are generated by the actual position.

another way could be that closing / opening would be calculated es well:

opened : position > 0 -> allready done
closed : position = 0 -> allready done
closing: executed position command topic with a position bigger than actual position
opening: executed position command topic with a position smaller than actual position

That way after sending the command for open the state will be calculated with “opening” and after you got the new position it will change to open again…


1 Like

I fully agree with the proposed extra states (Stopped, Unknown, …) from @rwpalmer, this is really needed in Home Assistant.

@gitlemat how did you solve that with you customized mqtt cover? Do you have some code for it? Would be really nice because everything works now except the closing / opening states that the device (a shelly) reports) in its mqtt communication but you cannot use it because of the position…


Can you help me?

I have to binary sensors at the end of the door travel and other at the starttravel , they give me the closed or open state. Like this:

state: on
battery: 100
contact: false
linkquality: 255
temperature: 28
voltage: 3035
device_class: door
friendly_name: Sensor Porton Garaje Abierto

Is this right?

  • platform: mqtt
    name: “Porton Garaje”
    device_class: garage
    command_topic: “home-assistant/cover/set”
    position_topic: “home-assistant/cover/position”
    set_position_topic: “home-assistant/cover/position/set”
    • topic: “home-assistant/cover/availability”
      qos: 0
      retain: true
      payload_open: “OPEN”
      payload_close: “CLOSE”
      payload_stop: “STOP”
      state_open: “open”
      state_opening: “opening”
      state_closed: “closed”
      state_closing: “closing”
      state_stopped: “stopped”
      payload_available: “online”
      payload_not_available: “offline”
      optimistic: false
      #value_template: “{{ value.x }}”
      position_template: |-
      {% if (state_attr(“binary_sensor.sensor_porton_garaje_cerrado_contact”, “contact”)) and not (state_attr(“binary_sensor.sensor_porton_garaje_abierto_contact”, “contact”)) %}
      {% set position = 0 %}
      {% elif not (state_attr(“binary_sensor.sensor_porton_garaje_cerrado_contact”, “contact”)) and (state_attr(“binary_sensor.sensor_porton_garaje_abierto_contact”, “contact”)) %}
      {% set position = 100 %}
      {% endif %}