[NF] Tiny fix for mqtt

This commit is contained in:
BlubbFish 2017-12-17 21:53:16 +00:00
parent d7f27fad4f
commit db935e019c
15 changed files with 57 additions and 55 deletions

View File

@ -12,7 +12,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
/// </summary> /// </summary>
public class Battery : ACommandClass { public class Battery : ACommandClass {
public Single Level { get; private set; } public Double Level { get; private set; }
public override event UpdatedValue Update; public override event UpdatedValue Update;
@ -24,12 +24,12 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
Boolean success = false; Boolean success = false;
if (match.Groups[4].Value == ".data") { if (match.Groups[4].Value == ".data") {
if (json.Keys.Contains("last") && json["last"].Keys.Contains("value")) { if (json.Keys.Contains("last") && json["last"].Keys.Contains("value")) {
this.Level = Single.Parse(json["last"]["value"].ToString()); this.Level = Double.Parse(json["last"]["value"].ToString());
success = true; success = true;
} }
} else if (match.Groups[4].Value == ".data.last") { } else if (match.Groups[4].Value == ".data.last") {
if (json.Keys.Contains("value")) { if (json.Keys.Contains("value")) {
this.Level = Single.Parse(json["value"].ToString()); this.Level = Double.Parse(json["value"].ToString());
success = true; success = true;
} }
} else if (match.Groups[4].Value.StartsWith(".data.history.")) { } else if (match.Groups[4].Value.StartsWith(".data.history.")) {
@ -44,7 +44,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
private void InitComplex(JsonData json) { private void InitComplex(JsonData json) {
if (json.Keys.Contains("data") && json["data"].Keys.Contains("last") && json["data"]["last"].Keys.Contains("value")) { if (json.Keys.Contains("data") && json["data"].Keys.Contains("last") && json["data"]["last"].Keys.Contains("value")) {
this.Level = Single.Parse(json["data"]["last"]["value"].ToString()); this.Level = Double.Parse(json["data"]["last"]["value"].ToString());
} }
} }
@ -54,7 +54,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
public override Dictionary<String, Object> ToDictionary() { public override Dictionary<String, Object> ToDictionary() {
return new Dictionary<String, Object> { return new Dictionary<String, Object> {
{ "level", this.Level.ToString() }, { "level", this.Level },
}; };
} }
} }

View File

@ -78,8 +78,8 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
public override Dictionary<String, Object> ToDictionary() { public override Dictionary<String, Object> ToDictionary() {
return new Dictionary<String, Object> { return new Dictionary<String, Object> {
{ "scene", this.Scene.ToString() }, { "scene", this.Scene },
{ "key", this.Key.ToString() }, { "key", this.Key },
}; };
} }
} }

View File

@ -61,8 +61,8 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
public override Dictionary<String, Object> ToDictionary() { public override Dictionary<String, Object> ToDictionary() {
return new Dictionary<String, Object> { return new Dictionary<String, Object> {
{ "level", this.Level.ToString() }, { "level", this.Level },
{ "size", this.Size.ToString() }, { "size", this.Size },
}; };
} }
} }

View File

@ -11,7 +11,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
public override event UpdatedValue Update; public override event UpdatedValue Update;
public String Type { get; private set; } public String Type { get; private set; }
public Single Level { get; private set; } public Double Level { get; private set; }
public String Scale { get; private set; } public String Scale { get; private set; }
public Metersub(JsonData json, Tuple<Int32, Int32, Classes, Int32> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) { public Metersub(JsonData json, Tuple<Int32, Int32, Classes, Int32> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
this.HasReset = true; this.HasReset = true;
@ -27,7 +27,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
json.Keys.Contains("scaleString") && json.Keys.Contains("scaleString") &&
json["scaleString"].Keys.Contains("value")) { json["scaleString"].Keys.Contains("value")) {
this.Type = json["sensorTypeString"]["value"].ToString(); this.Type = json["sensorTypeString"]["value"].ToString();
this.Level = Single.Parse(json["val"]["value"].ToString()); this.Level = Double.Parse(json["val"]["value"].ToString());
this.Scale = json["scaleString"]["value"].ToString(); this.Scale = json["scaleString"]["value"].ToString();
} }
} }
@ -37,10 +37,10 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
json.Keys.Contains("sensorTypeString") && json["sensorTypeString"].Keys.Contains("value") && json.Keys.Contains("sensorTypeString") && json["sensorTypeString"].Keys.Contains("value") &&
json.Keys.Contains("scaleString") && json["scaleString"].Keys.Contains("value") && json.Keys.Contains("scaleString") && json["scaleString"].Keys.Contains("value") &&
this.CheckSetUpdateTime(json)) { this.CheckSetUpdateTime(json)) {
this.Level = Single.Parse(json["val"]["value"].ToString()); this.Level = Double.Parse(json["val"]["value"].ToString());
this.Type = json["sensorTypeString"]["value"].ToString(); this.Type = json["sensorTypeString"]["value"].ToString();
this.Scale = json["scaleString"]["value"].ToString(); this.Scale = json["scaleString"]["value"].ToString();
this.Update?.Invoke(this, new DeviceUpdateEvent(new Tuple<String, String, Single>(this.Type, this.Scale, this.Level), this.LastUpdate, this)); this.Update?.Invoke(this, new DeviceUpdateEvent(new Tuple<String, String, Double>(this.Type, this.Scale, this.Level), this.LastUpdate, this));
} }
} }
@ -52,7 +52,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
public override Dictionary<String, Object> ToDictionary() { public override Dictionary<String, Object> ToDictionary() {
return new Dictionary<String, Object> { return new Dictionary<String, Object> {
{ "level", this.Level.ToString() }, { "level", this.Level },
{ "type", this.Type }, { "type", this.Type },
{ "scale", this.Scale }, { "scale", this.Scale },
}; };

View File

@ -11,7 +11,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
public override event UpdatedValue Update; public override event UpdatedValue Update;
public String Type { get; private set; } public String Type { get; private set; }
public Single Level { get; private set; } public Double Level { get; private set; }
public String Scale { get; private set; } public String Scale { get; private set; }
public Sensormultilevelsub(JsonData json, Tuple<Int32, Int32, Classes, Int32> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) { public Sensormultilevelsub(JsonData json, Tuple<Int32, Int32, Classes, Int32> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
@ -27,7 +27,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
json.Keys.Contains("scaleString") && json.Keys.Contains("scaleString") &&
json["scaleString"].Keys.Contains("value")) { json["scaleString"].Keys.Contains("value")) {
this.Type = json["sensorTypeString"]["value"].ToString(); this.Type = json["sensorTypeString"]["value"].ToString();
this.Level = Single.Parse(json["val"]["value"].ToString()); this.Level = Double.Parse(json["val"]["value"].ToString());
this.Scale = json["scaleString"]["value"].ToString(); this.Scale = json["scaleString"]["value"].ToString();
} }
} }
@ -37,10 +37,10 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
json.Keys.Contains("sensorTypeString") && json["sensorTypeString"].Keys.Contains("value") && json.Keys.Contains("sensorTypeString") && json["sensorTypeString"].Keys.Contains("value") &&
json.Keys.Contains("scaleString") && json["scaleString"].Keys.Contains("value") && json.Keys.Contains("scaleString") && json["scaleString"].Keys.Contains("value") &&
this.CheckSetUpdateTime(json)) { this.CheckSetUpdateTime(json)) {
this.Level = Single.Parse(json["val"]["value"].ToString()); this.Level = Double.Parse(json["val"]["value"].ToString());
this.Type = json["sensorTypeString"]["value"].ToString(); this.Type = json["sensorTypeString"]["value"].ToString();
this.Scale = json["scaleString"]["value"].ToString(); this.Scale = json["scaleString"]["value"].ToString();
this.Update?.Invoke(this, new DeviceUpdateEvent(new Tuple<String, String, Single>(this.Type, this.Scale, this.Level), this.LastUpdate, this)); this.Update?.Invoke(this, new DeviceUpdateEvent(new Tuple<String, String, Double>(this.Type, this.Scale, this.Level), this.LastUpdate, this));
} }
} }
@ -52,7 +52,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
public override Dictionary<String, Object> ToDictionary() { public override Dictionary<String, Object> ToDictionary() {
return new Dictionary<String, Object> { return new Dictionary<String, Object> {
{ "level", this.Level.ToString() }, { "level", this.Level },
{ "type", this.Type }, { "type", this.Type },
{ "scale", this.Scale }, { "scale", this.Scale },
}; };

View File

@ -10,20 +10,20 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
class Thermostatsetpointsub : ACommandClass { class Thermostatsetpointsub : ACommandClass {
public override event UpdatedValue Update; public override event UpdatedValue Update;
private Single _level; private Double _level;
public Single Level { public Double Level {
get { get {
return this._level; return this._level;
} }
set { set {
if (!this.HasMinMax || (this.HasMinMax && value >= this.TempMin && value <= this.TempMax)) { if (!this.HasMinMax || (this.HasMinMax && value >= this.TempMin && value <= this.TempMax)) {
this.SetTuple(this.SensorId, (Single)Math.Round(value * 2, MidpointRounding.AwayFromZero) / 2); this.SetTuple(this.SensorId, (Double)Math.Round(value * 2, MidpointRounding.AwayFromZero) / 2);
} }
} }
} }
public String Scale { get; private set; } public String Scale { get; private set; }
public Single TempMax { get; private set; } public Double TempMax { get; private set; }
public Single TempMin { get; private set; } public Double TempMin { get; private set; }
public Boolean HasMinMax { get; private set; } public Boolean HasMinMax { get; private set; }
public String Type { get; private set; } public String Type { get; private set; }
@ -37,13 +37,13 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
json.Keys.Contains("val") && json["val"].Keys.Contains("value") && json.Keys.Contains("val") && json["val"].Keys.Contains("value") &&
json.Keys.Contains("deviceScaleString") && json["deviceScaleString"].Keys.Contains("value")) { json.Keys.Contains("deviceScaleString") && json["deviceScaleString"].Keys.Contains("value")) {
this.Type = json["modeName"]["value"].ToString(); this.Type = json["modeName"]["value"].ToString();
this._level = Single.Parse(json["val"]["value"].ToString()); this._level = Double.Parse(json["val"]["value"].ToString());
this.Scale = json["deviceScaleString"]["value"].ToString(); this.Scale = json["deviceScaleString"]["value"].ToString();
} }
if (json.Keys.Contains("min") && json["min"].Keys.Contains("value") && if (json.Keys.Contains("min") && json["min"].Keys.Contains("value") &&
json.Keys.Contains("max") && json["max"].Keys.Contains("value")) { json.Keys.Contains("max") && json["max"].Keys.Contains("value")) {
this.TempMin = Single.Parse(json["min"]["value"].ToString()); this.TempMin = Double.Parse(json["min"]["value"].ToString());
this.TempMax = Single.Parse(json["max"]["value"].ToString()); this.TempMax = Double.Parse(json["max"]["value"].ToString());
this.HasMinMax = true; this.HasMinMax = true;
} else { } else {
this.HasMinMax = false; this.HasMinMax = false;
@ -55,22 +55,22 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
if (json.Keys.Contains("val") && json["val"].Keys.Contains("value") && if (json.Keys.Contains("val") && json["val"].Keys.Contains("value") &&
json.Keys.Contains("deviceScaleString") && json["deviceScaleString"].Keys.Contains("value") && json.Keys.Contains("deviceScaleString") && json["deviceScaleString"].Keys.Contains("value") &&
json.Keys.Contains("modeName") && json["modeName"].Keys.Contains("value")) { json.Keys.Contains("modeName") && json["modeName"].Keys.Contains("value")) {
this._level = Single.Parse(json["val"]["value"].ToString()); this._level = Double.Parse(json["val"]["value"].ToString());
this.Scale = json["deviceScaleString"]["value"].ToString(); this.Scale = json["deviceScaleString"]["value"].ToString();
this.Type = json["modeName"]["value"].ToString(); this.Type = json["modeName"]["value"].ToString();
ret = true; ret = true;
} }
if (json.Keys.Contains("min") && json["val"].Keys.Contains("value") && if (json.Keys.Contains("min") && json["val"].Keys.Contains("value") &&
json.Keys.Contains("max") && json["max"].Keys.Contains("value")) { json.Keys.Contains("max") && json["max"].Keys.Contains("value")) {
this.TempMin = Single.Parse(json["min"]["value"].ToString()); this.TempMin = Double.Parse(json["min"]["value"].ToString());
this.TempMax = Single.Parse(json["max"]["value"].ToString()); this.TempMax = Double.Parse(json["max"]["value"].ToString());
this.HasMinMax = true; this.HasMinMax = true;
ret = true; ret = true;
} else { } else {
this.HasMinMax = false; this.HasMinMax = false;
} }
if (ret && this.CheckSetUpdateTime(json)) { if (ret && this.CheckSetUpdateTime(json)) {
this.Update?.Invoke(this, new DeviceUpdateEvent(new Tuple<String, String, Single, Single, Single, Boolean>(this.Type, this.Scale, this.Level, this.TempMin, this.TempMax, this.HasMinMax), this.LastUpdate, this)); this.Update?.Invoke(this, new DeviceUpdateEvent(new Tuple<String, String, Double, Double, Double, Boolean>(this.Type, this.Scale, this.Level, this.TempMin, this.TempMax, this.HasMinMax), this.LastUpdate, this));
} }
} }
@ -82,12 +82,12 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
public override Dictionary<String, Object> ToDictionary() { public override Dictionary<String, Object> ToDictionary() {
return new Dictionary<String, Object> { return new Dictionary<String, Object> {
{ "level", this.Level.ToString() }, { "level", this.Level },
{ "type", this.Type }, { "type", this.Type },
{ "scale", this.Scale }, { "scale", this.Scale },
{ "tempmax", this.TempMax.ToString() }, { "tempmax", this.TempMax },
{ "tempmin", this.TempMin.ToString() }, { "tempmin", this.TempMin },
{ "hasminmax", this.HasMinMax.ToString() }, { "hasminmax", this.HasMinMax },
}; };
} }
} }

View File

@ -50,7 +50,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
public override Dictionary<String, Object> ToDictionary() { public override Dictionary<String, Object> ToDictionary() {
return new Dictionary<String, Object> { return new Dictionary<String, Object> {
{ "level", this.Level.ToString() }, { "level", this.Level },
}; };
} }
} }

View File

@ -51,7 +51,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
public override Dictionary<String, Object> ToDictionary() { public override Dictionary<String, Object> ToDictionary() {
return new Dictionary<String, Object> { return new Dictionary<String, Object> {
{ "level", this.Level.ToString() } { "level", this.Level }
}; };
} }
} }

View File

@ -54,7 +54,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
public override Dictionary<String, Object> ToDictionary() { public override Dictionary<String, Object> ToDictionary() {
return new Dictionary<String, Object> { return new Dictionary<String, Object> {
{ "level", this.Level.ToString() } { "level", this.Level }
}; };
} }
} }

View File

@ -71,7 +71,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
modes.Add(item.Key.ToString(), item.Value); modes.Add(item.Key.ToString(), item.Value);
} }
Dictionary<String, Object> json = new Dictionary<String, Object> { Dictionary<String, Object> json = new Dictionary<String, Object> {
{ "level", this.Level.ToString() }, { "level", this.Level },
{ "modes", modes } { "modes", modes }
}; };
return json; return json;

View File

@ -124,9 +124,11 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
public override Dictionary<String, Object> ToDictionary() { public override Dictionary<String, Object> ToDictionary() {
return new Dictionary<String, Object> { return new Dictionary<String, Object> {
{ "wakeupmin", this.WakeupMin.ToString() }, {"interval", this.Interval },
{ "wakeupmax", this.WakeupMax.ToString() }, {"againstnode", this.AgainstNode },
{ "wakeupdefault", this.WakeupDefault.ToString() }, { "wakeupmin", this.WakeupMin },
{ "wakeupmax", this.WakeupMax },
{ "wakeupdefault", this.WakeupDefault },
{ "lastwakeup", this.LastWakeup.ToString() }, { "lastwakeup", this.LastWakeup.ToString() },
{ "lastsleep", this.LastSleep.ToString() } { "lastsleep", this.LastSleep.ToString() }
}; };

View File

@ -10,8 +10,8 @@ namespace BlubbFish.IoT.Zway.Events {
public DeviceUpdateEvent() { public DeviceUpdateEvent() {
} }
public DeviceUpdateEvent(Single value, DateTime time, Object parent) { public DeviceUpdateEvent(Double value, DateTime time, Object parent) {
this.GetSingle = value; this.GetDouble = value;
this.UpdateTime = time; this.UpdateTime = time;
this.Parent = parent; this.Parent = parent;
} }
@ -28,13 +28,13 @@ namespace BlubbFish.IoT.Zway.Events {
this.Parent = parent; this.Parent = parent;
} }
public DeviceUpdateEvent(Tuple<String, String, Single> value, DateTime time, Object parent) { public DeviceUpdateEvent(Tuple<String, String, Double> value, DateTime time, Object parent) {
this.GetStringStringSingleTuple = value; this.GetStringStringDoubleTuple = value;
this.UpdateTime = time; this.UpdateTime = time;
this.Parent = parent; this.Parent = parent;
} }
public DeviceUpdateEvent(Tuple<String, String, Single, Single, Single, Boolean> value, DateTime time, Object parent) { public DeviceUpdateEvent(Tuple<String, String, Double, Double, Double, Boolean> value, DateTime time, Object parent) {
this.GetStringStringSingleSingleSingleSingleBooleanTuple = value; this.GetStringStringDoubleDoubleDoubleDoubleBooleanTuple = value;
this.UpdateTime = time; this.UpdateTime = time;
this.Parent = parent; this.Parent = parent;
} }
@ -51,10 +51,10 @@ namespace BlubbFish.IoT.Zway.Events {
this.Parent = parent; this.Parent = parent;
} }
public Single GetSingle { get; } public Double GetDouble { get; }
public DateTime GetDate { get; } public DateTime GetDate { get; }
public Tuple<String, String, Single> GetStringStringSingleTuple { get; } public Tuple<String, String, Double> GetStringStringDoubleTuple { get; }
public Tuple<String, String, Single, Single, Single, Boolean> GetStringStringSingleSingleSingleSingleBooleanTuple { get; } public Tuple<String, String, Double, Double, Double, Boolean> GetStringStringDoubleDoubleDoubleDoubleBooleanTuple { get; }
public Tuple<Int64, Int32> GetLongIntegerTuple { get; } public Tuple<Int64, Int32> GetLongIntegerTuple { get; }
public DateTime UpdateTime { get; } public DateTime UpdateTime { get; }
public Object Parent { get; private set; } public Object Parent { get; private set; }

View File

@ -172,11 +172,11 @@ namespace BlubbFish.IoT.Zway.Interfaces {
this.http.GetVoid("ZWave.zway/Run/devices[" + this.DeviceId + "].instances[" + this.Instance + "].commandClasses[" + ((Int32)this.Commandclass).ToString() + "].Set(" + value + ")"); this.http.GetVoid("ZWave.zway/Run/devices[" + this.DeviceId + "].instances[" + this.Instance + "].commandClasses[" + ((Int32)this.Commandclass).ToString() + "].Set(" + value + ")");
} }
protected void SetTuple(Single value1, Single value2) { protected void SetTuple(Double value1, Double value2) {
this.http.GetVoid("ZWave.zway/Run/devices[" + this.DeviceId + "].instances[" + this.Instance + "].commandClasses[" + ((Int32)this.Commandclass).ToString() + "].Set(" + value1 + "," + value2 + ")"); this.http.GetVoid("ZWave.zway/Run/devices[" + this.DeviceId + "].instances[" + this.Instance + "].commandClasses[" + ((Int32)this.Commandclass).ToString() + "].Set(" + value1 + "," + value2 + ")");
} }
protected void SetTuple(Int32 v1, Int32 v2) => this.SetTuple(v1, (Single)v2); protected void SetTuple(Int32 v1, Int32 v2) => this.SetTuple(v1, (Double)v2);
protected Boolean CheckSetUpdateTime(JsonData json) { protected Boolean CheckSetUpdateTime(JsonData json) {
if (json.Keys.Contains("updateTime") && (json["updateTime"].IsInt || json["updateTime"].IsLong)) { if (json.Keys.Contains("updateTime") && (json["updateTime"].IsInt || json["updateTime"].IsLong)) {

View File

@ -32,5 +32,5 @@ 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,
// indem Sie "*" wie unten gezeigt eingeben: // indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.0.0")] [assembly: AssemblyVersion("1.3.1.0")]
[assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyFileVersion("1.3.1.0")]

Binary file not shown.