static void ParseShelly(string Topic, string Payload) { string[] Top = Topic.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); string ID = Top[1]; string SubTopic = ""; if (ID == "announce") { return; } if (Topic.Count(C => C == '/') >= 2) { SubTopic = Topic.Substring(Topic.IndexOf('/', Topic.IndexOf('/') + 1) + 1); } HomeDevice Dev = SmartHome.GetOrCreateDevice(ID, ID); if (Dev != null) { Dev.ReceiveUpdateProperty(SubTopic, Payload); } ActionsParser.TriggerEvent(Topic, Payload); }
static void Main(string[] args) { //Test(); //return; Logging.Init(); Tasks.Init(); SmartHome.Init(); ActionsParser.Init(); MQTT.Init(); NancyHost Host = new NancyHost(new Uri("http://localhost:8080")); Host.Start(); //Application.EnableVisualStyles(); //Application.Run(new MainForm()); while (true) { Tasks.Tick(); Thread.Sleep(250); } }