示例#1
0
def get_devices_from_response_dict(response_dict, filter_key):
    """
    :rtype: list of WinkDevice
    """
    items = response_dict.get('data')

    devices = []

    keys = DEVICE_ID_KEYS.values()
    if filter_key:
        keys = [filter_key]

    api_interface = WinkApiInterface()

    for item in items:
        for key in keys:
            if not __device_is_visible(item, key):
                continue

            if key == "powerstrip_id":
                devices.extend(__get_outlets_from_powerstrip(item, api_interface))
                continue  # Don't capture the powerstrip itself as a device, only the individual outlets

            if key == "sensor_pod_id":
                subsensors = _get_subsensors_from_sensor_pod(item, api_interface)
                if subsensors:
                    devices.extend(subsensors)

            devices.append(build_device(item, api_interface))

    return devices
示例#2
0
def get_devices_from_response_dict(response_dict, filter_key):
    """
    :rtype: list of WinkDevice
    """
    items = response_dict.get('data')

    devices = []

    keys = DEVICE_ID_KEYS.values()
    if filter_key:
        keys = [filter_key]

    api_interface = WinkApiInterface()

    for item in items:
        for key in keys:
            if not __device_is_visible(item, key):
                continue

            if key == "powerstrip_id":
                devices.extend(
                    __get_outlets_from_powerstrip(item, api_interface))
                continue  # Don't capture the powerstrip itself as a device, only the individual outlets

            if key == "sensor_pod_id":
                subsensors = _get_subsensors_from_sensor_pod(
                    item, api_interface)
                if subsensors:
                    devices.extend(subsensors)

            devices.append(build_device(item, api_interface))

    return devices
示例#3
0
def __get_sensor_from_hub(item, api_interface, filter_key):
    if filter_key != 'hub_id':
        return []
    keys = list(DEVICE_ID_KEYS.values())
    # Most devices have a hub_id, but we only want the actual hub.
    # This will only return hubs by checking for any other keys
    # being present along with the hub_id
    skip = False
    for key in keys:
        if key == "hub_id":
            continue
        if item.get(key, None) is not None:
            skip = True
    if skip:
        return []
    else:
        return [WinkHub(item, api_interface)]
示例#4
0
def __get_sensor_from_hub(item, api_interface, filter_key):
    if filter_key != 'hub_id':
        return []
    keys = list(DEVICE_ID_KEYS.values())
    # Most devices have a hub_id, but we only want the actual hub.
    # This will only return hubs by checking for any other keys
    # being present along with the hub_id
    skip = False
    for key in keys:
        if key == "hub_id":
            continue
        if item.get(key, None) is not None:
            skip = True
    if skip:
        return []
    else:
        return [WinkHub(item, api_interface)]