-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MQTT Cover Fix Assumed State #14672
MQTT Cover Fix Assumed State #14672
Conversation
(In my case, this would preferably be in a bug-fix release such as 0.70.1, as this is a pretty important part of the new cover component for esphomeyaml in the next version and since this is actually a bug fix. Of course I understand if this should rather fall into the usual full release cycle) |
@dgomes Probably, yes. But I think in the case of the cover it's not that important, since the frontend doesn't seem to show the state if in optimistic mode (the up/down buttons are there to show the state) Also there are probably few use-cases where one needs the underlying state from templates/automations, so I don't think I'll do that in this PR. |
well the obvious use case would be to avoid open/close the cover when the cover is already open/closed |
The cover component (as well as the other MQTT integrations I believe) explicitly do not prevent sending a command like open the cover twice. Besides, the whole idea of the optimistic parameter is that you do not know the actual state of the device (here cover). The problem is that if we try to prevent users from doing something like opening a cover twice, then that would also mean to only show one of the UP/DOWN buttons in the front-end. Even with the recorder we cannot always know the actual state of the cover, only do an approximation of the state. |
My understanding of optimistic is different:
|
Well the Home Assistant property we're declaring is called Also, consider this: I have a cover, which is optimistic as it does not have any sensor reporting the actual state of the cover. Then:
The same would happen in a more frequent scenario:
Of course the latter scenario could be handled manually by setting assumed state to true once a stop happens, but that would just make things more complicated and once again a semi-bad UX imo. To clarify, sure we can recover the state from the recorder, no problem. But we should definitely not try to prevent the user from opening a cover twice (by setting |
It's true that a human can always mess around with the state, but thats why it's optimistic (we expects that no one does and everything is in sync) How to recover from a closed cover that optimistically we think is open ?
|
So I feel like we failed by naming the option Optimistic: when sending the command, assume it succeeds and update the local cache of the state. Just being optimistic doesn't mean perse that we don't get a state reported, it might just be very slow. Assumed: we never get a state reported. Be optimistic when sending commands. |
Description:
Usually, if an MQTT platform has an
optimistic
mode, it means thatassumed_state
will also be True. This is usually used in cases where the actual state of a device (such as a cover) is unknown and causes the front-end to show the up AND down actions.Right now, if optimistic is False, only one action is shown as seen below. However, if optimistic is True, ideally both actions should be enabled.
Related issue (if applicable): fixes #
Example entry for
configuration.yaml
(if applicable):Checklist:
tox
. Your PR cannot be merged unless tests passIf the code does not interact with devices: