Cleanup SmartTub filtration cycles (#47192)

This commit is contained in:
Matt Zimmerman 2021-02-28 15:53:57 -08:00 committed by GitHub
parent 1d7660f071
commit 277c3cb661
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View file

@ -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(),
}

View file

@ -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"