MQTT Cover operation logic issue


I am developing an MQTT cover device.
I have a logic issue with how it works with home assistant. I use both set and state topic.
Initially on screen I see 3 buttons: Open, Stop, and Close - OK.
Now say I give an open command, the shade start to open. When it is completely open, I send an ‘open’ state, this will gray out the Open button - OK.
Now, I press the Close button, and before the cover is closed I press Stop. The cover is 1/2 closed so I do not send any state message (as there is none for middle state).
And here is the problem: If I want now to open the cover, I can’t since the Open button is grayed out. The only option it to continue closing until its fully closed, and then the Close is gray, and the Open is now enabled.
In fact, after the first ‘open’ or ‘close’ status, there is no way to get to a point where the 2 buttons are active at the same time.
How can I bypass this issue?


Haven’t used an MQTT cover, so the following is just conjecture based upon my use of the command line cover.

With command line cover, you set state with a value between 0 (fully closed) and 100 (fully open) so setting a value of 50 makes the cover show half-open, and makes both open and close buttons available.

So what happens if you send a state value that is anything other than ‘open’ or ‘closed’?

1 Like

How is your dev board monitoring the state of the garage? Reed switches? To provide insight, I have created my own MQTT dev board for my garage and programmed it to sense NOT OPEN and NOT CLOSED and call it the “middle” state. The programming will actually send a value for current_position and the value is something other than 0 or 100.

My suggestion is to find some way to utilize the current_position for your status.

P.S. - My actual garage opener does not utilize different commands for OPEN, CLOSE, and STOP. It is one button to perform all 3 tasks, so I am in essence just closing a relay to start and stop my garage opener. Yours may have different functionality.


Thank you for your answer, unfortunately mqtt state accepts open or close. I tried other states such as unknown, and stop, but it did not work. There is something called value_template, but I’m not sure if its connected. need to look further. What is the command line to set a 50% state?

I can sens ‘middle’ position, however I can not report it via MQTT. Looks like something is missing in the protocol. There is a way to do it on the ‘Tilt’ topic but not on the main topic.

I wrote the tilt mods :slight_smile:

current_position is definitely what you want to use to report open/closed position.
set_cover_position should do what you want but it’s not implemented in the MQTT cover. Doesn’t look like it’d be hard to add though.

Hi Quadmasta,

Thanks for your answer, and thanks for your tilt mods!


Hi redwnsrul

Yes! I just poke in the code and found out that though the state topic is supposed to accept ‘open’ or ‘closed’, if it finds a numerical value, it will update the current_position as well.
So based on your suggestion whenever the cover is neither open nor closed, I put a ‘50’ value in the state, and both buttons instantly become active. :grinning: Hurray!

Set position would be really helpful - and if it could use a set_position_template pattern, then it would be excellent.

I’m currently working on making open/close optional as well as adding the tilt controls to the main card. If I get that done I may see about the set_position. I have no way to test this on anything though :slight_smile:

Sounds good.:slight_smile:

PRs are issued:

It’s merged to dev now, should go in the next release

Regarding the set_position_topic,
When I use this, I expected to get a slider on the card/panel that would make use
of the set_position_topic, but I never get a slider to show up in the card/panel.

Has the slider been implemented for the card/panel?