def __init__(self, aftv, name, apps, get_sources, turn_on_command, turn_off_command): """Initialize the Android TV / Fire TV device.""" self.aftv = aftv self._name = name self._app_id_to_name = APPS.copy() self._app_id_to_name.update(apps) self._app_name_to_id = { value: key for key, value in self._app_id_to_name.items() } self._get_sources = get_sources self._keys = KEYS self._device_properties = self.aftv.device_properties self._unique_id = self._device_properties.get("serialno") self.turn_on_command = turn_on_command self.turn_off_command = turn_off_command # ADB exceptions to catch if not self.aftv.adb_server_ip: # Using "adb_shell" (Python ADB implementation) self.exceptions = ( AttributeError, BrokenPipeError, TypeError, ValueError, InvalidChecksumError, InvalidCommandError, InvalidResponseError, TcpTimeoutException, ) else: # Using "pure-python-adb" (communicate with ADB server) self.exceptions = (ConnectionResetError, RuntimeError) # Property attributes self._adb_response = None self._available = True self._current_app = None self._sources = None self._state = None
def __init__(self, aftv, name, apps, turn_on_command, turn_off_command): """Initialize the Android TV / Fire TV device.""" self.aftv = aftv self._name = name self._apps = APPS.copy() self._apps.update(apps) self._keys = KEYS self.turn_on_command = turn_on_command self.turn_off_command = turn_off_command # ADB exceptions to catch if not self.aftv.adb_server_ip: # Using "python-adb" (Python ADB implementation) from adb.adb_protocol import ( InvalidChecksumError, InvalidCommandError, InvalidResponseError, ) from adb.usb_exceptions import TcpTimeoutException self.exceptions = ( AttributeError, BrokenPipeError, TypeError, ValueError, InvalidChecksumError, InvalidCommandError, InvalidResponseError, TcpTimeoutException, ) else: # Using "pure-python-adb" (communicate with ADB server) self.exceptions = (ConnectionResetError, RuntimeError) # Property attributes self._adb_response = None self._available = self.aftv.available self._current_app = None self._state = None
def _process_config(self): """Load the config options.""" _LOGGER.debug("Loading configuration options") options = self.hass.data[DOMAIN][self._entry_id][ANDROID_DEV_OPT] apps = options.get(CONF_APPS, {}) self._app_id_to_name = APPS.copy() self._app_id_to_name.update(apps) self._app_name_to_id = { value: key for key, value in self._app_id_to_name.items() if value } # Make sure that apps overridden via the `apps` parameter are reflected # in `self._app_name_to_id` for key, value in apps.items(): self._app_name_to_id[value] = key self._get_sources = options.get(CONF_GET_SOURCES, DEFAULT_GET_SOURCES) self._exclude_unnamed_apps = options.get(CONF_EXCLUDE_UNNAMED_APPS, DEFAULT_EXCLUDE_UNNAMED_APPS) self._screencap = options.get(CONF_SCREENCAP, DEFAULT_SCREENCAP) self.turn_off_command = options.get(CONF_TURN_OFF_COMMAND) self.turn_on_command = options.get(CONF_TURN_ON_COMMAND)
def __init__( self, aftv, name, apps, get_sources, turn_on_command, turn_off_command, exclude_unnamed_apps, screencap, ): """Initialize the Android TV / Fire TV device.""" self.aftv = aftv self._name = name self._app_id_to_name = APPS.copy() self._app_id_to_name.update(apps) self._app_name_to_id = { value: key for key, value in self._app_id_to_name.items() if value } # Make sure that apps overridden via the `apps` parameter are reflected # in `self._app_name_to_id` for key, value in apps.items(): self._app_name_to_id[value] = key self._get_sources = get_sources self._keys = KEYS self._device_properties = self.aftv.device_properties self._unique_id = self._device_properties.get("serialno") self.turn_on_command = turn_on_command self.turn_off_command = turn_off_command self._exclude_unnamed_apps = exclude_unnamed_apps self._screencap = screencap # ADB exceptions to catch if not self.aftv.adb_server_ip: # Using "adb_shell" (Python ADB implementation) self.exceptions = ( AdbTimeoutError, BrokenPipeError, ConnectionResetError, ValueError, InvalidChecksumError, InvalidCommandError, InvalidResponseError, TcpTimeoutException, ) else: # Using "pure-python-adb" (communicate with ADB server) self.exceptions = (ConnectionResetError, RuntimeError) # Property attributes self._adb_response = None self._available = True self._current_app = None self._sources = None self._state = None self._hdmi_input = None