Skip to content

Register Wemo fan services with entity service helper#44192

Merged
MartinHjelmare merged 6 commits into
home-assistant:devfrom
esev:wemo_singleton
Dec 15, 2020
Merged

Register Wemo fan services with entity service helper#44192
MartinHjelmare merged 6 commits into
home-assistant:devfrom
esev:wemo_singleton

Conversation

@esev
Copy link
Copy Markdown
Contributor

@esev esev commented Dec 13, 2020

Proposed change

Use an entity service helper to register the Wemo fan services. This avoids the custom service_handle that is currently registered in async_setup_entry.

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:

Comment thread homeassistant/components/wemo/fan.py Outdated
Comment thread homeassistant/components/wemo/__init__.py Outdated
@esev
Copy link
Copy Markdown
Contributor Author

esev commented Dec 15, 2020

It would help if I give more background on what I'm hoping to accomplish:
esev@ac80c27#diff-a2d1d17598ff2f03141313777a6ed9b0756b8d6594285b9d9fce370ac007ad50

Only a single config entry is supported.

The future PR above will change the Wemo component to use a config entry per device. I'm trying to separate that large PR into more manageable parts. That PR also adds support for async_unload_entry.

Please implement entity service helper instead.

Is it okay to use a service helper when there are multiple entities? Given the above background, will I run into issues with registering a service multiple times under the same name?

@MartinHjelmare
Copy link
Copy Markdown
Member

I'm not sure that a config entry per device is the best approach. We try to avoid doing that.

@esev
Copy link
Copy Markdown
Contributor Author

esev commented Dec 15, 2020

I'm not sure that a config entry per device is the best approach. We try to avoid doing that.

Doh! This PR may be unnecessary then.

Would you recommend I run the pywemo SSDP discovery periodically in the background? Or is there another way to use the hass SSDP discovery component and maintain a single config entry (is there an example component that does this)?

@MartinHjelmare
Copy link
Copy Markdown
Member

Yes, I'd recommend running the discovery periodically. I'm not sure that there's a standard for reusing the ssdp integration.

@MartinHjelmare
Copy link
Copy Markdown
Member

The entity service helper will make sure to keep track of entities and target the correct one.

@esev esev changed the title Use a singleton for the Wemo registry and fan services Use an entity service helper to register the Wemo fan services Dec 15, 2020
@MartinHjelmare MartinHjelmare changed the title Use an entity service helper to register the Wemo fan services Register Wemo fan services with entity service helper Dec 15, 2020
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.

Great!

@MartinHjelmare MartinHjelmare merged commit 2765c6f into home-assistant:dev Dec 15, 2020
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 16, 2020
@esev esev deleted the wemo_singleton branch August 4, 2021 18:28
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