MC Add active statsu to automation + send zigbee request no matter the state

This commit is contained in:
Thomas Fransolet 2021-03-30 16:15:25 +02:00
parent 7a6e2b1540
commit 9c5bc07531
4 changed files with 9 additions and 2 deletions

View File

@ -10,6 +10,7 @@ namespace MyCore.Interfaces.DTO
{ {
public string Id { get; set; } public string Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public bool Active { get; set; }
public string UserId { get; set; } public string UserId { get; set; }
public DateTime CreatedDate { get; set; } public DateTime CreatedDate { get; set; }
public DateTime UpdatedDate { get; set; } public DateTime UpdatedDate { get; set; }

View File

@ -23,6 +23,10 @@ namespace MyCore.Interfaces.Models
[BsonRequired] [BsonRequired]
public string Name { get; set; } public string Name { get; set; }
[BsonElement("Active")]
[BsonRequired]
public bool Active { get; set; }
[BsonElement("CreatedDate")] [BsonElement("CreatedDate")]
public DateTime CreatedDate { get; set; } public DateTime CreatedDate { get; set; }

View File

@ -22,6 +22,7 @@ namespace MyCore.Service.Services
automation.UserId = userId; automation.UserId = userId;
automation.Name = automationCreateOrUpdateDetailDTO.Name; automation.Name = automationCreateOrUpdateDetailDTO.Name;
automation.Active = automationCreateOrUpdateDetailDTO.Active;
automation.CreatedDate = create ? DateTime.Now : automation.CreatedDate; automation.CreatedDate = create ? DateTime.Now : automation.CreatedDate;
automation.UpdatedDate = DateTime.Now; automation.UpdatedDate = DateTime.Now;
automation.Triggers = automationCreateOrUpdateDetailDTO.Triggers; automation.Triggers = automationCreateOrUpdateDetailDTO.Triggers;

View File

@ -406,13 +406,14 @@ namespace MyCore.Services.Devices
System.Console.WriteLine($"Check Action in light|switch ! {state.Name} {state.Value}"); System.Console.WriteLine($"Check Action in light|switch ! {state.Name} {state.Value}");
if (actionDeviceExposeForFeatures.features.Any(ade => ade.name == state.Name)) 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 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}"); throw new Exception($"Action device is already at the good state : {state.Name} {state.Value}");
} }
} }*/
// TODO clean this // TODO clean this
if (state.Name == "brightness") if (state.Name == "brightness")