Fix Husqvarna Automower schedule switch turning back on (#117692)
This commit is contained in:
parent
e149aa6b2e
commit
4aecd23f1d
2 changed files with 7 additions and 12 deletions
|
@ -7,8 +7,8 @@ from typing import TYPE_CHECKING, Any
|
|||
from aioautomower.exceptions import ApiException
|
||||
from aioautomower.model import (
|
||||
MowerActivities,
|
||||
MowerModes,
|
||||
MowerStates,
|
||||
RestrictedReasons,
|
||||
StayOutZones,
|
||||
Zone,
|
||||
)
|
||||
|
@ -86,11 +86,7 @@ class AutomowerScheduleSwitchEntity(AutomowerControlEntity, SwitchEntity):
|
|||
@property
|
||||
def is_on(self) -> bool:
|
||||
"""Return the state of the switch."""
|
||||
attributes = self.mower_attributes
|
||||
return not (
|
||||
attributes.mower.state == MowerStates.RESTRICTED
|
||||
and attributes.planner.restricted_reason == RestrictedReasons.NOT_APPLICABLE
|
||||
)
|
||||
return self.mower_attributes.mower.mode != MowerModes.HOME
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
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 freezegun.api import FrozenDateTimeFactory
|
||||
import pytest
|
||||
|
@ -41,12 +41,11 @@ async def test_switch_states(
|
|||
)
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
for state, restricted_reson, expected_state in (
|
||||
(MowerStates.RESTRICTED, RestrictedReasons.NOT_APPLICABLE, "off"),
|
||||
(MowerStates.IN_OPERATION, RestrictedReasons.NONE, "on"),
|
||||
for mode, expected_state in (
|
||||
(MowerModes.HOME, "off"),
|
||||
(MowerModes.MAIN_AREA, "on"),
|
||||
):
|
||||
values[TEST_MOWER_ID].mower.state = state
|
||||
values[TEST_MOWER_ID].planner.restricted_reason = restricted_reson
|
||||
values[TEST_MOWER_ID].mower.mode = mode
|
||||
mock_automower_client.get_status.return_value = values
|
||||
freezer.tick(SCAN_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
|
|
Loading…
Add table
Reference in a new issue