-
-
Notifications
You must be signed in to change notification settings - Fork 28.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into bugfix/task-endtime
- Loading branch information
Showing
409 changed files
with
8,975 additions
and
3,660 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
"""Base entity for Android TV Remote.""" | ||
from __future__ import annotations | ||
|
||
from androidtvremote2 import AndroidTVRemote, ConnectionClosed | ||
|
||
from homeassistant.config_entries import ConfigEntry | ||
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME | ||
from homeassistant.core import callback | ||
from homeassistant.exceptions import HomeAssistantError | ||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC | ||
from homeassistant.helpers.entity import DeviceInfo, Entity | ||
|
||
from .const import DOMAIN | ||
|
||
|
||
class AndroidTVRemoteBaseEntity(Entity): | ||
"""Android TV Remote Base Entity.""" | ||
|
||
_attr_has_entity_name = True | ||
_attr_should_poll = False | ||
|
||
def __init__(self, api: AndroidTVRemote, config_entry: ConfigEntry) -> None: | ||
"""Initialize the entity.""" | ||
self._api = api | ||
self._host = config_entry.data[CONF_HOST] | ||
self._name = config_entry.data[CONF_NAME] | ||
self._attr_unique_id = config_entry.unique_id | ||
self._attr_is_on = api.is_on | ||
device_info = api.device_info | ||
assert config_entry.unique_id | ||
assert device_info | ||
self._attr_device_info = DeviceInfo( | ||
connections={(CONNECTION_NETWORK_MAC, config_entry.data[CONF_MAC])}, | ||
identifiers={(DOMAIN, config_entry.unique_id)}, | ||
name=self._name, | ||
manufacturer=device_info["manufacturer"], | ||
model=device_info["model"], | ||
) | ||
|
||
@callback | ||
def _is_available_updated(self, is_available: bool) -> None: | ||
"""Update the state when the device is ready to receive commands or is unavailable.""" | ||
self._attr_available = is_available | ||
self.async_write_ha_state() | ||
|
||
@callback | ||
def _is_on_updated(self, is_on: bool) -> None: | ||
"""Update the state when device turns on or off.""" | ||
self._attr_is_on = is_on | ||
self.async_write_ha_state() | ||
|
||
async def async_added_to_hass(self) -> None: | ||
"""Register callbacks.""" | ||
self._api.add_is_available_updated_callback(self._is_available_updated) | ||
self._api.add_is_on_updated_callback(self._is_on_updated) | ||
|
||
async def async_will_remove_from_hass(self) -> None: | ||
"""Remove callbacks.""" | ||
self._api.remove_is_available_updated_callback(self._is_available_updated) | ||
self._api.remove_is_on_updated_callback(self._is_on_updated) | ||
|
||
def _send_key_command(self, key_code: str, direction: str = "SHORT") -> None: | ||
"""Send a key press to Android TV. | ||
This does not block; it buffers the data and arranges for it to be sent out asynchronously. | ||
""" | ||
try: | ||
self._api.send_key_command(key_code, direction) | ||
except ConnectionClosed as exc: | ||
raise HomeAssistantError( | ||
"Connection to Android TV device is closed" | ||
) from exc | ||
|
||
def _send_launch_app_command(self, app_link: str) -> None: | ||
"""Launch an app on Android TV. | ||
This does not block; it buffers the data and arranges for it to be sent out asynchronously. | ||
""" | ||
try: | ||
self._api.send_launch_app_command(app_link) | ||
except ConnectionClosed as exc: | ||
raise HomeAssistantError( | ||
"Connection to Android TV device is closed" | ||
) from exc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
{ | ||
"domain": "androidtv_remote", | ||
"name": "Android TV Remote", | ||
"codeowners": ["@tronikos"], | ||
"codeowners": ["@tronikos", "@Drafteed"], | ||
"config_flow": true, | ||
"documentation": "https://www.home-assistant.io/integrations/androidtv_remote", | ||
"integration_type": "device", | ||
"iot_class": "local_push", | ||
"loggers": ["androidtvremote2"], | ||
"quality_scale": "platinum", | ||
"requirements": ["androidtvremote2==0.0.7"], | ||
"requirements": ["androidtvremote2==0.0.8"], | ||
"zeroconf": ["_androidtvremote2._tcp.local."] | ||
} |
Oops, something went wrong.