Fix Islamic prayer sensor timestamp format (#35243)

This commit is contained in:
Rami Mosleh authored and GitHub committed 2020-05-06 15:17:40 +02:00
1 parent 1b3f9254bc
commit 35d8890f4e
4 files changed
+11 -5

No files matched your search

@@ -125,11 +125,11 @@ class IslamicPrayerClient:
"""
_LOGGER.debug("Scheduling next update for Islamic prayer times")
now = dt_util.as_local(dt_util.now())
now = dt_util.utcnow()
midnight_dt = self.prayer_times_info["Midnight"]
if now > dt_util.as_local(midnight_dt):
if now > dt_util.as_utc(midnight_dt):
next_update_at = midnight_dt + timedelta(days=1, minutes=1)
_LOGGER.debug(
"Midnight is after day the changes so schedule update for after Midnight the next day"
@@ -4,6 +4,7 @@ import logging
from homeassistant.const import DEVICE_CLASS_TIMESTAMP
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity
import homeassistant.util.dt as dt_util
from .const import DATA_UPDATED, DOMAIN, PRAYER_TIMES_ICON, SENSOR_TYPES
@@ -48,7 +49,11 @@ class IslamicPrayerTimeSensor(Entity):
@property
def state(self):
"""Return the state of the sensor."""
return self.client.prayer_times_info.get(self.sensor_type).isoformat()
return (
self.client.prayer_times_info.get(self.sensor_type)
.astimezone(dt_util.UTC)
.isoformat()
)
@property
def should_poll(self):