/// <inheritdoc/> public Task ExecuteAsync() { List <Task> tasks = new(); foreach (var entityId in _entityIds) { dynamic data = new FluentExpandoObject(); data.entity_id = entityId; data.option = _option; tasks.Add(_daemon.CallServiceAsync("input_select", "select_option", data)); } return(Task.WhenAll(tasks)); }
/// <inheritdoc/> protected async Task CallServiceOnAllEntities(string service, dynamic?serviceData = null) { var taskList = new List <Task>(); foreach (var entityId in EntityIds) { var domain = GetDomainFromEntity(entityId); serviceData ??= new FluentExpandoObject(); serviceData.entity_id = entityId; var task = Daemon.CallServiceAsync(domain, service, serviceData); taskList.Add(task); } if (taskList.Count > 0) { await Task.WhenAny(Task.WhenAll(taskList.ToArray()), Task.Delay(5000)).ConfigureAwait(false); } }