-
-
Notifications
You must be signed in to change notification settings - Fork 35k
Add a switch entity for add-ons #151431
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
base: dev
Are you sure you want to change the base?
Add a switch entity for add-ons #151431
Conversation
Hey there @home-assistant/supervisor, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
526f9b4
to
bdef888
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a switch entity for Supervisor add-ons that allows users to start and stop add-ons from the Home Assistant interface. This provides a more convenient way to control add-ons compared to navigating through the Settings menu.
Key changes:
- Adds a new switch platform for add-ons with start/stop functionality
- Implements proper state management and coordinator data refresh
- Includes comprehensive test coverage for the new functionality
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
homeassistant/components/hassio/__init__.py |
Adds switch platform to the list of available platforms |
homeassistant/components/hassio/switch.py |
Implements the switch entity for add-ons with turn on/off methods |
homeassistant/components/hassio/coordinator.py |
Adds method to force refresh addon data after state changes |
tests/components/hassio/test_switch.py |
Comprehensive test suite covering switch state and turn on/off operations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be nice to maintainers to try making this change before they review in full.
What do you mean by that? What change exactly? |
Disclaimer: I used Grok Code Fast 1 to help me get this PR started. I then reviewed thoroughly and made changes.
Proposed change
This PR adds a switch entity for Supervisor add-ons.
The switch entity reflects whether the add-on is running or not, and allows to start or stop the add-on depending on its current state.
My main motivation with this is that I have several add-ons that don't need to be running all the time. Some of them I start, do something, then stop, so that it does not keep consuming resources in background. Some of them are:
Having to reach the add-on page (Settings > Add-ons > Glances) is too much work. Now I can build my own dashboard for the add-ons I need to turn on/off, which should make this a lot easier.
Not to mention it is now much easier to automate, by simply using the
switch
actions rather than Supervisor's custom actions.chrome_COyAIu1P8m.mp4
Type of change
Additional information
Checklist
ruff format 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
.To help with the load of incoming pull requests: