diff --git a/Hue/Devices/Lights/Dimmablelight.cs b/Hue/Devices/Lights/Dimmablelight.cs index 688c409..8e93bbb 100644 --- a/Hue/Devices/Lights/Dimmablelight.cs +++ b/Hue/Devices/Lights/Dimmablelight.cs @@ -44,7 +44,7 @@ namespace BlubbFish.IoT.Hue.Devices.Lights { return this._alert; } set { - if(this.SetLightStateAttribute(new Dictionary() { { "alert", value } })) { + if(this.SetLightStateAttribute(new Dictionary() { { "alert", value.ToString() } })) { this._alert = value; this.NotifyClient(value); } diff --git a/Hue/HueController.cs b/Hue/HueController.cs index cc68f8a..ba44b2a 100644 --- a/Hue/HueController.cs +++ b/Hue/HueController.cs @@ -62,6 +62,22 @@ namespace BlubbFish.IoT.Hue { //throw new NotImplementedException(); } + public AConnector GetConnector(String type, String id) { + switch (type) { + case "sensor": + return this.Sensors.ContainsKey(Int32.Parse(id)) ? this.Sensors[Int32.Parse(id)] : null; + case "scene": + return this.Scenes.ContainsKey(id) ? this.Scenes[id] : null; + case "light": + return this.Lights.ContainsKey(Int32.Parse(id)) ? this.Lights[Int32.Parse(id)] : null; + case "group": + return this.Groups.ContainsKey(Int32.Parse(id)) ? this.Groups[Int32.Parse(id)] : null; + case "config": + return this.Config; + } + return null; + } + private void AllUpdate(Object sender, AllUpdateEvent e) { this.Update?.Invoke(sender, e); } diff --git a/Hue/Interfaces/AConfig.cs b/Hue/Interfaces/AConfig.cs index 3fc018e..ca97894 100644 --- a/Hue/Interfaces/AConfig.cs +++ b/Hue/Interfaces/AConfig.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using BlubbFish.IoT.Hue.Devices.Configs; using BlubbFish.IoT.Hue.lib; using LitJson; diff --git a/Hue/Interfaces/AGroup.cs b/Hue/Interfaces/AGroup.cs index ad78e53..ef9e507 100644 --- a/Hue/Interfaces/AGroup.cs +++ b/Hue/Interfaces/AGroup.cs @@ -176,7 +176,7 @@ namespace BlubbFish.IoT.Hue.Interfaces { } public String MqttTopic() { - return "groups/" + this.GroupId + "/" + this.Groupclass.ToString(); + return "group/" + this.GroupId; } #endregion } diff --git a/Hue/Interfaces/ALight.cs b/Hue/Interfaces/ALight.cs index 53d6e31..2bffff3 100644 --- a/Hue/Interfaces/ALight.cs +++ b/Hue/Interfaces/ALight.cs @@ -79,7 +79,7 @@ namespace BlubbFish.IoT.Hue.Interfaces { #region IMqtt public String MqttTopic() { - return "lights/" + this.LightId + "/" + this.Lightclass.ToString(); + return "light/" + this.LightId; } public String ToJson() { diff --git a/Hue/Interfaces/AScene.cs b/Hue/Interfaces/AScene.cs index 35fc321..2c8f7c2 100644 --- a/Hue/Interfaces/AScene.cs +++ b/Hue/Interfaces/AScene.cs @@ -36,7 +36,7 @@ namespace BlubbFish.IoT.Hue.Interfaces { } public String MqttTopic() { - return "groups/" + this.SceneId; + return "scene/" + this.SceneId; } #endregion } diff --git a/Hue/Interfaces/ASensor.cs b/Hue/Interfaces/ASensor.cs index 664fd10..bd10a81 100644 --- a/Hue/Interfaces/ASensor.cs +++ b/Hue/Interfaces/ASensor.cs @@ -6,8 +6,6 @@ using LitJson; namespace BlubbFish.IoT.Hue.Interfaces { public abstract class ASensor : AConnector, IMqtt { - - public enum Types { Daylight } @@ -116,7 +114,7 @@ namespace BlubbFish.IoT.Hue.Interfaces { #region IMqtt public String MqttTopic() { - return "groups/" + this.SensorId + "/" + this.Sensorclass.ToString(); + return "sensor/" + this.SensorId; } public String ToJson() { diff --git a/Hue/bin/Release/Hue.dll b/Hue/bin/Release/Hue.dll index f73a4a4..30deab9 100644 Binary files a/Hue/bin/Release/Hue.dll and b/Hue/bin/Release/Hue.dll differ diff --git a/Hue/bin/Release/litjson.dll b/Hue/bin/Release/litjson.dll index 892f38a..d2229a7 100644 Binary files a/Hue/bin/Release/litjson.dll and b/Hue/bin/Release/litjson.dll differ