using HomeAssistant.Entities.Interfaces; using HomeAssistant.Models; using NetDaemon.Extensions.MqttEntityManager; namespace HomeAssistant.Entities; public class EntityManager(IMqttEntityManager entityManager) : IEntityManager { public async Task CreateEntitiesAsync(ICollection entities) { await Task.WhenAll(entities.Select(CreateEntityAsync)); } public async Task CreateEntityAsync(EntityCreateModel createModel) { if (createModel.EntityId != null) { await entityManager.CreateAsync(createModel.EntityId, createModel.Options, createModel.AdditionalConfig); } } public async Task SetEntityState(string entityId, string state) { await entityManager.SetStateAsync(entityId, state); } public async Task SetEntityAttributes(string entityId, object attributes) { await entityManager.SetAttributesAsync(entityId, attributes); } public async Task RemoveEntity(string entityId) { await entityManager.RemoveAsync(entityId); } }