Correct philips_js usage of the overloaded coordinator (#66287)

This commit is contained in:
Joakim Plate 2022-02-10 21:59:42 +01:00 committed by GitHub
parent 4d944e35fd
commit ad09e875a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View File

@ -82,7 +82,7 @@ async def async_setup_entry(
class PhilipsTVMediaPlayer(CoordinatorEntity, MediaPlayerEntity): class PhilipsTVMediaPlayer(CoordinatorEntity, MediaPlayerEntity):
"""Representation of a Philips TV exposing the JointSpace API.""" """Representation of a Philips TV exposing the JointSpace API."""
_coordinator: PhilipsTVDataUpdateCoordinator coordinator: PhilipsTVDataUpdateCoordinator
_attr_device_class = MediaPlayerDeviceClass.TV _attr_device_class = MediaPlayerDeviceClass.TV
def __init__( def __init__(
@ -91,7 +91,6 @@ class PhilipsTVMediaPlayer(CoordinatorEntity, MediaPlayerEntity):
) -> None: ) -> None:
"""Initialize the Philips TV.""" """Initialize the Philips TV."""
self._tv = coordinator.api self._tv = coordinator.api
self._coordinator = coordinator
self._sources = {} self._sources = {}
self._channels = {} self._channels = {}
self._supports = SUPPORT_PHILIPS_JS self._supports = SUPPORT_PHILIPS_JS
@ -125,7 +124,7 @@ class PhilipsTVMediaPlayer(CoordinatorEntity, MediaPlayerEntity):
def supported_features(self): def supported_features(self):
"""Flag media player features that are supported.""" """Flag media player features that are supported."""
supports = self._supports supports = self._supports
if self._coordinator.turn_on or ( if self.coordinator.turn_on or (
self._tv.on and self._tv.powerstate is not None self._tv.on and self._tv.powerstate is not None
): ):
supports |= SUPPORT_TURN_ON supports |= SUPPORT_TURN_ON
@ -170,7 +169,7 @@ class PhilipsTVMediaPlayer(CoordinatorEntity, MediaPlayerEntity):
await self._tv.setPowerState("On") await self._tv.setPowerState("On")
self._state = STATE_ON self._state = STATE_ON
else: else:
await self._coordinator.turn_on.async_run(self.hass, self._context) await self.coordinator.turn_on.async_run(self.hass, self._context)
await self._async_update_soon() await self._async_update_soon()
async def async_turn_off(self): async def async_turn_off(self):

View File

@ -30,7 +30,7 @@ async def async_setup_entry(
class PhilipsTVRemote(CoordinatorEntity, RemoteEntity): class PhilipsTVRemote(CoordinatorEntity, RemoteEntity):
"""Device that sends commands.""" """Device that sends commands."""
_coordinator: PhilipsTVDataUpdateCoordinator coordinator: PhilipsTVDataUpdateCoordinator
def __init__( def __init__(
self, self,
@ -63,7 +63,7 @@ class PhilipsTVRemote(CoordinatorEntity, RemoteEntity):
if self._tv.on and self._tv.powerstate: if self._tv.on and self._tv.powerstate:
await self._tv.setPowerState("On") await self._tv.setPowerState("On")
else: else:
await self._coordinator.turn_on.async_run(self.hass, self._context) await self.coordinator.turn_on.async_run(self.hass, self._context)
self.async_write_ha_state() self.async_write_ha_state()
async def async_turn_off(self, **kwargs): async def async_turn_off(self, **kwargs):