[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 {
|
||||
class Mqtt : Mqtt<HueController> {
|
||||
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)
|
||||
|
@ -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")]
|
||||
|
||||
|
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
|
||||
Priority: optional
|
||||
Architecture: any
|
||||
Depends: mono-complete (>= 5.4.1.6)
|
||||
Depends: mono-runtime (>= 5.16.0)
|
||||
Maintainer: BlubbFish <dev@blubbfish.net>
|
||||
Description: Hue-Bot
|
||||
Hue-Bot manage a HueBridge
|
||||
|
Loading…
Reference in New Issue
Block a user