I have implemented the following config for my cover. The cover buttons are active and working (blind works as expected) - and the blind takes commands from the position slider.
However, the one thing I cannot figure out is why the position slider does not retain the position of the blind even though I can see the MQTT updates coming back into the broker on the ‘position’ topic - what am i missing?
When I close the pop up - it resets back to zero when I open it, its like the slider is ignoring the actaul position - the screen shot below is a great example of it being at zero.
I set the blind to 60% closed 2hrs ago, closed the pop up and its back at zero.
ok - so I have been digging into this somewhat and trouble shooting the retain flag.
forcing the retain flag on the client end has no effect unless you have retain set in the cover config on HASS
with retain set on HASS and optionally set on the client then
a) the position slider does not remember the position, and
b) unwanted behaviour occurs
My gut feel on this one is there is a problem with the payload by the fact that the payload is a string and it needs to be a INT for the position_topic to recognise it.
Looking at the MQTT Cover documentation there are options to add templates for all topics but the position_topic - i am at a bit of a loss here.
Is it possible to add a template to the positions_topic? Has anyone done this?
It appears that if the blind does not provide an immediate update on the position topic the position slider defaults to 0 when you close the more info box. Moreover it also appears that if an update is not recieved by home assistant in a finite amount of time it also ignores the position or can exhibit erratic behaviour… c’est la vie!
The solution which is not ideal is to set
optimistic: true
its not ideal as it will remeber the last position set rather than the actual position of the blind - this may help some one else
I kept digging on this and ultimately raised an issue on GIT. The root cause was with the formatting of the payload on the position_topic.
My original payload had preceding spaces [..payload] - which would have required a template to extract a value so that HASS could then strip the spaces - which is clearly incorrect.
Refactoring the controller code to remove the preceding spaces [payload] AND updating the position_topic with position every couple of seconds the position slider works correctly and not only retains position but you can see it moving with the actual blind position - really nerdy
This has allowed me to create an auto configuring MQTT blind integration so I can remove the YAML entry completely.