Skip to content

Commit

Permalink
Merge pull request #609 from astrandb/VacuumActivity
Browse files Browse the repository at this point in the history
Change to VacuumActivity
  • Loading branch information
astrandb authored Jan 4, 2025
2 parents 6f48193 + f9a52d1 commit f028cbf
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions custom_components/miele/vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@

from homeassistant.components.vacuum import (
ATTR_STATUS,
STATE_CLEANING,
STATE_DOCKED,
STATE_ERROR,
STATE_IDLE,
STATE_PAUSED,
STATE_RETURNING,
StateVacuumEntity,
StateVacuumEntityDescription,
VacuumActivity,
VacuumEntityFeature,
)
from homeassistant.core import HomeAssistant
Expand Down Expand Up @@ -139,24 +134,24 @@ def __init__(
self._attr_fan_speed_list = FAN_SPEEDS

@property
def state(self):
def activity(self) -> VacuumActivity | None:
"""Map state."""
if self.coordinator.data[self._ent]["state|status|value_raw"] == 6:
return STATE_PAUSED
return VacuumActivity.STATE_PAUSED

self._phase = self.coordinator.data[self._ent]["state|programPhase|value_raw"]
if self._phase in (5903, 5904):
return STATE_DOCKED
elif self._phase in (5889, 5892):
return STATE_CLEANING
elif self._phase == 5890:
return STATE_RETURNING
elif self._phase in (5893, 5894, 5895, 5896, 5897, 5898, 5899, 5900):
return STATE_ERROR
elif self._phase in (5891, 5910):
return STATE_PAUSED
elif self._phase == 0:
return STATE_IDLE
return VacuumActivity.STATE_DOCKED
if self._phase in (5889, 5892):
return VacuumActivity.STATE_CLEANING
if self._phase == 5890:
return VacuumActivity.STATE_RETURNING
if self._phase in (5893, 5894, 5895, 5896, 5897, 5898, 5899, 5900):
return VacuumActivity.STATE_ERROR
if self._phase in (5891, 5910):
return VacuumActivity.STATE_PAUSED
if self._phase == 0:
return VacuumActivity.STATE_IDLE

return self._phase

Expand Down

0 comments on commit f028cbf

Please sign in to comment.