8000 Update Somfy to reduce calls to /site entrypoint by tetienne · Pull Request #51572 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update Somfy to reduce calls to /site entrypoint #51572

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

Merged
merged 10 commits into from
Jul 6, 2021

Conversation

tetienne
Copy link
Contributor
@tetienne tetienne commented Jun 7, 2021

Breaking change

Proposed change

Somfy recently changed the rules about polling their server to get the latest status. The purpose of this PR is to apply these rules.

We are contacting you today to inform you about the new rules we are now applying to the API:

    First of all, no limitation will be applied on the POST /device/{deviceId}/exec endpoint as we want to provide you a total freedom on controlling your devices.
    On the other hand, polling frequency on the GET /site and child endpoints will now have to be under 1 call per minute.

Release notes:

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

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:

@tetienne tetienne changed the title Move SomfyEntity to dedicated module Reduce calls to /site entrypoint Jun 7, 2021
@tetienne tetienne force-pushed the fix/somfy/reduce-call-to-site branch from 3c5524e to 0967543 Compare June 7, 2021 15:15
@emontnemery emontnemery changed the title Reduce calls to /site entrypoint Updte Somgy to reduce calls to /site entrypoint Jun 8, 2021
@emontnemery emontnemery changed the title Updte Somgy to reduce calls to /site entrypoint Update Somfy to reduce calls to /site entrypoint Jun 8, 2021
@tetienne
Copy link
Contributor Author
tetienne commented Jun 8, 2021

I cannot currently test my fix. For any reason, Somfy API returns a device I don’t own 👎

@tetienne tetienne force-pushed the fix/somfy/reduce-call-to-site branch from 740cfd3 to b921e01 Compare June 28, 2021 07:53
@tetienne tetienne marked this pull request as ready for review July 4, 2021 20:18
@tetienne
Copy link
Contributor Author
tetienne commented Jul 4, 2021

After some exchange with Somfy support, they review their quota limitation. Once a site is retrieved, we can chain with another call to get the device.

Tested locally, without any issue (finally 🎉 )

@frenck
Copy link
Member
frenck commented Jul 5, 2021

@tetienne Can we adjust the tests so we can include it in the July release?

@tetienne
Copy link
Contributor Author
tetienne commented Jul 5, 2021

I will check asap.

@tetienne
Copy link
Contributor Author
tetienne commented Jul 6, 2021

Test is failing because sites = await self.hass.async_add_executor_job(self.client.get_sites) returns a MagicMock. And I’m expected a list (empty or not).

@tetienne
Copy link
Contributor Author
tetienne commented Jul 6, 2021

Don’t know how to correctly mock, so I updated the code :(

@frenck
Copy link
Member
frenck commented Jul 6, 2021

@tetienne Reverted the change and added a mock to the setup entry (which is how we generally do that with testing config flows).

@tetienne
Copy link
Contributor Author
tetienne commented Jul 6, 2021

Awesome, many thx @frenck

@frenck frenck added this to the 2021.7.0 milestone Jul 6, 2021
@frenck frenck merged commit 5c07fb5 into home-assistant:dev Jul 6, 2021
frenck added a commit that referenced this pull request Jul 6, 2021
Co-authored-by: Franck Nijhof <git@frenck.dev>
@github-actions github-actions bot locked and limited conversation to collaborators Jul 7, 2021
Copy link
Member
@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Please address the comments in a new PR. Thanks!

devices = await self.hass.async_add_executor_job(
self.client.get_devices, site_id
)
self.site_device[site_id] = devices
Copy link
Member

Choose a reason for hiding this comment

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

Please only wrap the line that can raise in the try... except block.

from .const import DOMAIN


class SomfyEntity(CoordinatorEntity, Entity):
Copy link
Member

Choose a reason for hiding this comment

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

We don't need to inherit Entity when inheriting CoordinatorEntity.

@@ -0,0 +1,71 @@
"""Helpers to help coordinate updated."""
Copy link
Member

Choose a reason for hiding this comment

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

Please exclude all new untested modules from coverage calculation in .coveragerc.

@tetienne tetienne deleted the fix/somfy/reduce-call-to-site branch August 16, 2021 07:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Somfy disconnects every 2 minutes
5 participants
< 2A23 footer class="footer pt-8 pb-6 f6 color-fg-muted p-responsive" role="contentinfo" >

Footer

© 2025 GitHub, Inc.
0