Exemplo n.º 1
0
async def async_get_device_info(pv_request):
    """Determine device info."""
    userdata = UserData(pv_request)
    resources = await userdata.get_resources()
    userdata_data = resources[USER_DATA]

    if FIRMWARE in userdata_data:
        main_processor_info = userdata_data[FIRMWARE][FIRMWARE_MAINPROCESSOR]
    elif userdata_data:
        # Legacy devices
        fwversion = ApiEntryPoint(pv_request, API_PATH_FWVERSION)
        resources = await fwversion.get_resources()

        if FIRMWARE in resources:
            main_processor_info = resources[FIRMWARE][FIRMWARE_MAINPROCESSOR]
        else:
            main_processor_info = DEFAULT_LEGACY_MAINPROCESSOR

    return {
        DEVICE_NAME: base64_to_unicode(userdata_data[HUB_NAME]),
        DEVICE_MAC_ADDRESS: userdata_data[MAC_ADDRESS_IN_USERDATA],
        DEVICE_SERIAL_NUMBER: userdata_data[SERIAL_NUMBER_IN_USERDATA],
        DEVICE_REVISION: main_processor_info[FIRMWARE_REVISION],
        DEVICE_FIRMWARE: main_processor_info,
        DEVICE_MODEL: main_processor_info[FIRMWARE_NAME],
    }
Exemplo n.º 2
0
async def async_get_device_info(pv_request: AioRequest,
                                hub_address: str) -> PowerviewDeviceInfo:
    """Determine device info."""
    userdata = UserData(pv_request)
    resources = await userdata.get_resources()
    userdata_data = resources[USER_DATA]

    if FIRMWARE in userdata_data:
        main_processor_info = userdata_data[FIRMWARE][FIRMWARE_MAINPROCESSOR]
    elif userdata_data:
        # Legacy devices
        fwversion = ApiEntryPoint(pv_request, API_PATH_FWVERSION)
        resources = await fwversion.get_resources()

        if FIRMWARE in resources:
            main_processor_info = resources[FIRMWARE][FIRMWARE_MAINPROCESSOR]
        else:
            main_processor_info = DEFAULT_LEGACY_MAINPROCESSOR

    return PowerviewDeviceInfo(
        name=base64_to_unicode(userdata_data[HUB_NAME]),
        mac_address=userdata_data[MAC_ADDRESS_IN_USERDATA],
        serial_number=userdata_data[SERIAL_NUMBER_IN_USERDATA],
        firmware=main_processor_info,
        model=main_processor_info[FIRMWARE_NAME],
        hub_address=hub_address,
    )
Exemplo n.º 3
0
 def __init__(self, hub_ip, loop, websession=None):
     ApiEntryPoint.__init__(self, loop, websession,
                            get_base_path(hub_ip, URL_ROOMS))
def test_clean_names():
    api = ApiEntryPoint(None, 'abc')
    clean = api._sanitize_resources(test_data1)
Exemplo n.º 5
0
 def __init__(self, hub_ip, loop, websession=None):
     ApiEntryPoint.__init__(self, loop, websession,get_base_path(hub_ip, 'api/userdata'))