Skip to content

Avoid failing when hub does not provide cover position information#39826

Merged
bdraco merged 1 commit intohome-assistant:devfrom
Franchie:hunterdouglas-missing-positions
Sep 8, 2020
Merged

Avoid failing when hub does not provide cover position information#39826
bdraco merged 1 commit intohome-assistant:devfrom
Franchie:hunterdouglas-missing-positions

Conversation

@Franchie
Copy link
Copy Markdown
Contributor

@Franchie Franchie commented Sep 8, 2020

The powerview hub, seemingly randomly, will occasionally not
provide data for cover positions. Some requests will return the
desired response, but minutes later the same request might not.

It appears this issue is being experienced by a number of people:
https://community.home-assistant.io/t/hunter-douglas-powerview-component-expanding-this-api/88635/48

While an unfortunate bug with the hub, crashing the integration
as a result of this missing data appears somewhat excessive.
This patch adds a simple check to ensure the 'position' key
has been returned by the hub before attempting to access its
data.

Proposed change

This does a conditional check for existence of the "positions" key within the returned raw data from the hub.
If that does not exist, an empty dictionary is returned instead then later checks avoid accessing the unavailable data.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

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.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

The powerview hub, seemingly randomly, will occasionally not
provide data for cover positions. Some requests will return the
desired response, but minutes later the same request might not.

It appears this issue is being experienced by a number of people:
https://community.home-assistant.io/t/hunter-douglas-powerview-component-expanding-this-api/88635/48

While an unfortunate bug with the hub, crashing the integration
as a result of this missing data appears somewhat excessive.
This patch adds a simple check to ensure the 'position' key
has been returned by the hub before attempting to access its
data.
@homeassistant
Copy link
Copy Markdown
Contributor

Hi @Franchie,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@probot-home-assistant
Copy link
Copy Markdown

Hey there @bdraco, mind taking a look at this pull request as its been labeled with an integration (hunterdouglas_powerview) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

Comment thread homeassistant/components/hunterdouglas_powerview/cover.py
@bdraco bdraco added this to the 0.115.0 milestone Sep 8, 2020
@bdraco
Copy link
Copy Markdown
Member

bdraco commented Sep 8, 2020

I've never had mine do that, but these talk over RF so its not really surprising. It may be an hub v1 issue per #36040

@bdraco
Copy link
Copy Markdown
Member

bdraco commented Sep 8, 2020

Still works as expected ( I wouldn't expect otherwise with this small of a change )

Screen Shot 2020-09-08 at 3 53 39 PM

@Franchie
Copy link
Copy Markdown
Contributor Author

Franchie commented Sep 8, 2020

Yes, it is a v1 hub, and I know from use that the RF to this particular blind is troublesome. That's likely what's causing the random drops.
Thanks for your work on this integration, it's awesome!

@bdraco bdraco merged commit 066a418 into home-assistant:dev Sep 8, 2020
@Franchie Franchie deleted the hunterdouglas-missing-positions branch September 8, 2020 21:02
balloob pushed a commit that referenced this pull request Sep 8, 2020
…39826)

The powerview hub, seemingly randomly, will occasionally not
provide data for cover positions. Some requests will return the
desired response, but minutes later the same request might not.

It appears this issue is being experienced by a number of people:
https://community.home-assistant.io/t/hunter-douglas-powerview-component-expanding-this-api/88635/48

While an unfortunate bug with the hub, crashing the integration
as a result of this missing data appears somewhat excessive.
This patch adds a simple check to ensure the 'position' key
has been returned by the hub before attempting to access its
data.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants