コード例 #1
0
def find_devices():
    devices = HdhrUtility.discover_find_devices_custom()

    for device in devices:
        print("Found: %s" % (device))

    return devices
コード例 #2
0
async def async_setup_entry(hass, config_entry, async_add_entities):
    """Set up HDHomeRun from a config entry."""
    hosts = hass.data[DOMAIN].get(SENSOR_DOMAIN)
    devices = []

    if hosts:
        # Priority 1: manual config
        for host in hosts:
            ip = host[CONF_HOST]
            _LOGGER.debug('Fetching devices for manually-configured host: ' +
                          ip)
            devices.extend(HdhrUtility.discover_find_devices_custom(ip=ip))
    else:
        # Priority 2: scanned devices
        _LOGGER.debug('Scanning network for HDHomeRun devices')
        devices = HdhrUtility.discover_find_devices_custom()

    entities = []

    for device in devices:
        device_id = device.nice_device_id
        tuner_count = device.tuner_count
        _LOGGER.debug("Detected %d tuners for device: %s" %
                      (tuner_count, device_id))

        adapter = HdhrDeviceQuery(
            HdhrUtility.device_create_from_str(device_id))

        device_info = {
            'identifiers': {(DOMAIN, device_id)},
            'name': 'HDHomeRun ' + device_id,
            'manufacturer': 'SiliconDust',
            'model': adapter.get_model_str(),
            'sw_version': adapter.get_version(),
        }

        for tuner in range(0, tuner_count):
            tuner_str = "%s-%d" % (device_id, tuner)
            entities.append(TunerSensor(device_info, tuner_str))

    async_add_entities(entities, update_before_add=True)

    return True
コード例 #3
0
async def _async_has_devices(hass):
    """Return if there are devices that can be discovered."""
    hdhr_devices = HdhrUtility.discover_find_devices_custom()
    return len(hdhr_devices) > 0