custom_components/xiaomi_miot_raw/__init__.py
def async_service_handler(self, service):
        """Map services to methods on XiaomiMiioDevice."""
        method = SERVICE_TO_METHOD.get(service.service)
        params = {
            key: value for key, value in service.data.items() if key != ATTR_ENTITY_ID
        }
        entity_ids = service.data.get(ATTR_ENTITY_ID)
        if entity_ids:
            devices = [
                device
                for device in self.hass.data[DOMAIN]['entities'].values()
                if device.entity_id in entity_ids
            ]
        else:
            # devices = hass.data[DOMAIN]['entities'].values()
            devices = []
            _LOGGER.error("No entity_id specified.")

        update_tasks = []
        for device in devices:
            yield from getattr(device, method["method"])(**params)
            update_tasks.append(device.async_update_ha_state(True))

        if update_tasks:
            yield from asyncio.wait(update_tasks, loop=self.hass.loop)
Map services to methods on XiaomiMiioDevice.
Map services to methods on XiaomiMiioDevice.
Map services to methods on XiaomiMiioDevice .
def async_service_handler(self, service):
        method = SERVICE_TO_METHOD.get(service.service)
        params = {
            key: value for key, value in service.data.items() if key != ATTR_ENTITY_ID
        }
        entity_ids = service.data.get(ATTR_ENTITY_ID)
        if entity_ids:
            devices = [
                device
                for device in self.hass.data[DOMAIN]['entities'].values()
                if device.entity_id in entity_ids
            ]
        else:
            devices = []
            _LOGGER.error("No entity_id specified.")
        update_tasks = []
        for device in devices:
            yield from getattr(device, method["method"])(**params)
            update_tasks.append(device.async_update_ha_state(True))
        if update_tasks:
            yield from asyncio.wait(update_tasks, loop=self.hass.loop)
def async_service_handler ( self , service ) : method = SERVICE_TO_METHOD . get ( service . service ) params = { key : value for key , value in service . data . items ( ) if key != ATTR_ENTITY_ID } entity_ids = service . data . get ( ATTR_ENTITY_ID ) if entity_ids : devices = [ device for device in self . hass . data [ DOMAIN ] [ 'entities' ] . values ( ) if device . entity_id in entity_ids ] else : devices = [ ] _LOGGER . error ( "No entity_id specified." ) update_tasks = [ ] for device in devices : yield from getattr ( device , method [ "method" ] ) ( ** params ) update_tasks . append ( device . async_update_ha_state ( True ) ) if update_tasks : yield from asyncio . wait ( update_tasks , loop = self . hass . loop )
Map services to methods on XiaomiMiioDevice.
Map services to methods on XiaomiMiioDevice .
"""Map services to methods on XiaomiMiioDevice.""" # devices = hass.data[DOMAIN]['entities'].values()
self
service