diff --git a/homeassistant/components/starlink/coordinator.py b/homeassistant/components/starlink/coordinator.py index 7a09b2f2dee..a891941fb8e 100644 --- a/homeassistant/components/starlink/coordinator.py +++ b/homeassistant/components/starlink/coordinator.py @@ -119,12 +119,16 @@ class StarlinkUpdateCoordinator(DataUpdateCoordinator[StarlinkData]): async def async_set_sleep_duration(self, end: int) -> None: """Set Starlink system sleep schedule end time.""" + duration = end - self.data.sleep[0] + if duration < 0: + # If the duration pushed us into the next day, add one days worth to correct that. + duration += 1440 async with asyncio.timeout(4): try: await self.hass.async_add_executor_job( set_sleep_config, self.data.sleep[0], - end, + duration, self.data.sleep[2], self.channel_context, ) diff --git a/homeassistant/components/starlink/time.py b/homeassistant/components/starlink/time.py index 6475610564d..7395ec101ba 100644 --- a/homeassistant/components/starlink/time.py +++ b/homeassistant/components/starlink/time.py @@ -62,6 +62,8 @@ class StarlinkTimeEntity(StarlinkEntity, TimeEntity): def _utc_minutes_to_time(utc_minutes: int, timezone: tzinfo) -> time: hour = math.floor(utc_minutes / 60) + if hour > 23: + hour -= 24 minute = utc_minutes % 60 try: utc = datetime.now(UTC).replace(