Model Automation (WIP) + Mqtt service logic explanation

This commit is contained in:
Thomas Fransolet 2020-01-15 20:13:40 +01:00
parent 3d4f265e89
commit 0139257a28
4 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace MyCore.Models
{
public class Automation
{
public string Id { get; set; }
public string Name { get; set; }
public List<Declencheur> Declencheurs { get; set; }
public List<Condition> Conditions { get; set; }
public List<Action> Actions { get; set; }
}
public class Declencheur
{
public enum Type
{
MQTT,
WEB,
TIME
}
}
public class Condition
{
public enum Type
{
STATE,
HOUR
}
}
public class Action
{
public enum Type
{
DELAY,
DEVICE
}
}
}

View File

@ -104,6 +104,21 @@ namespace MyCore.Services
var topic = e.ApplicationMessage.Topic;
var payload = Encoding.UTF8.GetString(e.ApplicationMessage.Payload);
// TODO
// Here take only zigbee2mqtt *
// Check if we have the guid in database
// If so retrieve the device in database and his Type
// Retrieve the object
// Check in the list of automations if we have something to do with the message
// Load everydevice in cache.. ? Performance ?
switch (topic)
{
case "zigbee2mqtt/0x00158d00029a7b65":