Add Plugwise USB-stick integration#35713
Conversation
There was a problem hiding this comment.
Nice to see core integration for the older plugs as wel @brefra
Do note that core reviewers may want to start with only one platform per PR so you might have to begin with either sensor or switch but not both. If you indicate clearly that these should only be merged/released together they can add such indications. (We're following that path with plugwise as well now where we will have four platforms).
See this line in config_flow scaffolding.
|
@CoMPaTech thanks for the comment. |
On ours one of the core reviewers added a line in the initial comment about not merging on/before date. Just drop a clear comment in that this PR is intended to have a follow-up PR with your Submitter has a followup PR to add |
1b53a01 to
b21016a
Compare
2cb9f44 to
087582c
Compare
This comment has been minimized.
This comment has been minimized.
| ) | ||
| errors = await validate_connection(self.hass, device_path) | ||
| if not errors: | ||
| return self.async_create_entry( |
There was a problem hiding this comment.
You should add add this before return self.async_create_entry():
await self.async_set_unique_id("unique_id", raise_on_progress=False)
self._abort_if_unique_id_configured()
The config_flow also needs a unique_id, otherwise you will be able to add the integration more than once. Also, there will be issues when adding a 2nd Stick. I know, unlikely, but there's always someone that will do this :)
There was a problem hiding this comment.
Thanks, I'll add an unique_id to the the config entry.
| else: | ||
| device_path = await self.hass.async_add_executor_job( | ||
| get_serial_by_id, user_selection | ||
| ) |
There was a problem hiding this comment.
Suggestion: here you could add something like:
for entry in self._async_current_entries():
if entry.data.get("parameter") == user_input["parameter"]:
return self.async_abort(reason="already_configured")
This, together with the unique_id, see below, stops the possibility of adding a configuration 2 times.
This requires also a few addition lines in string.json.
There was a problem hiding this comment.
I do prevent adding the same USB-stick in a manually started second config flow at L103-L105 together with L18-L24 which gives a nice error message:

I'm not sure it is user friendly to abort the config flow instead. To me aborting the configflow seems to be only usefull when automatic discovery triggers the config flow, which is not the case for serial devices.
There was a problem hiding this comment.
Very good! Then please ignore my comment.
|
We normally integrate all devices from the same brand within the same integration. If there are different protocols in use we use different logic paths for the different protocols and let the user pick the device category to integrate if needed. |
|
@CoMPaTech & @bouwew do you think it feasible to integrate the support for the legacy USB-stick into the current Plugwise integration as Martin suggests? |
|
Prologue: Bouwe and me sort of discussed this already seeing the comment made, but didn't conclude anything yet. Enjoying 0.115 and some food/drinks with family while enjoying the sun was a higher priority most of this weekend :) So below my take on it. In summary/tldr: combining forces (for us and HA) and a single yet clear-to-configure component (for users) seems like a good idea and community spirit. I guess we should (@MartinHjelmare please confirm) mostly create 'network' vs 'usb' versions of both the current Aside from that, we should remember that you toned down your PR to just Just quickly again sifting through the PR
Side question - do we keep both |
|
Yes, if we can't detect automatically somehow what device has been connected, we can let the user pick the correct integration method, usb or network etc, in the config flow. |
Yup, but what if it is configured manually? Just create two seperate forms in |
|
Yes, that sounds good. |
|
@brefra, as @CoMPaTech has written in many words ;) yes we think it's feasible. @brefra are you on Discord? |
|
Great, I'll accept the challenge to "merge" this PR into the current Plugwise integration, and agree to start with a merged custom_component. I do have discord account (brefra), but not really an active user to be honest. |
|
We have made some initial progress in our beta-environment, from that: we created a preparation PR (#41201) to allow for integration of USB. Further PRs will be made to have this PR (and the original wider platform support) included, currently the rough outline of this is in https://github.com/plugwise/plugwise-beta/pull/117/files where we welcomed @brefra as a member too to streamline our combined efforts. @MartinHjelmare if your time allows #41201 provides scaffolding for the |
|
Marked as draft until alternative PR for the existing |
|
@brefra Let's close this PR now that the replacement-PR is up. |
Breaking change
None
Proposed change
This PR adds support for legacy Plugwise Circle+, Circle and Stealth devices. These devices are controlled by using a UBS-stick which communicates directly to the devices. More details is written down in the related documentation PR.
This first PR is based on this custom integration, published in HACS. It contains the switch platform to control the power relays. In future PR's the sensor platform will be added to support multiple sensors (mainly) related to the power consumption.
Type of change
Example entry for
configuration.yaml:No yaml example as it depends on config flow.
# Example configuration.yamlAdditional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale: