mirror of
https://bitbucket.org/myhomie/mycorerepository.git
synced 2025-12-06 09:41:19 +00:00
73 lines
1.4 KiB
C#
73 lines
1.4 KiB
C#
using MongoDB.Bson;
|
|
using MongoDB.Bson.Serialization.Attributes;
|
|
using MyCore.DTO.Common;
|
|
using MyCore.DTO.MyControlPanel;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace MyCore.Models
|
|
{
|
|
/// <summary>
|
|
/// Automation
|
|
/// </summary>
|
|
public class Automation
|
|
{
|
|
[BsonId]
|
|
[BsonRepresentation(BsonType.ObjectId)]
|
|
public string Id { get; set; }
|
|
|
|
[BsonElement("Name")]
|
|
[BsonRequired]
|
|
public string Name { get; set; }
|
|
|
|
[BsonElement("Triggers")]
|
|
public List<Trigger> Triggers { get; set; }
|
|
|
|
[BsonElement("Conditions")]
|
|
public List<Condition> Conditions { get; set; }
|
|
|
|
[BsonElement("Actions")]
|
|
public List<Action> Actions { get; set; }
|
|
|
|
public AutomationDTO ToDTO()
|
|
{
|
|
return new AutomationDTO()
|
|
{
|
|
Id = Id,
|
|
Name = Name,
|
|
//Triggers = Triggers
|
|
//Conditions = Conditions
|
|
//Actions = Actions
|
|
};
|
|
}
|
|
}
|
|
|
|
public class Trigger
|
|
{
|
|
public enum Type
|
|
{
|
|
MQTT,
|
|
WEB,
|
|
TIME
|
|
}
|
|
}
|
|
|
|
public class Condition
|
|
{
|
|
public enum Type
|
|
{
|
|
STATE,
|
|
HOUR
|
|
}
|
|
}
|
|
|
|
public class Action
|
|
{
|
|
public enum Type
|
|
{
|
|
DELAY,
|
|
DEVICE
|
|
}
|
|
}
|
|
}
|