diff --git a/homeassistant/components/islamic_prayer_times/__init__.py b/homeassistant/components/islamic_prayer_times/__init__.py index fa676221ea3..90a31890d16 100644 --- a/homeassistant/components/islamic_prayer_times/__init__.py +++ b/homeassistant/components/islamic_prayer_times/__init__.py @@ -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" diff --git a/homeassistant/components/islamic_prayer_times/sensor.py b/homeassistant/components/islamic_prayer_times/sensor.py index 92a0a491d8d..e0c2cf16f68 100644 --- a/homeassistant/components/islamic_prayer_times/sensor.py +++ b/homeassistant/components/islamic_prayer_times/sensor.py @@ -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): diff --git a/tests/components/islamic_prayer_times/__init__.py b/tests/components/islamic_prayer_times/__init__.py index db25428d17a..a8b68b98715 100644 --- a/tests/components/islamic_prayer_times/__init__.py +++ b/tests/components/islamic_prayer_times/__init__.py @@ -42,4 +42,4 @@ NEW_PRAYER_TIMES_TIMESTAMPS = { "Midnight": datetime(2020, 1, 1, 00, 43, 0), } -NOW = datetime(2020, 1, 1, 00, 00, 0) +NOW = datetime(2020, 1, 1, 00, 00, 0).astimezone() diff --git a/tests/components/islamic_prayer_times/test_sensor.py b/tests/components/islamic_prayer_times/test_sensor.py index 147d7e6ef1d..3ee6a59136a 100644 --- a/tests/components/islamic_prayer_times/test_sensor.py +++ b/tests/components/islamic_prayer_times/test_sensor.py @@ -1,5 +1,6 @@ """The tests for the Islamic prayer times sensor platform.""" from homeassistant.components import islamic_prayer_times +import homeassistant.util.dt as dt_util from . import NOW, PRAYER_TIMES, PRAYER_TIMES_TIMESTAMPS @@ -25,5 +26,5 @@ async def test_islamic_prayer_times_sensors(hass): hass.states.get( f"sensor.{prayer}_{islamic_prayer_times.const.SENSOR_TYPES[prayer]}" ).state - == PRAYER_TIMES_TIMESTAMPS[prayer].isoformat() + == PRAYER_TIMES_TIMESTAMPS[prayer].astimezone(dt_util.UTC).isoformat() )