def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the Onkyo platform.""" import eiscp from eiscp import eISCP hosts = [] if CONF_HOST in config and config[CONF_HOST] not in KNOWN_HOSTS: try: hosts.append( OnkyoDevice(eiscp.eISCP(config[CONF_HOST]), config.get(CONFIG_SOURCE_LIST, DEFAULT_SOURCES), name=config[CONF_NAME])) KNOWN_HOSTS.append(config[CONF_HOST]) except OSError: _LOGGER.error('Unable to connect to receiver at %s.', config[CONF_HOST]) else: for receiver in eISCP.discover(): if receiver.host not in KNOWN_HOSTS: hosts.append( OnkyoDevice( receiver, config.get(CONFIG_SOURCE_LIST, DEFAULT_SOURCES))) KNOWN_HOSTS.append(receiver.host) add_devices(hosts)
def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Onkyo platform.""" import eiscp from eiscp import eISCP host = config.get(CONF_HOST) hosts = [] if CONF_HOST in config and host not in KNOWN_HOSTS: try: hosts.append( OnkyoDevice( eiscp.eISCP(host), config.get(CONF_SOURCES), name=config.get(CONF_NAME), max_volume=config.get(CONF_MAX_VOLUME), )) KNOWN_HOSTS.append(host) # Add Zone2 if configured if config.get(CONF_ZONE2): _LOGGER.debug("Setting up zone 2") hosts.append( OnkyoDeviceZone2(eiscp.eISCP(host), config.get(CONF_SOURCES), name=config.get(CONF_NAME) + " Zone 2")) except OSError: _LOGGER.error("Unable to connect to receiver at %s", host) else: for receiver in eISCP.discover(): if receiver.host not in KNOWN_HOSTS: hosts.append(OnkyoDevice(receiver, config.get(CONF_SOURCES))) KNOWN_HOSTS.append(receiver.host) add_devices(hosts, True)
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Onkyo platform.""" import eiscp from eiscp import eISCP host = config.get(CONF_HOST) hosts = [] def service_handle(service): """Handle for services.""" entity_ids = service.data.get(ATTR_ENTITY_ID) devices = [d for d in hosts if d.entity_id in entity_ids] for device in devices: if service.service == SERVICE_SELECT_HDMI_OUTPUT: device.select_output(service.data.get(ATTR_HDMI_OUTPUT)) hass.services.register( DOMAIN, SERVICE_SELECT_HDMI_OUTPUT, service_handle, schema=ONKYO_SELECT_OUTPUT_SCHEMA) if CONF_HOST in config and host not in KNOWN_HOSTS: try: receiver = eiscp.eISCP(host) hosts.append(OnkyoDevice( receiver, config.get(CONF_SOURCES), name=config.get(CONF_NAME), max_volume=config.get(CONF_MAX_VOLUME), )) KNOWN_HOSTS.append(host) zones = determine_zones(receiver) # Add Zone2 if available if zones["zone2"]: _LOGGER.debug("Setting up zone 2") hosts.append(OnkyoDeviceZone( "2", receiver, config.get(CONF_SOURCES), name="{} Zone 2".format(config[CONF_NAME]))) # Add Zone3 if available if zones["zone3"]: _LOGGER.debug("Setting up zone 3") hosts.append(OnkyoDeviceZone( "3", receiver, config.get(CONF_SOURCES), name="{} Zone 3".format(config[CONF_NAME]))) except OSError: _LOGGER.error("Unable to connect to receiver at %s", host) else: for receiver in eISCP.discover(): if receiver.host not in KNOWN_HOSTS: hosts.append(OnkyoDevice(receiver, config.get(CONF_SOURCES))) KNOWN_HOSTS.append(receiver.host) add_entities(hosts, True)
def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Onkyo platform.""" import eiscp from eiscp import eISCP host = config.get(CONF_HOST) hosts = [] if CONF_HOST in config and host not in KNOWN_HOSTS: try: receiver = eiscp.eISCP(host) hosts.append( OnkyoDevice( receiver, config.get(CONF_SOURCES), name=config.get(CONF_NAME), max_volume=config.get(CONF_MAX_VOLUME), )) KNOWN_HOSTS.append(host) zones = determine_zones(receiver) # Add Zone2 if available if zones["zone2"]: _LOGGER.debug("Setting up zone 2") hosts.append( OnkyoDeviceZone("2", receiver, config.get(CONF_SOURCES), name="{} Zone 2".format( config[CONF_NAME]))) # Add Zone3 if available if zones["zone3"]: _LOGGER.debug("Setting up zone 3") hosts.append( OnkyoDeviceZone("3", receiver, config.get(CONF_SOURCES), name="{} Zone 3".format( config[CONF_NAME]))) except OSError: _LOGGER.error("Unable to connect to receiver at %s", host) else: for receiver in eISCP.discover(): if receiver.host not in KNOWN_HOSTS: hosts.append(OnkyoDevice(receiver, config.get(CONF_SOURCES))) KNOWN_HOSTS.append(receiver.host) add_devices(hosts, True)
def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Onkyo platform.""" import eiscp from eiscp import eISCP host = config.get(CONF_HOST) hosts = [] if CONF_HOST in config and host not in KNOWN_HOSTS: try: receiver = eiscp.eISCP(host) hosts.append(OnkyoDevice( receiver, config.get(CONF_SOURCES), name=config.get(CONF_NAME), max_volume=config.get(CONF_MAX_VOLUME), )) KNOWN_HOSTS.append(host) zones = determine_zones(receiver) # Add Zone2 if available if zones["zone2"]: _LOGGER.debug("Setting up zone 2") hosts.append(OnkyoDeviceZone( "2", receiver, config.get(CONF_SOURCES), name="{} Zone 2".format(config[CONF_NAME]))) # Add Zone3 if available if zones["zone3"]: _LOGGER.debug("Setting up zone 3") hosts.append(OnkyoDeviceZone( "3", receiver, config.get(CONF_SOURCES), name="{} Zone 3".format(config[CONF_NAME]))) except OSError: _LOGGER.error("Unable to connect to receiver at %s", host) else: for receiver in eISCP.discover(): if receiver.host not in KNOWN_HOSTS: hosts.append(OnkyoDevice(receiver, config.get(CONF_SOURCES))) KNOWN_HOSTS.append(receiver.host) add_devices(hosts, True)
def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the Onkyo platform.""" import eiscp from eiscp import eISCP host = config.get(CONF_HOST) hosts = [] if CONF_HOST in config and host not in KNOWN_HOSTS: try: hosts.append(OnkyoDevice(eiscp.eISCP(host), config.get(CONF_SOURCES), name=config.get(CONF_NAME))) KNOWN_HOSTS.append(host) except OSError: _LOGGER.error("Unable to connect to receiver at %s.", host) else: for receiver in eISCP.discover(): if receiver.host not in KNOWN_HOSTS: hosts.append(OnkyoDevice(receiver, config.get(CONF_SOURCES))) KNOWN_HOSTS.append(receiver.host) add_devices(hosts)
def setup_platform(hass, config, add_entities, discovery_info=None): """Set up the Onkyo platform.""" host = config.get(CONF_HOST) hosts = [] def service_handle(service): """Handle for services.""" entity_ids = service.data.get(ATTR_ENTITY_ID) devices = [d for d in hosts if d.entity_id in entity_ids] for device in devices: if service.service == SERVICE_SELECT_HDMI_OUTPUT: device.select_output(service.data.get(ATTR_HDMI_OUTPUT)) hass.services.register( DOMAIN, SERVICE_SELECT_HDMI_OUTPUT, service_handle, schema=ONKYO_SELECT_OUTPUT_SCHEMA, ) if CONF_HOST in config and host not in KNOWN_HOSTS: try: receiver = eiscp.eISCP(host) hosts.append( OnkyoDevice( receiver, config.get(CONF_SOURCES), name=config.get(CONF_NAME), max_volume=config.get(CONF_MAX_VOLUME), receiver_max_volume=config.get(CONF_RECEIVER_MAX_VOLUME), )) KNOWN_HOSTS.append(host) zones = determine_zones(receiver) # Add Zone2 if available if zones["zone2"]: _LOGGER.debug("Setting up zone 2") hosts.append( OnkyoDeviceZone( "2", receiver, config.get(CONF_SOURCES), name=f"{config[CONF_NAME]} Zone 2", max_volume=config.get(CONF_MAX_VOLUME), receiver_max_volume=config.get( CONF_RECEIVER_MAX_VOLUME), )) # Add Zone3 if available if zones["zone3"]: _LOGGER.debug("Setting up zone 3") hosts.append( OnkyoDeviceZone( "3", receiver, config.get(CONF_SOURCES), name=f"{config[CONF_NAME]} Zone 3", max_volume=config.get(CONF_MAX_VOLUME), receiver_max_volume=config.get( CONF_RECEIVER_MAX_VOLUME), )) except OSError: _LOGGER.error("Unable to connect to receiver at %s", host) else: for receiver in eISCP.discover(): if receiver.host not in KNOWN_HOSTS: hosts.append(OnkyoDevice(receiver, config.get(CONF_SOURCES))) KNOWN_HOSTS.append(receiver.host) add_entities(hosts, True)
def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the Onkyo platform.""" from eiscp import eISCP add_devices(OnkyoDevice(receiver) for receiver in eISCP.discover())
if zones["zone3"]: _LOGGER.debug("Setting up zone 3") hosts.append( OnkyoDeviceZone( "3", receiver, config.get(CONF_SOURCES), name=f"{config[CONF_NAME]} Zone 3", max_volume=config.get(CONF_MAX_VOLUME), receiver_max_volume=config.get(CONF_RECEIVER_MAX_VOLUME), ) ) except OSError: _LOGGER.error("Unable to connect to receiver at %s", host) else: for receiver in eISCP.discover(): if receiver.host not in KNOWN_HOSTS: hosts.append(OnkyoDevice(receiver, config.get(CONF_SOURCES))) KNOWN_HOSTS.append(receiver.host) add_entities(hosts, True) class OnkyoDevice(MediaPlayerEntity): """Representation of an Onkyo device.""" def __init__( self, receiver, sources, name=None, max_volume=SUPPORTED_MAX_VOLUME,