From 910cc2248a9a6275425713cae3e3db0d655db086 Mon Sep 17 00:00:00 2001 From: Seb Ruiz Date: Sun, 26 Jan 2020 07:58:10 +1100 Subject: [PATCH] Fix water started timestamp parsing --- custom_components/bhyve/switch.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/custom_components/bhyve/switch.py b/custom_components/bhyve/switch.py index 6ea0912..1aec610 100644 --- a/custom_components/bhyve/switch.py +++ b/custom_components/bhyve/switch.py @@ -96,14 +96,15 @@ def _setup(self, device): self._attrs[ATTR_IMAGE_URL] = image_url if is_watering: - started_watering_at = watering_status.get( - "started_watering_station_at" - ) + started_watering_at = watering_status.get("started_watering_station_at") self._set_watering_started(started_watering_at) def _set_watering_started(self, timestamp): + _LOGGER.debug("Timestamp is {}".format(timestamp)) if timestamp is not None: - self._attrs[ATTR_STARTED_WATERING_AT] = dt.as_local(dt.as_timestamp(timestamp)) + self._attrs[ATTR_STARTED_WATERING_AT] = dt.as_local( + dt.parse_datetime(timestamp) + ) else: self._attrs[ATTR_STARTED_WATERING_AT] = None @@ -125,9 +126,7 @@ def _on_ws_data(self, data): zone = data.get("current_station") if zone == self._zone_id: self._state = True - started_watering_at = watering_status.get( - "started_watering_station_at" - ) + started_watering_at = data.get("started_watering_station_at") self._set_watering_started(started_watering_at) elif event == "change_mode": program = data.get("program")