Cleanup SmartTub filtration cycles (#47192)
This commit is contained in:
parent
1d7660f071
commit
277c3cb661
2 changed files with 7 additions and 5 deletions
|
@ -7,9 +7,11 @@ from .entity import SmartTubSensorBase
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
# the desired duration, in hours, of the cycle
|
||||
ATTR_DURATION = "duration"
|
||||
ATTR_LAST_UPDATED = "last_updated"
|
||||
ATTR_CYCLE_LAST_UPDATED = "cycle_last_updated"
|
||||
ATTR_MODE = "mode"
|
||||
# the hour of the day at which to start the cycle (0-23)
|
||||
ATTR_START_HOUR = "start_hour"
|
||||
|
||||
|
||||
|
@ -73,7 +75,7 @@ class SmartTubPrimaryFiltrationCycle(SmartTubSensor):
|
|||
state = self._state
|
||||
return {
|
||||
ATTR_DURATION: state.duration,
|
||||
ATTR_LAST_UPDATED: state.last_updated.isoformat(),
|
||||
ATTR_CYCLE_LAST_UPDATED: state.last_updated.isoformat(),
|
||||
ATTR_MODE: state.mode.name.lower(),
|
||||
ATTR_START_HOUR: state.start_hour,
|
||||
}
|
||||
|
@ -98,6 +100,6 @@ class SmartTubSecondaryFiltrationCycle(SmartTubSensor):
|
|||
"""Return the state attributes."""
|
||||
state = self._state
|
||||
return {
|
||||
ATTR_LAST_UPDATED: state.last_updated.isoformat(),
|
||||
ATTR_CYCLE_LAST_UPDATED: state.last_updated.isoformat(),
|
||||
ATTR_MODE: state.mode.name.lower(),
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ async def test_sensors(spa, setup_entry, hass):
|
|||
assert state is not None
|
||||
assert state.state == "inactive"
|
||||
assert state.attributes["duration"] == 4
|
||||
assert state.attributes["last_updated"] is not None
|
||||
assert state.attributes["cycle_last_updated"] is not None
|
||||
assert state.attributes["mode"] == "normal"
|
||||
assert state.attributes["start_hour"] == 2
|
||||
|
||||
|
@ -55,5 +55,5 @@ async def test_sensors(spa, setup_entry, hass):
|
|||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
assert state.state == "inactive"
|
||||
assert state.attributes["last_updated"] is not None
|
||||
assert state.attributes["cycle_last_updated"] is not None
|
||||
assert state.attributes["mode"] == "away"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue