home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74k stars 31.05k forks source link

Tuya Covers have reversed up and down states. #60995

Closed emilinsweden closed 2 years ago

emilinsweden commented 2 years ago

The problem

Tuya covers. In my case Zemismart Wi-Fi blind motors. The button for up closes the covers and vice versa. One motor doesn’t even go up. Its position is reversed in the Tuya app.

What version of Home Assistant Core has the issue?

core-2021.12.0b0

What was the last working version of Home Assistant Core?

core-2021.11.5

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Tuya

Link to integration documentation on our website

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

probot-home-assistant[bot] commented 2 years ago

tuya documentation tuya source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @tuya, @zlinoliver, @metisu, @frenck, mind taking a look at this issue as it has been labeled with an integration (tuya) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

frenck commented 2 years ago

Honestly, I think this will be one of the unfixable problems that will keep appearing. If we flip it again, it will be wrong for a lot of other people. There won't be a right solution here.

I'm really out of ideas on resolving this.

nvx commented 2 years ago

I'm really out of ideas on resolving this.

Is it possible to expose an option on the device to flip the directionality? A manual flick of a switch seems like a better solution than nothing.

frenck commented 2 years ago

Home Assistant doesn't have a construct for configuring device preferences. It only has a construct for configuring integrations or device options that the device itself provides.

Since this is not a global integration setting, and not a control the device itself provides, there isn't a place for it.

nvx commented 2 years ago

Since this is [...] not a control the device itself provides, there isn't a place for it.

Is there any reason this is a hard limitation? Creating an entity for the device to control reversing the direction doesn't seem that dissimilar to an option provided by the device itself. This is what I was thinking of when I made my comment.

frenck commented 2 years ago

Is there any reason this is a hard limitation?

It not a hard limitation, it simply doesn't exist at this point. So this it not a matter of just a Tuya change, this needs a fundamental change to Home Assistant.

taljaardwp commented 2 years ago

Same issue with the Tuya Garage door opener. When the door is closed it shows open and open it shows closed. In the Tuya app it shows correctly.

Version core-2021.11.5 Version supervisor-2021.10.8

frenck commented 2 years ago

@taljaardwp Please avoid raising "Same issue" report. Instead, use the 👍 on the issue openings description. Thanks 👍

nvx commented 2 years ago

Is there any reason this is a hard limitation?

It not a hard limitation, it simply doesn't exist at this point. So this it not a matter of just a Tuya change, this needs a fundamental change to Home Assistant.

Sorry I misspoke earlier, I was thinking of exposing a service to control the reverse flag not an entity. The service would take in entity_id of the cover to adjust the reverse flag for though. (This is how the UniFi Protect integration available via HACS works to set a bunch of camera/etc related settings).

I'm not sure how it would need to be a fundamental change to Home Assistant though.

frenck commented 2 years ago

Sorry I misspoke earlier, I was thinking of exposing a service to control the reverse flag not an entity.

That is the same issue.

hudcap commented 2 years ago

@emilinsweden What is the product category of your blinds? Afaik the only category that was changed was "ckmkzq"

@taljaardwp your issue will likely be fixed in 2021.12 This issue relates to 2021.12 reversing the states incorrectly when it worked 2021.11

emilinsweden commented 2 years ago

@hudcap How do I find the category of product?

hudcap commented 2 years ago

On the Tuya IoT platform, under devices, click the "debug device" link for the device in question. That should open a tab with device information, including product category.

emilinsweden commented 2 years ago

the product category is cl

hudcap commented 2 years ago

@frenck As best I can tell, PR #59427 only reversed "ckmkzq" That said, upon reviewing what I did there, I see I messed up—I flipped True to False as an initial fix, but then changed the logic to make it customizable on a per-category basis and never flipped it back, so the logic is wrong now. I fixed it in #61303. That said, "cl" should report it's state as "fully_open" or "fully_close" based on this, so I don't think my mistake would have caused OPs issue.

hudcap commented 2 years ago

The button for up closes the covers and vice versa.

It looks like PR #59858 added some code to the open_cover and close_cover methods, and it looks like the values are reversed. open_cover sets the value to 0 and close_cover sets it to 100, but one of the docstrings says None is unknown, 0 is closed, 100 is fully open. I think this might be causing the OP's issue.

emilinsweden commented 2 years ago

The one motor that I reversed in the tuya app is going down but not up and the other "normally orientated" motors buttons are still reversed.

hudcap commented 2 years ago

I believe there are 2 issues here. One is the control only half working and the other is the reversed state reporting.

The one motor that I reversed in the tuya app is going down but not up and the other "normally orientated" motors buttons are still reversed.

I don't fully understand what you mean here, but my garage door will open and not close, which I think is the same as your first issue. I think the second issue relates to my previous comment.

I'm going to make a PR that I believe will fix these issues, but I can't verify, as I don't have any smart blinds.

emilinsweden commented 2 years ago

Okay that would be good. I will let you know if it fixes it.

What I mean is that I have Zemismart WiFi motors that you slide into a roller blind. They are AC powered. You can put them in from the right side or the left. If you slide the motor into the right side you need to change the up and down direction in the Tuya application because the motor is upside down!

hudcap commented 2 years ago

Oh, got it. I noticed a parameter having to do with reversing—I'm guessing that change you made in the app flips its value. I can't be sure how that affects the state reporting.

I believe there are 2 issues here.

Rethinking it—looks like it's actually one issue, but with 2 sources. Hopefully my PR will fix it.

emilinsweden commented 2 years ago

I saw you made a PR a couple of hours ago. You mean another one?

hudcap commented 2 years ago

Yeah, the first one was not related to your issue. While looking at your issue I noticed a different problem with a PR I had made a month ago.

emilinsweden commented 2 years ago

Why did you close the issue when it isn't fixed? The new update doesn't fix the problem unfortunately.

hudcap commented 2 years ago

You updated to 2021.12 (non-beta) and it didn't solve either of your problems?

emilinsweden commented 2 years ago

Yes and no difference with your PR

hudcap commented 2 years ago

I suspect that it's because the percentage open/closed is reversed, but that will not change in HA until Tuya clarifies the interpretation of the percentage in the docs for cl. I submitted a request for them to do so.

hudcap commented 2 years ago

The docs for cl have been updated, but are not as clear as I would have hoped: image

It seems that the percentage ignores the orientation of the motor, so its interpretation depends on the value of control_back_mode. I am still not clear on which way means what.

@emilinsweden For a reversed motor and a non-reversed motor, and for both the open and closed states, can you please post labeled screenshots of the Device Debugging tab after clicking on Debug Device? After you change the state, you will need to click Update Device Status before taking the screenshot.

It should look something like this (this is my garage door opener):

image
emilinsweden commented 2 years ago

Hello. The instructions do not work using the debug tool, they either go up and down a little bit when they are down or vice versa when they are up. They work great in the Tuya app though.. The states do not even change in the debug tool

normal motor reversed motor

hudcap commented 2 years ago

Sorry for the delayed response. When you took these screenshots, were the shades open or closed?

hudcap commented 2 years ago

The states do not even change in the debug tool

Did you click on Update Device Status?

emilinsweden commented 2 years ago

Yes I did but it didn't matter, the state didn't change so I didn't check if they were up or down

hudcap commented 2 years ago

So just to be clear, situation_set stayed stuck on fully-open and percent_state on 100 no matter what position the shades were in? I'm not sure how that makes sense, but if that's the case, then I think we're stuck.

emilinsweden commented 2 years ago

Okay the state changes, I have some new screenshots.

Screen Shot 2021-12-21 at 20 58 36 Screen Shot 2021-12-21 at 20 57 45 Screen Shot 2021-12-21 at 20 53 14 Screen Shot 2021-12-21 at 20 52 39
hudcap commented 2 years ago

Okay, that's great! This firmly establishes that percent_state is always referring to the percentage open. I'm going to make another PR that will hopefully fix this.

hudcap commented 2 years ago

@emilinsweden are you able to re-open this issue?

emilinsweden commented 2 years ago

@hudcap No I don't think so as @frenck closed it to get the release out

hudcap commented 2 years ago

I'm not sure what to make of the fact that situation_set doesn't change... @frenck can we please get your thoughts on those 4 screenshots? Thanks!

oxelwhy commented 2 years ago

Now my home assistant only able to open the curtain, but can't close on 2021.12 ( i was able to do so on 2021.11), it this similar to this fix?