diff --git a/Hue-Bot/Moduls/Mqtt.cs b/Hue-Bot/Moduls/Mqtt.cs index 12db3ae..a5cd97b 100644 --- a/Hue-Bot/Moduls/Mqtt.cs +++ b/Hue-Bot/Moduls/Mqtt.cs @@ -13,22 +13,25 @@ using LitJson; namespace BlubbFish.IoT.Bots.HueBot.Moduls { class Mqtt : Mqtt { + private Boolean mqttConnect = false; public override event ModulEvent Update; public Mqtt(HueController hue, InIReader settings) : base(hue, settings) { } #region Mqtt protected override void Connect() { + Console.WriteLine("BlubbFish.IoT.Bots.HueBot.Moduls.Mqtt.Connect()"); this.mqtt = ABackend.GetInstance(this.config["settings"], ABackend.BackendType.Data); - this.mqtt.MessageIncomming += this.EventInput; - this.library.Update += this.EventOutput; + this.mqtt.MessageIncomming += this.MqttUpdate; + this.mqttConnect = true; } protected override void Disconnect() { + Console.WriteLine("BlubbFish.IoT.Bots.ZwayBot.Moduls.Mqtt.Disconnect()"); + this.mqttConnect = false; if (this.mqtt != null) { - this.mqtt.MessageIncomming -= this.EventInput; + this.mqtt.MessageIncomming -= this.MqttUpdate; } - this.library.Update -= this.EventOutput; if (this.mqtt != null) { this.mqtt.Dispose(); } @@ -37,21 +40,29 @@ namespace BlubbFish.IoT.Bots.HueBot.Moduls { #endregion #region Events - protected virtual void EventOutput(Object sender, AllUpdateEvent e) { - String topic = ""; - String data = ""; - if (e.Parent.GetType().HasInterface(typeof(IMqtt))) { - IMqtt sensor = (IMqtt)e.Parent; - topic = "hue/" + sensor.MqttTopic(); - data = sensor.ToJson(); - } - if (topic != "" && data != "") { - ((ADataBackend)this.mqtt).Send(topic, data); - this.Update?.Invoke(this, new MqttEvent(topic, data)); - } + public override void EventLibSetter() { + this.library.Update += this.HandleLibUpdate; + } + protected override void LibUpadteThread(Object state) { + try { + if (this.mqttConnect) { + AllUpdateEvent e = state as AllUpdateEvent; + String topic = ""; + String data = ""; + if (e.Parent.GetType().HasInterface(typeof(IMqtt))) { + IMqtt sensor = (IMqtt)e.Parent; + topic = "hue/" + sensor.MqttTopic(); + data = sensor.ToJson(); + } + if (topic != "" && data != "") { + ((ADataBackend)this.mqtt).Send(topic, data); + this.Update?.Invoke(this, new MqttEvent(topic, data)); + } + } + } catch { } } - private void EventInput(Object sender, BackendEvent e) { + private void MqttUpdate(Object sender, BackendEvent e) { if (e.From.ToString().StartsWith("hue/") && (e.From.ToString().EndsWith("/set") || e.From.ToString().EndsWith("/get"))) { //return "sensor/" + this.SensorId; (Int32) //return "scene/" + this.SceneId; (String) diff --git a/Hue-Bot/Properties/AssemblyInfo.cs b/Hue-Bot/Properties/AssemblyInfo.cs index f5deecb..4a19af3 100644 --- a/Hue-Bot/Properties/AssemblyInfo.cs +++ b/Hue-Bot/Properties/AssemblyInfo.cs @@ -32,7 +32,7 @@ using System.Runtime.InteropServices; // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.1")] -[assembly: AssemblyFileVersion("1.1.1")] +[assembly: AssemblyVersion("1.1.2")] +[assembly: AssemblyFileVersion("1.1.2")] [assembly: NeutralResourcesLanguage("de-DE")] diff --git a/Hue-Bot/bin/Release/Bot-Utils.dll b/Hue-Bot/bin/Release/Bot-Utils.dll index d26685a..ab4d606 100644 Binary files a/Hue-Bot/bin/Release/Bot-Utils.dll and b/Hue-Bot/bin/Release/Bot-Utils.dll differ diff --git a/Hue-Bot/bin/Release/ConnectorDataMqtt.dll b/Hue-Bot/bin/Release/ConnectorDataMqtt.dll index 2fa9646..c0da70b 100644 Binary files a/Hue-Bot/bin/Release/ConnectorDataMqtt.dll and b/Hue-Bot/bin/Release/ConnectorDataMqtt.dll differ diff --git a/Hue-Bot/bin/Release/Hue-Bot.exe b/Hue-Bot/bin/Release/Hue-Bot.exe index 3974311..7a38363 100644 Binary files a/Hue-Bot/bin/Release/Hue-Bot.exe and b/Hue-Bot/bin/Release/Hue-Bot.exe differ diff --git a/Hue-Bot/bin/Release/Hue.dll b/Hue-Bot/bin/Release/Hue.dll index f81273b..d105a8d 100644 Binary files a/Hue-Bot/bin/Release/Hue.dll and b/Hue-Bot/bin/Release/Hue.dll differ diff --git a/Hue-Bot/bin/Release/Iot-Interfaces.dll b/Hue-Bot/bin/Release/Iot-Interfaces.dll index 1924221..e74451b 100644 Binary files a/Hue-Bot/bin/Release/Iot-Interfaces.dll and b/Hue-Bot/bin/Release/Iot-Interfaces.dll differ diff --git a/Hue-Bot/bin/Release/M2Mqtt.dll b/Hue-Bot/bin/Release/M2Mqtt.dll index 707230f..04034d6 100644 Binary files a/Hue-Bot/bin/Release/M2Mqtt.dll and b/Hue-Bot/bin/Release/M2Mqtt.dll differ diff --git a/Hue-Bot/bin/Release/Utils-IoT.dll b/Hue-Bot/bin/Release/Utils-IoT.dll index fb992b7..fdce797 100644 Binary files a/Hue-Bot/bin/Release/Utils-IoT.dll and b/Hue-Bot/bin/Release/Utils-IoT.dll differ diff --git a/Hue-Bot/bin/Release/Utils.dll b/Hue-Bot/bin/Release/Utils.dll index f250fbf..b3a4e24 100644 Binary files a/Hue-Bot/bin/Release/Utils.dll and b/Hue-Bot/bin/Release/Utils.dll differ diff --git a/Hue-Bot/bin/Release/litjson.dll b/Hue-Bot/bin/Release/litjson.dll index f127ee0..9c2f035 100644 Binary files a/Hue-Bot/bin/Release/litjson.dll and b/Hue-Bot/bin/Release/litjson.dll differ diff --git a/Hue-Bot/dpkg/control b/Hue-Bot/dpkg/control index b07e4f0..b3ab3ad 100644 --- a/Hue-Bot/dpkg/control +++ b/Hue-Bot/dpkg/control @@ -3,7 +3,7 @@ Version: x.x-x Section: base Priority: optional Architecture: any -Depends: mono-complete (>= 5.4.1.6) +Depends: mono-runtime (>= 5.16.0) Maintainer: BlubbFish Description: Hue-Bot Hue-Bot manage a HueBridge