localtuya
localtuya copied to clipboard
Fix broken state
My covers get permanently stuck in 'closing'. Manually forcing the state to 'stopped' allows all the other is_closed / is_open etc to trigger correctly and the buttons start working form the UI again
I mean I use it locally and it makes my curtains work, I just want it merged to others can benefit. I've personally not seen any outside the range, and the invert function elsewhere in the code equally has no guards for thisSent from Android deviceOn 29 Mar 2022 3:50 pm, CloCkWeRX @.***> wrote: @CloCkWeRX commented on this pull request.
In custom_components/localtuya/cover.py:
@@ -203,6 +203,12 @@ def status_updated(self): self._current_cover_position = 100 - curr_pos else: self._current_cover_position = curr_pos
-
if self._current_cover_position == 0:
Do you want to guard against odd readings, with <= 0 and >= 100 respectively?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>
Thanks very much for submitting this PR. It looks like it will fix an annoying bug. Is there anything else that needs to be done to prepare it to be merged?
it's been a while since i last visited it, but no don't believe there is anything else needed :)
oh sugar sorry I didn't realise clicking update would un-approve it - hopefully the fact there are no changes should mean its still an easy merge!
@rospogrigio can you verify this? It is a very important PR. Curtains are broken without it.
I really don't get what you are trying to do here, can you explain? I have 3 covers and they work just fine...
I really don't get what you are trying to do here, can you explain? I have 3 covers and they work just fine...
I have 6 curtains. Some of them always had the close button grayed out, even with the curtain fully open. The set position was working fine. What I could see is that the open curtain that I couldn't close with the button had the state "closing" and the raw_state "close". The other open curtain that was working fine was "open" for the state and "stop" for the raw_state. Looking through the debug logs on Tuya Cloud, I noticed that every time I open or close a curtain, either with the buttons or using the position slider, only the DP ID of the "curtain current position" with the position percentage as value appeared in the logs. It must be normal. But another thing I saw was that the last "control" DP ID that showed up in the logs had the value "stop" for the working curtain and "close" for the grayed out button curtain.
What I could understand about these PR is that it uses the curtain position (which is sent by Tuya in each curtain operation) to define the state of the curtain.
Well before I merge this I need to check what happens with mine. Will try to do it during the holidays, this period is too busy for me currently... thank you for your patience.
FWIW this seems to work well with my Quoya curtains, would be cool to see this merged though for now I just overwrote the cover.py in my configs.
would love to get this merged . . .
I wonder if my issue for a set of blinds is running into the same error:
homeassistant | 2023-07-21 15:12:33.028 ERROR (SyncWorker_14) [homeassistant.util.logging] Exception in _update_handler when dispatching 'localtuya_00408365e8db84c6d592': ({'1': 'stop', '2': 50, '3': 50, '5': False, '7': 'closing', '8': 'cancel', '9': 0, '10': 0, '11': 19340},)
homeassistant | Traceback (most recent call last):
homeassistant | File "/config/custom_components/localtuya/common.py", line 411, in _update_handler
homeassistant | self.status_updated()
homeassistant | File "/config/custom_components/localtuya/cover.py", line 203, in status_updated
homeassistant | self._current_cover_position = 100 - curr_pos
homeassistant | ~~~~^~~~~~~~~~
homeassistant | TypeError: unsupported operand type(s) for -: 'int' and 'str'
homeassistant |
It seems like perhaps this is due to not being able to communicate with the blinds, rather than the state being stuck like in the original issue.
This PR solved my issues. I have 7 Zemismart ZM25 curtain motors that were all experiencing this state issue where the up and/or down buttons wouldn't work and they would always show "closing".
@WarlaxZ I recommend changing lines 113 to the following - covers should be considered open unless closed:
if self._current_cover_position == 0:
return True
return False
👋🏻 ! Is this PR being considered? IMO this is a critical bug which should be fixed ASAP