[NF] Fixing to new Bot-Utils and create new dependencys
This commit is contained in:
parent
06c8d8159a
commit
a94110fec2
@ -13,22 +13,25 @@ using LitJson;
|
|||||||
|
|
||||||
namespace BlubbFish.IoT.Bots.HueBot.Moduls {
|
namespace BlubbFish.IoT.Bots.HueBot.Moduls {
|
||||||
class Mqtt : Mqtt<HueController> {
|
class Mqtt : Mqtt<HueController> {
|
||||||
|
private Boolean mqttConnect = false;
|
||||||
public override event ModulEvent Update;
|
public override event ModulEvent Update;
|
||||||
|
|
||||||
public Mqtt(HueController hue, InIReader settings) : base(hue, settings) { }
|
public Mqtt(HueController hue, InIReader settings) : base(hue, settings) { }
|
||||||
|
|
||||||
#region Mqtt
|
#region Mqtt
|
||||||
protected override void Connect() {
|
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 = ABackend.GetInstance(this.config["settings"], ABackend.BackendType.Data);
|
||||||
this.mqtt.MessageIncomming += this.EventInput;
|
this.mqtt.MessageIncomming += this.MqttUpdate;
|
||||||
this.library.Update += this.EventOutput;
|
this.mqttConnect = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Disconnect() {
|
protected override void Disconnect() {
|
||||||
|
Console.WriteLine("BlubbFish.IoT.Bots.ZwayBot.Moduls.Mqtt.Disconnect()");
|
||||||
|
this.mqttConnect = false;
|
||||||
if (this.mqtt != null) {
|
if (this.mqtt != null) {
|
||||||
this.mqtt.MessageIncomming -= this.EventInput;
|
this.mqtt.MessageIncomming -= this.MqttUpdate;
|
||||||
}
|
}
|
||||||
this.library.Update -= this.EventOutput;
|
|
||||||
if (this.mqtt != null) {
|
if (this.mqtt != null) {
|
||||||
this.mqtt.Dispose();
|
this.mqtt.Dispose();
|
||||||
}
|
}
|
||||||
@ -37,7 +40,13 @@ namespace BlubbFish.IoT.Bots.HueBot.Moduls {
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Events
|
#region Events
|
||||||
protected virtual void EventOutput(Object sender, AllUpdateEvent e) {
|
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 topic = "";
|
||||||
String data = "";
|
String data = "";
|
||||||
if (e.Parent.GetType().HasInterface(typeof(IMqtt))) {
|
if (e.Parent.GetType().HasInterface(typeof(IMqtt))) {
|
||||||
@ -50,8 +59,10 @@ namespace BlubbFish.IoT.Bots.HueBot.Moduls {
|
|||||||
this.Update?.Invoke(this, new MqttEvent(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"))) {
|
if (e.From.ToString().StartsWith("hue/") && (e.From.ToString().EndsWith("/set") || e.From.ToString().EndsWith("/get"))) {
|
||||||
//return "sensor/" + this.SensorId; (Int32)
|
//return "sensor/" + this.SensorId; (Int32)
|
||||||
//return "scene/" + this.SceneId; (String)
|
//return "scene/" + this.SceneId; (String)
|
||||||
|
@ -32,7 +32,7 @@ using System.Runtime.InteropServices;
|
|||||||
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
|
||||||
// übernehmen, indem Sie "*" eingeben:
|
// übernehmen, indem Sie "*" eingeben:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.1.1")]
|
[assembly: AssemblyVersion("1.1.2")]
|
||||||
[assembly: AssemblyFileVersion("1.1.1")]
|
[assembly: AssemblyFileVersion("1.1.2")]
|
||||||
[assembly: NeutralResourcesLanguage("de-DE")]
|
[assembly: NeutralResourcesLanguage("de-DE")]
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -3,7 +3,7 @@ Version: x.x-x
|
|||||||
Section: base
|
Section: base
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Architecture: any
|
Architecture: any
|
||||||
Depends: mono-complete (>= 5.4.1.6)
|
Depends: mono-runtime (>= 5.16.0)
|
||||||
Maintainer: BlubbFish <dev@blubbfish.net>
|
Maintainer: BlubbFish <dev@blubbfish.net>
|
||||||
Description: Hue-Bot
|
Description: Hue-Bot
|
||||||
Hue-Bot manage a HueBridge
|
Hue-Bot manage a HueBridge
|
||||||
|
Loading…
Reference in New Issue
Block a user