Skip to content

Conversation

felipecrs
Copy link
Contributor

@felipecrs felipecrs commented Aug 30, 2025

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:

  • Glances (I only check process stats when I suspect something is off)
  • Studio Code Server (it is too heavy to be kept running all the time, and I only need it rarely)
  • Webtop - my new very WIP add-on (runs an entire XFCE Linux desktop accessible through the Ingress but I don't need it all the time)

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.

image
chrome_COyAIu1P8m.mp4

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)
  • Deprecation (breaking change to happen in the future)
  • 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
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format 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.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @home-assistant/supervisor, mind taking a look at this pull request as it has been labeled with an integration (hassio) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of hassio can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign hassio Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

Copilot

This comment was marked as outdated.

@felipecrs felipecrs changed the title Add switch entity to Supervisor add-ons Add a switch entity for add-ons Aug 30, 2025
@felipecrs felipecrs requested a review from Copilot August 30, 2025 21:22
Copilot

This comment was marked as outdated.

@felipecrs felipecrs requested a review from Copilot August 30, 2025 21:39
Copy link
Contributor

@Copilot Copilot AI left a 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

Copy link
Contributor

@wbyoung wbyoung left a 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.

@felipecrs felipecrs requested a review from wbyoung September 1, 2025 20:15
@felipecrs
Copy link
Contributor Author

felipecrs commented Sep 1, 2025

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants