(api_key, session: ClientSession, device_label="")
return result
Get list of available SmartThings devices
Get list of available SmartThings devices
Get list of available SmartThings devices
async def get_devices_list(api_key, session: ClientSession, device_label=""):
        """Get list of available SmartThings devices"""

        result = {}

        async with session.get(
            API_DEVICES, headers=_headers(api_key), raise_for_status=True,
        ) as resp:
            device_list = await resp.json()

        if device_list:
            _LOGGER.debug("SmartThings available devices: %s", str(device_list))

            for k in device_list.get("items", []):
                device_id = k.get("deviceId", "")
                device_type = k.get("type", "")
                device_type_id = k.get("deviceTypeId", "")
                if device_id and (
                    device_type_id == DEVICE_TYPEID_OCF
                    or device_type == DEVICE_TYPE_OCF
                ):
                    label = k.get("label", "")
                    if device_label == "" or (label == device_label and label != ""):
                        result[device_id] = {
                            "name": k.get("name", ""),
                            "label": label,
                        }

        _LOGGER.info("SmartThings discovered TV devices: %s", str(result))

        return result
async def get_devices_list ( api_key , session : ClientSession , device_label = "" ) : result = { } async with session . get ( API_DEVICES , headers = _headers ( api_key ) , raise_for_status = True , ) as resp : device_list = await resp . json ( ) if device_list : _LOGGER . debug ( "SmartThings available devices: %s" , str ( device_list ) ) for k in device_list . get ( "items" , [ ] ) : device_id = k . get ( "deviceId" , "" ) device_type = k . get ( "type" , "" ) device_type_id = k . get ( "deviceTypeId" , "" ) if device_id and ( device_type_id == DEVICE_TYPEID_OCF or device_type == DEVICE_TYPE_OCF ) : label = k . get ( "label" , "" ) if device_label == "" or ( label == device_label and label != "" ) : result [ device_id ] = { "name" : k . get ( "name" , "" ) , "label" : label , } _LOGGER . info ( "SmartThings discovered TV devices: %s" , str ( result ) ) return result