Skip to content
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

Make tplink light more responsive #28652

Merged
merged 5 commits into from
Dec 17, 2019
Merged

Make tplink light more responsive #28652

merged 5 commits into from
Dec 17, 2019

Conversation

vangorra
Copy link
Contributor

@vangorra vangorra commented Nov 9, 2019

Breaking Change:

None

Description:

Tplink light bulbs take upwards of 6 seconds to update their state after taking action. This makes for a bad user experience. This change makes the entity optimistically update the state, run the actual update in the background and throttles the number of update calls.

Related issue (if applicable): fixes None

Pull request with documentation for home-assistant.io (if applicable): None

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly. Update and include derived files by running python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

@probot-home-assistant
Copy link

Hey there @rytilahti, mind taking a look at this pull request as its been labeled with a integration (tplink) you are listed as a codeowner for? Thanks!

@MartinHjelmare MartinHjelmare changed the title Making tplink light more responsive. Make tplink light more responsive Nov 9, 2019
Copy link
Member

@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have generally speaking nothing against this, but it'd be great to have this done simultaneously for all platforms to keep them in sync.

homeassistant/components/tplink/light.py Outdated Show resolved Hide resolved
homeassistant/components/tplink/light.py Outdated Show resolved Hide resolved
@vangorra
Copy link
Contributor Author

I don't have generally speaking nothing against this, but it'd be great to have this done simultaneously for all platforms to keep them in sync.

I haven't noticed any issues with the switch platform so I didn't think there was a need to change anything.

@rytilahti
Copy link
Member

I haven't noticed any issues with the switch platform so I didn't think there was a need to change anything.

Both of the platforms share most of the code and should probably be derived from a common base class to keep them in sync without extra effort :-) The same "problem" should also be relevant to plugs as they are polled just like the lights (or maybe the lights are slower at responding?)

@vangorra
Copy link
Contributor Author

The lights tend to make 4 or 5 duplicate calls to get state information where the switch make only 1 call. This appears to be the cause.
Future versions of the api avoids duplication by caching the first call for a few seconds or until new values are sent.

@rytilahti
Copy link
Member

The lights tend to make 4 or 5 duplicate calls to get state information where the switch make only 1 call. This appears to be the cause.

Yes, that's the reason why I added caching – I had a couple of bulbs earlier for testing, and noticed how homeassistant spams the bulbs :-)

@vangorra vangorra mentioned this pull request Nov 12, 2019
9 tasks
@vangorra
Copy link
Contributor Author

vangorra commented Dec 9, 2019

Tests updated to mock the tplink module and not the API.

@rytilahti
Copy link
Member

As there has been no objections, let's get this merged. Thanks for the PR @vangorra!

@rytilahti rytilahti merged commit 78e831b into home-assistant:dev Dec 17, 2019
@vangorra vangorra deleted the rvangork_tplink_fixes branch December 17, 2019 04:28
@lock lock bot locked and limited conversation to collaborators Dec 18, 2019
@balloob
Copy link
Member

balloob commented Dec 20, 2019

This PR has caused flaky tests like this

@balloob
Copy link
Member

balloob commented Dec 22, 2019

I will have to revert this PR before the next release to make sure that we don't have flaky tests anymore in dev.

@rytilahti
Copy link
Member

Ping @vangorra – any ideas what could be wrong?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants