Skip to content

Add Homepluscontrol integration#46783

Merged
MartinHjelmare merged 31 commits into
home-assistant:devfrom
chemaaa:homepluscontrol
Mar 25, 2021
Merged

Add Homepluscontrol integration#46783
MartinHjelmare merged 31 commits into
home-assistant:devfrom
chemaaa:homepluscontrol

Conversation

@chemaaa
Copy link
Copy Markdown
Contributor

@chemaaa chemaaa commented Feb 19, 2021

Proposed change

This adds the Legrand Home+ Control integration to the Home Assistant core. This integration connects Home Assistant to the Legrand API that can manage "Legrand/Bticino with Netatmo" products. This API is one of several that Legrand exposes through their "Works with Legrand" platform: https://developer.legrand.com/

In this initial PR, the integration adds a simple switch entity to represent the in-wall switches and power outlets that are part of this Legrand smart home product range.

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

Example entry for configuration.yaml:

# Example configuration.yaml
home_plus_control:
  client_id: YOUR_CLIENT_ID
  client_secret: YOUR_CLIENT_SECRET
  subscription_key: YOUR_SUBSCRIPTION_KEY

Additional information

The integration uses cloud-polling with a single API poll to fetch the data of all entities.
Authentication follows an oauth2 exchange.
The Legrand API only allows 500 API calls per day, so this is catered for in the configuration of the integration - refresh intervals have default values that are larger than ideal, but are currently the best possible to prevent reaching daily quota limitations. In any case, these intervals are configurable in the integration.

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
  • 🥇 Gold
  • 🥈 Silver
  • 🏆 Platinum

To help with the load of incoming pull requests:

@homeassistant
Copy link
Copy Markdown
Contributor

Hi @chemaaa,

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!

Comment thread homeassistant/components/homepluscontrol/__init__.py Outdated
Comment thread homeassistant/components/homepluscontrol/config_flow.py Outdated
Comment thread homeassistant/components/homepluscontrol/config_flow.py Outdated
Comment thread homeassistant/components/homepluscontrol/switch.py Outdated
Comment thread homeassistant/components/homepluscontrol/switch.py Outdated
Comment thread tests/components/homepluscontrol/test_integration.py Outdated
Comment thread tests/components/homepluscontrol/test_integration.py Outdated
Comment thread tests/components/homepluscontrol/test_integration.py Outdated
Comment thread tests/components/homepluscontrol/test_integration.py Outdated
Comment thread tests/components/homepluscontrol/test_options_flow.py Outdated
Comment thread homeassistant/components/homepluscontrol/manifest.json Outdated
@MartinHjelmare MartinHjelmare changed the title Homepluscontrol Add Homepluscontrol Feb 19, 2021
@cgarwood cgarwood changed the title Add Homepluscontrol Add Homepluscontrol integration Feb 19, 2021
Comment thread homeassistant/components/home_plus_control/__init__.py Outdated
Comment thread homeassistant/components/home_plus_control/__init__.py Outdated
Comment thread homeassistant/components/home_plus_control/__init__.py Outdated
Comment thread homeassistant/components/home_plus_control/__init__.py Outdated
Comment thread homeassistant/components/home_plus_control/__init__.py Outdated
Comment thread homeassistant/components/home_plus_control/manifest.json Outdated
Comment thread homeassistant/components/home_plus_control/switch.py Outdated
Comment thread homeassistant/components/home_plus_control/switch.py Outdated
Comment thread homeassistant/components/home_plus_control/config_flow.py Outdated
Comment thread homeassistant/components/home_plus_control/config_flow.py Outdated
Comment thread homeassistant/components/home_plus_control/__init__.py Outdated
Comment thread homeassistant/components/home_plus_control/switch.py Outdated
Comment thread tests/components/home_plus_control/test_config_flow.py Outdated
Comment thread tests/components/home_plus_control/test_init.py Outdated
Comment thread tests/components/home_plus_control/test_init.py Outdated
Comment thread tests/components/home_plus_control/test_init.py Outdated
Comment thread homeassistant/components/home_plus_control/switch.py Outdated
Comment thread homeassistant/components/home_plus_control/switch.py Outdated
Comment thread homeassistant/components/home_plus_control/switch.py Outdated
Comment thread homeassistant/components/home_plus_control/__init__.py Outdated
Comment thread homeassistant/components/home_plus_control/__init__.py Outdated
Comment thread homeassistant/components/home_plus_control/__init__.py Outdated
Comment thread homeassistant/components/home_plus_control/__init__.py Outdated
Comment thread homeassistant/components/home_plus_control/__init__.py Outdated
Comment thread homeassistant/components/home_plus_control/api.py Outdated
Comment thread homeassistant/components/home_plus_control/api.py Outdated
Comment thread homeassistant/components/home_plus_control/api.py Outdated
Comment thread homeassistant/components/home_plus_control/switch.py Outdated
Comment thread homeassistant/components/home_plus_control/__init__.py Outdated
chemaaa and others added 2 commits March 19, 2021 07:46
Start platforms before refreshing the coordinator.

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
@MartinHjelmare MartinHjelmare self-assigned this Mar 19, 2021
@MartinHjelmare
Copy link
Copy Markdown
Member

Please don't pin requirements exact in the library. And don't require any packages that are not imported directly. The library only needs these requirements:

aiohttp
PyJWT
yarl

Please change here:
https://github.com/chemaaa/homepluscontrol/blob/26aab702aafa573eec05eeb873dcfcce14398f0f/setup.py#L43-L89

Please set as loose version specifiers as possible. Eg a minimum version but no maximum version. If a maximum version is needed, please be as forgiving as possible to avoid conflicts with other libraries installed in Home Assistant.

Comment thread homeassistant/components/home_plus_control/switch.py Outdated
Comment thread tests/components/home_plus_control/test_config_flow.py Outdated
Comment thread tests/components/home_plus_control/test_config_flow.py
Comment thread homeassistant/components/home_plus_control/strings.json
Comment thread homeassistant/components/home_plus_control/strings.json Outdated
Comment thread tests/components/home_plus_control/test_init.py Outdated
Comment thread tests/components/home_plus_control/test_init.py Outdated
Comment thread tests/components/home_plus_control/test_init.py Outdated
Comment thread tests/components/home_plus_control/test_init.py Outdated
chemaaa and others added 2 commits March 19, 2021 22:40
@MartinHjelmare MartinHjelmare removed their assignment Mar 20, 2021
@chemaaa
Copy link
Copy Markdown
Contributor Author

chemaaa commented Mar 20, 2021

Please don't pin requirements exact in the library. And don't require any packages that are not imported directly. The library only needs these requirements:

aiohttp
PyJWT
yarl

Please change here:
https://github.com/chemaaa/homepluscontrol/blob/26aab702aafa573eec05eeb873dcfcce14398f0f/setup.py#L43-L89

Please set as loose version specifiers as possible. Eg a minimum version but no maximum version. If a maximum version is needed, please be as forgiving as possible to avoid conflicts with other libraries installed in Home Assistant.

OK, I will also work on cleaning up the library dependencies 👍

Comment thread tests/components/home_plus_control/test_init.py Outdated
Comment thread tests/components/home_plus_control/test_switch.py Outdated
Comment thread tests/components/home_plus_control/test_switch.py Outdated
Comment thread tests/components/home_plus_control/test_switch.py Outdated
Comment thread tests/components/home_plus_control/test_switch.py Outdated
Comment thread tests/components/home_plus_control/test_switch.py Outdated
Comment thread tests/components/home_plus_control/test_switch.py Outdated
Comment thread tests/components/home_plus_control/test_switch.py Outdated
Comment thread tests/components/home_plus_control/test_switch.py Outdated
Comment thread tests/components/home_plus_control/test_switch.py Outdated
Comment thread tests/components/home_plus_control/test_switch.py Outdated
Comment thread tests/components/home_plus_control/test_switch.py Outdated
Comment thread tests/components/home_plus_control/test_switch.py Outdated
Copy link
Copy Markdown
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.

Looks good!

Are we ready to merge?

@chemaaa
Copy link
Copy Markdown
Contributor Author

chemaaa commented Mar 25, 2021

Looks good!

Are we ready to merge?

Thanks @MartinHjelmare!

All good on my side 😄 . Let me know if there is anything else I should do in this process (sorry, this is my first PR).

@MartinHjelmare MartinHjelmare merged commit 1b60c8e into home-assistant:dev Mar 25, 2021
@MartinHjelmare
Copy link
Copy Markdown
Member

Good work!

Maybe check if we can make the integration configurable via Home Assistant Cloud Account Linking service to make the set up super easy?
https://developers.home-assistant.io/docs/config_entries_config_flow_handler#configuration-via-oauth2

@github-actions github-actions Bot locked and limited conversation to collaborators Mar 26, 2021
@chemaaa chemaaa deleted the homepluscontrol branch April 5, 2021 10: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.

3 participants