mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Fix Husqvarna Automower schedule switch turning back on (#117692)
This commit is contained in:
parent
e149aa6b2e
commit
4aecd23f1d
@ -7,8 +7,8 @@ from typing import TYPE_CHECKING, Any
|
|||||||
from aioautomower.exceptions import ApiException
|
from aioautomower.exceptions import ApiException
|
||||||
from aioautomower.model import (
|
from aioautomower.model import (
|
||||||
MowerActivities,
|
MowerActivities,
|
||||||
|
MowerModes,
|
||||||
MowerStates,
|
MowerStates,
|
||||||
RestrictedReasons,
|
|
||||||
StayOutZones,
|
StayOutZones,
|
||||||
Zone,
|
Zone,
|
||||||
)
|
)
|
||||||
@ -86,11 +86,7 @@ class AutomowerScheduleSwitchEntity(AutomowerControlEntity, SwitchEntity):
|
|||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Return the state of the switch."""
|
"""Return the state of the switch."""
|
||||||
attributes = self.mower_attributes
|
return self.mower_attributes.mower.mode != MowerModes.HOME
|
||||||
return not (
|
|
||||||
attributes.mower.state == MowerStates.RESTRICTED
|
|
||||||
and attributes.planner.restricted_reason == RestrictedReasons.NOT_APPLICABLE
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
from aioautomower.exceptions import ApiException
|
from aioautomower.exceptions import ApiException
|
||||||
from aioautomower.model import MowerStates, RestrictedReasons
|
from aioautomower.model import MowerModes
|
||||||
from aioautomower.utils import mower_list_to_dictionary_dataclass
|
from aioautomower.utils import mower_list_to_dictionary_dataclass
|
||||||
from freezegun.api import FrozenDateTimeFactory
|
from freezegun.api import FrozenDateTimeFactory
|
||||||
import pytest
|
import pytest
|
||||||
@ -41,12 +41,11 @@ async def test_switch_states(
|
|||||||
)
|
)
|
||||||
await setup_integration(hass, mock_config_entry)
|
await setup_integration(hass, mock_config_entry)
|
||||||
|
|
||||||
for state, restricted_reson, expected_state in (
|
for mode, expected_state in (
|
||||||
(MowerStates.RESTRICTED, RestrictedReasons.NOT_APPLICABLE, "off"),
|
(MowerModes.HOME, "off"),
|
||||||
(MowerStates.IN_OPERATION, RestrictedReasons.NONE, "on"),
|
(MowerModes.MAIN_AREA, "on"),
|
||||||
):
|
):
|
||||||
values[TEST_MOWER_ID].mower.state = state
|
values[TEST_MOWER_ID].mower.mode = mode
|
||||||
values[TEST_MOWER_ID].planner.restricted_reason = restricted_reson
|
|
||||||
mock_automower_client.get_status.return_value = values
|
mock_automower_client.get_status.return_value = values
|
||||||
freezer.tick(SCAN_INTERVAL)
|
freezer.tick(SCAN_INTERVAL)
|
||||||
async_fire_time_changed(hass)
|
async_fire_time_changed(hass)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user