Skip to content

Commit

Permalink
Fixes from feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mdegat01 committed Sep 17, 2024
1 parent 4d21624 commit 8312ef4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
7 changes: 5 additions & 2 deletions homeassistant/components/hassio/addon_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
from typing import Any, Concatenate

from aiohasupervisor import SupervisorError
from aiohasupervisor.models import InstalledAddonComplete
from aiohasupervisor.models import (
AddonState as SupervisorAddonState,
InstalledAddonComplete,
)

from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
Expand Down Expand Up @@ -172,7 +175,7 @@ def async_get_addon_state(self, addon_info: InstalledAddonComplete) -> AddonStat
"""Return the current state of the managed add-on."""
addon_state = AddonState.NOT_RUNNING

if addon_info.state == "started":
if addon_info.state == SupervisorAddonState.STARTED:
addon_state = AddonState.RUNNING
if self._install_task and not self._install_task.done():
addon_state = AddonState.INSTALLING
Expand Down
13 changes: 7 additions & 6 deletions tests/components/hassio/test_binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,22 +193,23 @@ def mock_all(aioclient_mock: AiohttpClientMocker, addon_installed) -> None:


@pytest.mark.parametrize(
("entity_id", "expected"),
("entity_id", "expected", "addon_state"),
[
("binary_sensor.test_running", "on"),
("binary_sensor.test2_running", "off"),
("binary_sensor.test_running", "on", "started"),
("binary_sensor.test2_running", "off", "stopped"),
],
)
async def test_binary_sensor(
hass: HomeAssistant,
entity_id,
expected,
entity_id: str,
expected: str,
addon_state: str,
aioclient_mock: AiohttpClientMocker,
entity_registry: er.EntityRegistry,
addon_installed: AsyncMock,
) -> None:
"""Test hassio OS and addons binary sensor."""
addon_installed.return_value.state = "started" if expected == "on" else "stopped"
addon_installed.return_value.state = addon_state
config_entry = MockConfigEntry(domain=DOMAIN, data={}, unique_id=DOMAIN)
config_entry.add_to_hass(hass)

Expand Down

0 comments on commit 8312ef4

Please sign in to comment.