diff --git a/MyCore.Interfaces/DTO/MyControlPanel/AutomationDTO.cs b/MyCore.Interfaces/DTO/MyControlPanel/AutomationDTO.cs index e52105c..ad0fa8e 100644 --- a/MyCore.Interfaces/DTO/MyControlPanel/AutomationDTO.cs +++ b/MyCore.Interfaces/DTO/MyControlPanel/AutomationDTO.cs @@ -10,6 +10,7 @@ namespace MyCore.Interfaces.DTO { public string Id { get; set; } public string Name { get; set; } + public bool Active { get; set; } public string UserId { get; set; } public DateTime CreatedDate { get; set; } public DateTime UpdatedDate { get; set; } diff --git a/MyCore.Interfaces/Models/MyControlPanel/Database/Automation.cs b/MyCore.Interfaces/Models/MyControlPanel/Database/Automation.cs index 2f6731c..b7eda59 100644 --- a/MyCore.Interfaces/Models/MyControlPanel/Database/Automation.cs +++ b/MyCore.Interfaces/Models/MyControlPanel/Database/Automation.cs @@ -23,6 +23,10 @@ namespace MyCore.Interfaces.Models [BsonRequired] public string Name { get; set; } + [BsonElement("Active")] + [BsonRequired] + public bool Active { get; set; } + [BsonElement("CreatedDate")] public DateTime CreatedDate { get; set; } diff --git a/MyCore/Services/AutomationService.cs b/MyCore/Services/AutomationService.cs index 7b29b7d..c8ddc14 100644 --- a/MyCore/Services/AutomationService.cs +++ b/MyCore/Services/AutomationService.cs @@ -22,6 +22,7 @@ namespace MyCore.Service.Services automation.UserId = userId; automation.Name = automationCreateOrUpdateDetailDTO.Name; + automation.Active = automationCreateOrUpdateDetailDTO.Active; automation.CreatedDate = create ? DateTime.Now : automation.CreatedDate; automation.UpdatedDate = DateTime.Now; automation.Triggers = automationCreateOrUpdateDetailDTO.Triggers; diff --git a/MyCore/Services/Devices/ActionService.cs b/MyCore/Services/Devices/ActionService.cs index a06a2af..3093c70 100644 --- a/MyCore/Services/Devices/ActionService.cs +++ b/MyCore/Services/Devices/ActionService.cs @@ -406,13 +406,14 @@ namespace MyCore.Services.Devices System.Console.WriteLine($"Check Action in light|switch ! {state.Name} {state.Value}"); if (actionDeviceExposeForFeatures.features.Any(ade => ade.name == state.Name)) { - if (dic.Count > 0) + // Comment this for test (ensure the request will be sent) + /*if (dic.Count > 0) { if (dic["state"].ToString().ToLower() == state.Value.ToLower() && action.States.Count <= 1) // workaround if brightness not the same { throw new Exception($"Action device is already at the good state : {state.Name} {state.Value}"); } - } + }*/ // TODO clean this if (state.Name == "brightness")