mirror of
https://github.com/sudoxnym/roomba_rest980.git
synced 2026-04-14 11:37:46 +00:00
Don't show mission start time, if it's a previous command and not active
This commit is contained in:
parent
8d62f4b534
commit
cad8af474b
2 changed files with 20 additions and 10 deletions
|
|
@ -4,7 +4,7 @@
|
|||
"codeowners": [
|
||||
"@ia74"
|
||||
],
|
||||
"version": "1.7.1",
|
||||
"version": "1.8.0",
|
||||
"config_flow": true,
|
||||
"dependencies": [],
|
||||
"dhcp": [
|
||||
|
|
|
|||
|
|
@ -288,17 +288,27 @@ class RoombaMissionStartTime(RoombaSensor):
|
|||
"""Update sensor when coordinator data changes."""
|
||||
data = self.coordinator.data or {}
|
||||
status = data.get("cleanMissionStatus", {})
|
||||
missionStartTime = status.get("mssnStrtTm") # Unix timestamp in seconds?
|
||||
# Mission State
|
||||
phase = status.get("phase")
|
||||
battery = data.get("batPct")
|
||||
|
||||
if missionStartTime:
|
||||
self._attr_available = True
|
||||
try:
|
||||
self._attr_native_value = dt_util.utc_from_timestamp(missionStartTime)
|
||||
except (TypeError, ValueError):
|
||||
self._attr_native_value = None
|
||||
else:
|
||||
self._attr_native_value = None
|
||||
if phase == "charge" and battery == 100:
|
||||
self._attr_available = False
|
||||
self._attr_native_value = None
|
||||
else:
|
||||
missionStartTime = status.get("mssnStrtTm") # Unix timestamp in seconds?
|
||||
|
||||
if missionStartTime:
|
||||
self._attr_available = True
|
||||
try:
|
||||
self._attr_native_value = dt_util.utc_from_timestamp(
|
||||
missionStartTime
|
||||
)
|
||||
except (TypeError, ValueError):
|
||||
self._attr_native_value = None
|
||||
else:
|
||||
self._attr_native_value = None
|
||||
self._attr_available = False
|
||||
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue