def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the Panasonic Viera TV platform.""" from panasonic_viera import RemoteControl name = config.get(CONF_NAME) port = config.get(CONF_PORT) if discovery_info: _LOGGER.debug('%s', discovery_info) vals = discovery_info.split(':') if len(vals) > 1: port = vals[1] host = vals[0] remote = RemoteControl(host, port) add_devices([PanasonicVieraTVDevice(name, remote)]) return True host = config.get(CONF_HOST) remote = RemoteControl(host, port) try: remote.get_mute() except OSError as error: _LOGGER.error('Panasonic Viera TV is not available at %s:%d: %s', host, port, error) return False add_devices([PanasonicVieraTVDevice(name, remote)]) return True
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Panasonic Viera TV platform.""" from panasonic_viera import RemoteControl mac = config.get(CONF_MAC) name = config.get(CONF_NAME) port = config.get(CONF_PORT) app_power = config.get(CONF_APP_POWER) if discovery_info: _LOGGER.debug('%s', discovery_info) name = discovery_info.get('name') host = discovery_info.get('host') port = discovery_info.get('port') udn = discovery_info.get('udn') if udn and udn.startswith('uuid:'): uuid = udn[len('uuid:'):] else: uuid = None remote = RemoteControl(host, port) add_entities([PanasonicVieraTVDevice( mac, name, remote, host, app_power, uuid)]) return True host = config.get(CONF_HOST) remote = RemoteControl(host, port) add_entities([PanasonicVieraTVDevice(mac, name, remote, host, app_power)]) return True
def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the Panasonic Viera TV platform.""" from panasonic_viera import DEFAULT_PORT, RemoteControl name = config.get(CONF_NAME, 'Panasonic Viera TV') port = config.get(CONF_PORT, DEFAULT_PORT) if discovery_info: _LOGGER.debug('%s', discovery_info) vals = discovery_info.split(':') if len(vals) > 1: port = vals[1] host = vals[0] remote = RemoteControl(host, port) add_devices([PanasonicVieraTVDevice(name, remote)]) return True # Validate that all required config options are given if not validate_config({DOMAIN: config}, {DOMAIN: [CONF_HOST]}, _LOGGER): return False host = config.get(CONF_HOST, None) remote = RemoteControl(host, port) try: remote.get_mute() except (socket.timeout, TimeoutError, OSError): _LOGGER.error('Panasonic Viera TV is not available at %s:%d', host, port) return False add_devices([PanasonicVieraTVDevice(name, remote)]) return True
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Panasonic Viera TV platform.""" mac = config.get(CONF_MAC) name = config.get(CONF_NAME) port = config.get(CONF_PORT) app_power = config.get(CONF_APP_POWER) if discovery_info: _LOGGER.debug("%s", discovery_info) name = discovery_info.get("name") host = discovery_info.get("host") port = discovery_info.get("port") udn = discovery_info.get("udn") if udn and udn.startswith("uuid:"): uuid = udn[len("uuid:"):] else: uuid = None remote = RemoteControl(host, port) add_entities( [PanasonicVieraTVDevice(mac, name, remote, host, app_power, uuid)]) return True host = config.get(CONF_HOST) remote = RemoteControl(host, port) add_entities([PanasonicVieraTVDevice(mac, name, remote, host, app_power)]) return True
def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Panasonic Viera TV platform.""" from panasonic_viera import RemoteControl mac = config.get(CONF_MAC) name = config.get(CONF_NAME) port = config.get(CONF_PORT) if discovery_info: _LOGGER.debug('%s', discovery_info) host = discovery_info.get('host') port = discovery_info.get('port') remote = RemoteControl(host, port) add_devices([PanasonicVieraTVDevice(mac, name, remote)]) return True host = config.get(CONF_HOST) remote = RemoteControl(host, port) add_devices([PanasonicVieraTVDevice(mac, name, remote)]) return True
def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the Panasonic Viera TV platform.""" from panasonic_viera import RemoteControl name = config.get(CONF_NAME) port = config.get(CONF_PORT) if discovery_info: _LOGGER.debug('%s', discovery_info) vals = discovery_info.split(':') if len(vals) > 1: port = vals[1] host = vals[0] remote = RemoteControl(host, port) add_devices([PanasonicVieraTVDevice(name, remote)]) return True host = config.get(CONF_HOST) remote = RemoteControl(host, port) try: remote.get_mute() except (socket.timeout, TimeoutError, OSError): _LOGGER.error('Panasonic Viera TV is not available at %s:%d', host, port) return False add_devices([PanasonicVieraTVDevice(name, remote)]) return True