def _apply_service(service, service_func, *service_func_args):
 entity_ids = service.data.get('entity_id')
 if entity_ids:
  _devices = [device for device in DEVICES if (device.entity_id in entity_ids)]
 else:
  _devices = DEVICES
 for device in _devices:
  service_func(device, *service_func_args)
  device.update_ha_state(True)

def _apply_service ( service , service_func , * service_func_args ) : entity_ids = service . data . get ( 'entity_id' ) if entity_ids : _devices = [ device for device in DEVICES if ( device . entity_id in entity_ids ) ] else : _devices = DEVICES for device in _devices : service_func ( device , * service_func_args ) device . update_ha_state ( True )
internal func for applying a service .