Fix calculation of Starlink sleep end setting (#115507)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
b4f6325278
commit
278751607f
2 changed files with 7 additions and 1 deletions
|
@ -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,
|
||||
)
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Reference in a new issue