Skip to content

Commit

Permalink
fix: change return state to avoid Invalid Date
Browse files Browse the repository at this point in the history
Closes #419
  • Loading branch information
alandtse committed Oct 12, 2019
1 parent cf44ab8 commit 0744d7d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions custom_components/alexa_media/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def should_poll(self):
def state(self):
"""Return the state of the sensor."""
return self._next[self._sensor_property].replace(
tzinfo=LOCAL_TIMEZONE) if self._next else 'None'
tzinfo=LOCAL_TIMEZONE) if self._next else None

@property
def unit_of_measurement(self):
Expand Down Expand Up @@ -344,7 +344,7 @@ def state(self) -> datetime.datetime:
"""Return the state of the sensor."""
return dt.as_local(dt.utc_from_timestamp(
dt.utcnow().timestamp() +
self._next[self._sensor_property]/1000)) if self._next else 'None'
self._next[self._sensor_property]/1000)) if self._next else None

@property
def paused(self) -> bool:
Expand Down Expand Up @@ -377,7 +377,7 @@ def state(self):
"""Return the state of the sensor."""
return dt.as_local(datetime.datetime.fromtimestamp(
self._next[self._sensor_property]/1000,
tz=LOCAL_TIMEZONE)) if self._next else 'None'
tz=LOCAL_TIMEZONE)) if self._next else None

@property
def reminder(self):
Expand Down

0 comments on commit 0744d7d

Please sign in to comment.