mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Add available and state to SamsungTV remote (#117909)
* Add available and state to SamsungTV remote * Align turn_off * Fix merge * Fix merge (again)
This commit is contained in:
parent
0d5c8e30cd
commit
deded19bb3
@ -51,6 +51,18 @@ class SamsungTVEntity(CoordinatorEntity[SamsungTVDataUpdateCoordinator], Entity)
|
|||||||
}
|
}
|
||||||
self._turn_on_action = PluggableAction(self.async_write_ha_state)
|
self._turn_on_action = PluggableAction(self.async_write_ha_state)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def available(self) -> bool:
|
||||||
|
"""Return the availability of the device."""
|
||||||
|
if self._bridge.auth_failed:
|
||||||
|
return False
|
||||||
|
return (
|
||||||
|
self.coordinator.is_on
|
||||||
|
or bool(self._turn_on_action)
|
||||||
|
or self._mac is not None
|
||||||
|
or self._bridge.power_off_in_progress
|
||||||
|
)
|
||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Connect and subscribe to dispatcher signals and state updates."""
|
"""Connect and subscribe to dispatcher signals and state updates."""
|
||||||
await super().async_added_to_hass()
|
await super().async_added_to_hass()
|
||||||
|
@ -297,18 +297,6 @@ class SamsungTVDevice(SamsungTVEntity, MediaPlayerEntity):
|
|||||||
return
|
return
|
||||||
await self._bridge.async_send_keys(keys)
|
await self._bridge.async_send_keys(keys)
|
||||||
|
|
||||||
@property
|
|
||||||
def available(self) -> bool:
|
|
||||||
"""Return the availability of the device."""
|
|
||||||
if self._bridge.auth_failed:
|
|
||||||
return False
|
|
||||||
return (
|
|
||||||
self.state == MediaPlayerState.ON
|
|
||||||
or bool(self._turn_on_action)
|
|
||||||
or self._mac is not None
|
|
||||||
or self._bridge.power_off_in_progress
|
|
||||||
)
|
|
||||||
|
|
||||||
async def async_turn_off(self) -> None:
|
async def async_turn_off(self) -> None:
|
||||||
"""Turn off media player."""
|
"""Turn off media player."""
|
||||||
await super()._async_turn_off()
|
await super()._async_turn_off()
|
||||||
|
@ -6,7 +6,7 @@ from collections.abc import Iterable
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.components.remote import ATTR_NUM_REPEATS, RemoteEntity
|
from homeassistant.components.remote import ATTR_NUM_REPEATS, RemoteEntity
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import SamsungTVConfigEntry
|
from . import SamsungTVConfigEntry
|
||||||
@ -28,7 +28,12 @@ class SamsungTVRemote(SamsungTVEntity, RemoteEntity):
|
|||||||
"""Device that sends commands to a SamsungTV."""
|
"""Device that sends commands to a SamsungTV."""
|
||||||
|
|
||||||
_attr_name = None
|
_attr_name = None
|
||||||
_attr_should_poll = False
|
|
||||||
|
@callback
|
||||||
|
def _handle_coordinator_update(self) -> None:
|
||||||
|
"""Handle data update."""
|
||||||
|
self._attr_is_on = self.coordinator.is_on
|
||||||
|
self.async_write_ha_state()
|
||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the device off."""
|
"""Turn the device off."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user