Fix husqvarna_automower_ble activity mapping (#151228)

This commit is contained in:
Erik Montnemery
2025-08-27 10:37:32 +02:00
committed by GitHub
parent 2abb914867
commit bfd4f85225
2 changed files with 16 additions and 1 deletions

View File

@@ -73,6 +73,10 @@ class AutomowerLawnMower(HusqvarnaAutomowerBleEntity, LawnMowerEntity):
if state in (MowerState.STOPPED, MowerState.OFF, MowerState.WAIT_FOR_SAFETYPIN): if state in (MowerState.STOPPED, MowerState.OFF, MowerState.WAIT_FOR_SAFETYPIN):
# This is actually stopped, but that isn't an option # This is actually stopped, but that isn't an option
return LawnMowerActivity.ERROR return LawnMowerActivity.ERROR
if state == MowerState.PENDING_START and activity == MowerActivity.NONE:
# This happens when the mower is safety stopped and we try to send a
# command to start it.
return LawnMowerActivity.ERROR
if state in ( if state in (
MowerState.RESTRICTED, MowerState.RESTRICTED,
MowerState.IN_OPERATION, MowerState.IN_OPERATION,

View File

@@ -156,7 +156,7 @@ OPERATIONAL_STATES = [
# Operational states are mapped according to the activity # Operational states are mapped according to the activity
( (
OPERATIONAL_STATES, OPERATIONAL_STATES,
[MowerActivity.CHARGING, MowerActivity.NONE, MowerActivity.PARKED], [MowerActivity.CHARGING, MowerActivity.PARKED],
LawnMowerActivity.DOCKED, LawnMowerActivity.DOCKED,
), ),
( (
@@ -174,6 +174,17 @@ OPERATIONAL_STATES = [
[MowerActivity.STOPPED_IN_GARDEN], [MowerActivity.STOPPED_IN_GARDEN],
LawnMowerActivity.ERROR, LawnMowerActivity.ERROR,
), ),
# Special case for MowerActivity.NONE
(
[MowerState.IN_OPERATION, MowerState.RESTRICTED],
[MowerActivity.NONE],
LawnMowerActivity.DOCKED,
),
(
[MowerState.PENDING_START],
[MowerActivity.NONE],
LawnMowerActivity.ERROR,
),
], ],
) )
async def test_mower_activity_mapping( async def test_mower_activity_mapping(