mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Only run philips_js notify service while TV is turned on (#51196)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com> Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
00507539c1
commit
b6cb123c4f
@ -116,8 +116,21 @@ class PhilipsTVDataUpdateCoordinator(DataUpdateCoordinator[None]):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _notify_wanted(self):
|
||||||
|
"""Return if the notify feature should be active.
|
||||||
|
|
||||||
|
We only run it when TV is considered fully on. When powerstate is in standby, the TV
|
||||||
|
will go in low power states and seemingly break the http server in odd ways.
|
||||||
|
"""
|
||||||
|
return (
|
||||||
|
self.api.on
|
||||||
|
and self.api.powerstate == "On"
|
||||||
|
and self.api.notify_change_supported
|
||||||
|
)
|
||||||
|
|
||||||
async def _notify_task(self):
|
async def _notify_task(self):
|
||||||
while self.api.on and self.api.notify_change_supported:
|
while self._notify_wanted:
|
||||||
res = await self.api.notifyChange(130)
|
res = await self.api.notifyChange(130)
|
||||||
if res:
|
if res:
|
||||||
self.async_set_updated_data(None)
|
self.async_set_updated_data(None)
|
||||||
@ -133,11 +146,10 @@ class PhilipsTVDataUpdateCoordinator(DataUpdateCoordinator[None]):
|
|||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_notify_schedule(self):
|
def _async_notify_schedule(self):
|
||||||
if (
|
if self._notify_future and not self._notify_future.done():
|
||||||
(self._notify_future is None or self._notify_future.done())
|
return
|
||||||
and self.api.on
|
|
||||||
and self.api.notify_change_supported
|
if self._notify_wanted:
|
||||||
):
|
|
||||||
self._notify_future = asyncio.create_task(self._notify_task())
|
self._notify_future = asyncio.create_task(self._notify_task())
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
|
Loading…
x
Reference in New Issue
Block a user