def async_see( opp: OpenPeerPower, mac: str = None, dev_id: str = None, host_name: str = None, location_name: str = None, gps: GPSType = None, gps_accuracy=None, battery: int = None, attributes: dict = None, ): """Call service to notify you see device.""" data = { key: value for key, value in ( (ATTR_MAC, mac), (ATTR_DEV_ID, dev_id), (ATTR_HOST_NAME, host_name), (ATTR_LOCATION_NAME, location_name), (ATTR_GPS, gps), (ATTR_GPS_ACCURACY, gps_accuracy), (ATTR_BATTERY, battery), ) if value is not None } if attributes: data[ATTR_ATTRIBUTES] = attributes opp.async_add_job(opp.services.async_call(DOMAIN, SERVICE_SEE, data))
async def async_setup(opp: OpenPeerPower, config: ConfigType) -> bool: """Set up the HomematicIP Cloud component.""" opp.data[DOMAIN] = {} accesspoints = config.get(DOMAIN, []) for conf in accesspoints: if conf[CONF_ACCESSPOINT] not in { entry.data[HMIPC_HAPID] for entry in opp.config_entries.async_entries(DOMAIN) }: opp.async_add_job( opp.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, data={ HMIPC_HAPID: conf[CONF_ACCESSPOINT], HMIPC_AUTHTOKEN: conf[CONF_AUTHTOKEN], HMIPC_NAME: conf[CONF_NAME], }, )) return True