PaulAnnekov / tuyaha

Implements the special Tuya Home Assistant API.
Other
141 stars 106 forks source link

Use cached discovery, fix climate and light device values #39

Closed ollo69 closed 3 years ago

ollo69 commented 4 years ago

Hi,

I start to PR this change that basically try to limit the use of discovery method and cache retrieved data. The intention is to share the result of one discovery call for all devices and at the same time limit the number of calls, also because in many case status device refresh fail with an error "FrequentlyInvoked". This will also improve device detection by HA component because cached data are used also for this. For the moment I implemented this only for switch and cover, I think should be also extended (and can be quickly done) for light bulb, but not having a bulb I'm not sure about how to correctly update in the cache some of the state (brightness, color, etc). If you have one and time we can work also on this.

Please also consider that last pr #38 probably will break cover device because "state" attribute is not properly updated.

PaulAnnekov commented 3 years ago

I will try to take a look at this PR on the weekend. It's quite big and contains architectural changes.

ollo69 commented 3 years ago

Thanks, I will be available for required clarifications.

PaulAnnekov commented 3 years ago

@ollo69 Review is done. Waiting for fixes and comments.

ollo69 commented 3 years ago

@PaulAnnekov,

looks like you don't have time to dedicate to this PR and to this project. If you prefer I can create a new library to use in the HA integration. Please let me know.

PaulAnnekov commented 3 years ago

I'm trying to review this repo weekly or at least once in two weeks. Please, handle my last comments, they are easy. I will be available to review them in the next 3 days.

PaulAnnekov commented 3 years ago

@ollo69 thanks for your work 😉

PaulAnnekov commented 3 years ago

PR into HA https://github.com/home-assistant/core/pull/41365