Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7fe9d7279 | ||
|
|
b5e7d81d28 | ||
|
|
35aadc09cf | ||
|
|
af7eeeaf15 | ||
|
|
c47895e6bb | ||
|
|
3a19253230 | ||
|
|
58f467a591 | ||
|
|
52bb4bcea7 | ||
|
|
3760f36e9f | ||
|
|
05cbcdf2dc | ||
|
|
dd4cc7635c | ||
|
|
bf49abfd44 | ||
|
|
566f840012 | ||
|
|
d1a8fa449b | ||
|
|
1da54f7416 | ||
|
|
eb4783c11e | ||
|
|
c06d910356 | ||
|
|
02871e4d66 | ||
|
|
edb59f01b6 | ||
|
|
ce30132f5f | ||
|
|
64c9020bcb | ||
|
|
a22628b0d0 | ||
|
|
64d74668cc | ||
|
|
e53529b9d4 | ||
|
|
ca399a405c | ||
|
|
a931ed15f0 | ||
|
|
ff35791819 | ||
|
|
6bce798689 | ||
|
|
317ae9b682 | ||
|
|
b5e0c70b1e | ||
|
|
bd01c5df3f | ||
|
|
8dd8605d73 | ||
|
|
beea6c1ee0 | ||
|
|
1082ee0d2a | ||
|
|
6d395107cb | ||
|
|
ae999384c7 | ||
|
|
9d09f09c12 | ||
|
|
08047db287 | ||
|
|
f406b09ffa |
@@ -0,0 +1,86 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using BlubbFish.IoT.Zway.Events;
|
||||||
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
|
using LitJson;
|
||||||
|
|
||||||
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
||||||
|
/// <summary>
|
||||||
|
/// 135 = Indicator
|
||||||
|
/// </summary>
|
||||||
|
class Alarm : ACommandClass {
|
||||||
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
/// <summary>
|
||||||
|
/// Unklar
|
||||||
|
/// </summary>
|
||||||
|
public Int32 Level { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// unklar
|
||||||
|
/// </summary>
|
||||||
|
public Int32 AlarmType { get; private set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
|
public Alarm(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
|
this.InitComplex(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitComplex(JsonData json) {
|
||||||
|
if (json.Keys.Contains("data") && json["data"].Keys.Contains("V1event")) {
|
||||||
|
if(json["data"]["V1event"].Keys.Contains("alarmType") &&
|
||||||
|
json["data"]["V1event"]["alarmType"].Keys.Contains("value") &&
|
||||||
|
json["data"]["V1event"]["alarmType"]["value"] != null &&
|
||||||
|
json["data"]["V1event"]["alarmType"]["value"].IsInt) {
|
||||||
|
this.AlarmType = Int32.Parse(json["data"]["V1event"]["alarmType"]["value"].ToString());
|
||||||
|
}
|
||||||
|
if(json["data"]["V1event"].Keys.Contains("level") &&
|
||||||
|
json["data"]["V1event"]["level"].Keys.Contains("value") &&
|
||||||
|
json["data"]["V1event"]["level"]["value"] != null &&
|
||||||
|
json["data"]["V1event"]["level"]["value"].IsInt) {
|
||||||
|
this.Level = Int32.Parse(json["data"]["V1event"]["level"]["value"].ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
|
public override String ToString() {
|
||||||
|
return "Alarm " + this.Name + " [" + this.Id + "]: " + this.AlarmType + " " + this.Level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Dictionary<String, Object> ToDictionary() {
|
||||||
|
return new Dictionary<String, Object> {
|
||||||
|
{ "AlarmType", this.AlarmType },
|
||||||
|
{ "Level", this.Level },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
|
if (match.Groups[4].Value == ".data.V1event") {
|
||||||
|
if (json.Keys.Contains("alarmType") && json["alarmType"].Keys.Contains("value") &&
|
||||||
|
json.Keys.Contains("level") && json["level"].Keys.Contains("value") &&
|
||||||
|
this.CheckSetUpdateTime(json)) {
|
||||||
|
this.AlarmType = Int32.Parse(json["alarmType"]["value"].ToString());
|
||||||
|
this.Level = Int32.Parse(json["level"]["value"].ToString());
|
||||||
|
this.Update?.Invoke(this, new DeviceUpdateEvent(new Tuple<Int32, Int32>(this.AlarmType, this.Level), this.LastUpdate, this));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void Poll() => this.PollNone();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ISenml
|
||||||
|
protected override List<Senml> ToSenmlList() {
|
||||||
|
return new List<Senml>() { };
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs;
|
||||||
|
using BlubbFish.IoT.Zway.Events;
|
||||||
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
|
using LitJson;
|
||||||
|
|
||||||
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
||||||
|
/// <summary>
|
||||||
|
/// 50 = Meter
|
||||||
|
/// </summary>
|
||||||
|
public class Alarmsensor : ACommandClass {
|
||||||
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
|
public Alarmsensor(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
|
this.HasSub = true;
|
||||||
|
this.InitComplex(json);
|
||||||
|
foreach (KeyValuePair<Int32, ACommandClass> item in this.Sub) {
|
||||||
|
item.Value.Update += this.DeviceUpdate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitComplex(JsonData json) {
|
||||||
|
if (json.Keys.Contains("data")) {
|
||||||
|
JsonData data = json["data"];
|
||||||
|
Dictionary<Int32, ACommandClass> subs = new Dictionary<Int32, ACommandClass>();
|
||||||
|
foreach (String item in data.Keys) {
|
||||||
|
if (Int32.TryParse(item, out Int32 subid) &&
|
||||||
|
data[item].Keys.Contains("srcId") &&
|
||||||
|
data[item].Keys.Contains("sensorState") &&
|
||||||
|
data[item].Keys.Contains("sensorTime") &&
|
||||||
|
data[item].Keys.Contains("typeString")) {
|
||||||
|
subs.Add(subid, new Alarmsensorsub(data[item], new Tuple<Int32, Int32, Classes, Int32>(this.DeviceId, this.Instance, this.Commandclass, subid), this.http, this.Polling));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.Sub = new ReadOnlyDictionary<Int32, ACommandClass>(subs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DeviceUpdate(Object sender, DeviceUpdateEvent e) {
|
||||||
|
this.Update?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
|
if (match.Groups[4].Value.StartsWith(".data.")) {
|
||||||
|
Int32 subid = Int32.Parse(match.Groups[5].Value);
|
||||||
|
if (this.Sub.ContainsKey(subid)) {
|
||||||
|
this.Sub[subid].SetUpdate(json, match);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Dictionary<String, Object> ToDictionary() => this.ToDictionarySub();
|
||||||
|
|
||||||
|
internal override void Poll() => this.PollSubGlobal();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ISenml
|
||||||
|
protected override List<Senml> ToSenmlList() => this.ToSenmlListSub();
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ using System.Text.RegularExpressions;
|
|||||||
using BlubbFish.IoT.Zway.Events;
|
using BlubbFish.IoT.Zway.Events;
|
||||||
using BlubbFish.IoT.Zway.Interfaces;
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
using BlubbFish.IoT.Zway.lib;
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
||||||
@@ -11,15 +12,37 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
/// 128 = Battery
|
/// 128 = Battery
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Battery : ACommandClass {
|
public class Battery : ACommandClass {
|
||||||
|
|
||||||
public Double Level { get; private set; }
|
|
||||||
|
|
||||||
public override event UpdatedValue Update;
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
/// <summary>
|
||||||
|
/// Batterylevel in Percent
|
||||||
|
/// </summary>
|
||||||
|
public Double Level { get; private set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
public Battery(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
public Battery(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
this.InitComplex(json);
|
this.InitComplex(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void InitComplex(JsonData json) {
|
||||||
|
if (json.Keys.Contains("data") && json["data"].Keys.Contains("last") && json["data"]["last"].Keys.Contains("value")) {
|
||||||
|
this.Level = Double.Parse(json["data"]["last"]["value"].ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
|
public override String ToString() {
|
||||||
|
return "Battery " + this.Name + " [" + this.Id + "]: " + this.Level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Dictionary<String, Object> ToDictionary() {
|
||||||
|
return new Dictionary<String, Object> {
|
||||||
|
{ "Level", this.Level },
|
||||||
|
};
|
||||||
|
}
|
||||||
internal override void SetUpdate(JsonData json, Match match) {
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
Boolean success = false;
|
Boolean success = false;
|
||||||
if (match.Groups[4].Value == ".data") {
|
if (match.Groups[4].Value == ".data") {
|
||||||
@@ -41,21 +64,13 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
this.Update?.Invoke(this, new DeviceUpdateEvent(this.Level, this.LastUpdate, this));
|
this.Update?.Invoke(this, new DeviceUpdateEvent(this.Level, this.LastUpdate, this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
private void InitComplex(JsonData json) {
|
#region ISenml
|
||||||
if (json.Keys.Contains("data") && json["data"].Keys.Contains("last") && json["data"]["last"].Keys.Contains("value")) {
|
protected override List<Senml> ToSenmlList() {
|
||||||
this.Level = Double.Parse(json["data"]["last"]["value"].ToString());
|
return new List<Senml>() { new SenmlDouble("chargelevel", Senml.Units.Percent, this.Level) };
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public override String ToString() {
|
|
||||||
return "Battery " + this.Name + " [" + this.Id + "]: " + this.Level;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Dictionary<String, Object> ToDictionary() {
|
|
||||||
return new Dictionary<String, Object> {
|
|
||||||
{ "Level", this.Level },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Text.RegularExpressions;
|
|||||||
using BlubbFish.IoT.Zway.Events;
|
using BlubbFish.IoT.Zway.Events;
|
||||||
using BlubbFish.IoT.Zway.Interfaces;
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
using BlubbFish.IoT.Zway.lib;
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
||||||
@@ -14,30 +15,27 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
public class Centralscene : ACommandClass {
|
public class Centralscene : ACommandClass {
|
||||||
public override event UpdatedValue Update;
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
/// <summary>
|
||||||
|
/// Combination of Scenes and Modes
|
||||||
|
/// </summary>
|
||||||
public ReadOnlyDictionary<Int32, ReadOnlyCollection<Int32>> ValidScenesModes { get; private set; }
|
public ReadOnlyDictionary<Int32, ReadOnlyCollection<Int32>> ValidScenesModes { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Current active Senes
|
||||||
|
/// </summary>
|
||||||
public Int32 Scene { get; private set; }
|
public Int32 Scene { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Current active mode
|
||||||
|
/// </summary>
|
||||||
public Int32 Key { get; private set; }
|
public Int32 Key { get; private set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
public Centralscene(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
public Centralscene(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
this.ValidScenesModes = new ReadOnlyDictionary<Int32, ReadOnlyCollection<Int32>>(new Dictionary<Int32, ReadOnlyCollection<Int32>>());
|
this.ValidScenesModes = new ReadOnlyDictionary<Int32, ReadOnlyCollection<Int32>>(new Dictionary<Int32, ReadOnlyCollection<Int32>>());
|
||||||
this.InitComplex(json);
|
this.InitComplex(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void SetUpdate(JsonData json, Match match) {
|
|
||||||
if (match.Groups[4].Value == ".data.currentScene") {
|
|
||||||
if (json.Keys.Contains("value")) {
|
|
||||||
this.Scene = Int32.Parse(json["value"].ToString());
|
|
||||||
}
|
|
||||||
} else if (match.Groups[4].Value == ".data.keyAttribute") {
|
|
||||||
if (json.Keys.Contains("value") && this.CheckSetUpdateTime(json)) {
|
|
||||||
this.Key = Int32.Parse(json["value"].ToString());
|
|
||||||
this.Update?.Invoke(this, new DeviceUpdateEvent(new Tuple<Int32, Int32>(this.Scene, this.Key), this.LastUpdate, this));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitComplex(JsonData json) {
|
private void InitComplex(JsonData json) {
|
||||||
if (json.Keys.Contains("data")) {
|
if (json.Keys.Contains("data")) {
|
||||||
JsonData data = json["data"];
|
JsonData data = json["data"];
|
||||||
@@ -69,18 +67,42 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
public override String ToString() {
|
public override String ToString() {
|
||||||
return "CentralScene " + this.Name + " [" + this.Id + "]: " + this.Scene + "-" + this.Key;
|
return "CentralScene " + this.Name + " [" + this.Id + "]: " + this.Scene + "-" + this.Key;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void Poll() => this.PollNone();
|
|
||||||
|
|
||||||
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 },
|
{ "Scene", this.Scene },
|
||||||
{ "Key", this.Key },
|
{ "Key", this.Key },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
|
if (match.Groups[4].Value == ".data.currentScene") {
|
||||||
|
if (json.Keys.Contains("value")) {
|
||||||
|
this.Scene = Int32.Parse(json["value"].ToString());
|
||||||
|
}
|
||||||
|
} else if (match.Groups[4].Value == ".data.keyAttribute") {
|
||||||
|
if (json.Keys.Contains("value") && this.CheckSetUpdateTime(json)) {
|
||||||
|
this.Key = Int32.Parse(json["value"].ToString());
|
||||||
|
this.Update?.Invoke(this, new DeviceUpdateEvent(new Tuple<Int32, Int32>(this.Scene, this.Key), this.LastUpdate, this));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void Poll() => this.PollNone();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ISenml
|
||||||
|
protected override List<Senml> ToSenmlList() {
|
||||||
|
return new List<Senml>() { new SenmlDouble("scene", Senml.Units.CounterValue, this.Scene), new SenmlDouble("key", Senml.Units.CounterValue, this.Key) };
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using BlubbFish.IoT.Zway.Events;
|
||||||
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
|
using LitJson;
|
||||||
|
|
||||||
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
||||||
|
public class Alarmsensorsub : ACommandClass {
|
||||||
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public Int32 Source { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public Int32 Level { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public Int32 Time { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public String Type { get; private set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
|
public Alarmsensorsub(JsonData json, Tuple<Int32, Int32, Classes, Int32> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
|
this.IsSub = true;
|
||||||
|
InitComplex(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitComplex(JsonData json) {
|
||||||
|
if (json.Keys.Contains("srcId") && json["srcId"].Keys.Contains("value") &&
|
||||||
|
json.Keys.Contains("sensorState") && json["sensorState"].Keys.Contains("value") &&
|
||||||
|
json.Keys.Contains("sensorTime") && json["sensorTime"].Keys.Contains("value") &&
|
||||||
|
json.Keys.Contains("typeString") && json["typeString"].Keys.Contains("value")) {
|
||||||
|
this.Source = Int32.Parse(json["srcId"]["value"].ToString());
|
||||||
|
this.Level = Int32.Parse(json["sensorState"]["value"].ToString());
|
||||||
|
this.Time = Int32.Parse(json["sensorTime"]["value"].ToString());
|
||||||
|
this.Type = json["typeString"]["value"].ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
|
public override String ToString() {
|
||||||
|
return "AlarmSensor " + this.Name + " [" + this.Id + "]: " + this.Type + " " + this.Source + " " + this.Level + " " + this.Time + " " + this.Type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Dictionary<String, Object> ToDictionary() {
|
||||||
|
return new Dictionary<String, Object> {
|
||||||
|
{ "Source", this.Source },
|
||||||
|
{ "Level", this.Level },
|
||||||
|
{ "Time", this.Time },
|
||||||
|
{ "Type", this.Type }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
|
if (json.Keys.Contains("srcId") && json["srcId"].Keys.Contains("value") &&
|
||||||
|
json.Keys.Contains("sensorState") && json["sensorState"].Keys.Contains("value") &&
|
||||||
|
json.Keys.Contains("sensorTime") && json["sensorTime"].Keys.Contains("value") &&
|
||||||
|
json.Keys.Contains("typeString") && json["typeString"].Keys.Contains("value") &&
|
||||||
|
this.CheckSetUpdateTime(json)) {
|
||||||
|
this.Source = Int32.Parse(json["srcId"]["value"].ToString());
|
||||||
|
this.Level = Int32.Parse(json["sensorState"]["value"].ToString());
|
||||||
|
this.Time = Int32.Parse(json["sensorTime"]["value"].ToString());
|
||||||
|
this.Type = json["typeString"]["value"].ToString();
|
||||||
|
this.Update?.Invoke(this, new DeviceUpdateEvent(new Tuple<Int32, Int32, Int32, String>(this.Source, this.Level, this.Time, this.Type), this.LastUpdate, this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void Poll() => this.PollNone();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ISenml
|
||||||
|
protected override List<Senml> ToSenmlList() {
|
||||||
|
return new List<Senml>() { };
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,13 +4,18 @@ using System.Text.RegularExpressions;
|
|||||||
using BlubbFish.IoT.Zway.Events;
|
using BlubbFish.IoT.Zway.Events;
|
||||||
using BlubbFish.IoT.Zway.Interfaces;
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
using BlubbFish.IoT.Zway.lib;
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
||||||
class Configurationsub : ACommandClass {
|
class Configurationsub : ACommandClass {
|
||||||
public override event UpdatedValue Update;
|
public override event UpdatedValue Update;
|
||||||
private Int64 _level;
|
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
private Int64 _level;
|
||||||
|
/// <summary>
|
||||||
|
/// Value of the Configuration Item
|
||||||
|
/// </summary>
|
||||||
public Int64 Level {
|
public Int64 Level {
|
||||||
get {
|
get {
|
||||||
return this._level;
|
return this._level;
|
||||||
@@ -25,8 +30,13 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Size of the Configuration slot
|
||||||
|
/// </summary>
|
||||||
public Int32 Size { get; private set; }
|
public Int32 Size { get; private set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
public Configurationsub(JsonData json, Tuple<Int32, Int32, Classes, Int32> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
public Configurationsub(JsonData json, Tuple<Int32, Int32, Classes, Int32> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
this.IsSub = true;
|
this.IsSub = true;
|
||||||
InitComplex(json);
|
InitComplex(json);
|
||||||
@@ -42,8 +52,19 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
|||||||
this.Size = Int32.Parse(json["size"]["value"].ToString());
|
this.Size = Int32.Parse(json["size"]["value"].ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
internal override void Poll() => this.PollSub();
|
#region ACommandClass
|
||||||
|
public override String ToString() {
|
||||||
|
return "Configuration " + this.Name + " [" + this.Id + "]: " + this.Level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Dictionary<String, Object> ToDictionary() {
|
||||||
|
return new Dictionary<String, Object> {
|
||||||
|
{ "Level", this.Level },
|
||||||
|
{ "Size", this.Size },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
internal override void SetUpdate(JsonData json, Match match) {
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
if (json.Keys.Contains("val") && json["val"].Keys.Contains("value") && json["val"]["value"] != null &&
|
if (json.Keys.Contains("val") && json["val"].Keys.Contains("value") && json["val"]["value"] != null &&
|
||||||
@@ -55,15 +76,13 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override String ToString() {
|
internal override void Poll() => this.PollSub();
|
||||||
return "Configuration " + this.Name + " [" + this.Id + "]: " + this.Level;
|
#endregion
|
||||||
}
|
|
||||||
|
|
||||||
public override Dictionary<String, Object> ToDictionary() {
|
#region ISenml
|
||||||
return new Dictionary<String, Object> {
|
protected override List<Senml> ToSenmlList() {
|
||||||
{ "Level", this.Level },
|
return new List<Senml>() { };
|
||||||
{ "Size", this.Size },
|
}
|
||||||
};
|
#endregion
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,15 +4,29 @@ using System.Text.RegularExpressions;
|
|||||||
using BlubbFish.IoT.Zway.Events;
|
using BlubbFish.IoT.Zway.Events;
|
||||||
using BlubbFish.IoT.Zway.Interfaces;
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
using BlubbFish.IoT.Zway.lib;
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
||||||
public class Metersub : ACommandClass {
|
public class Metersub : ACommandClass {
|
||||||
public override event UpdatedValue Update;
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
/// <summary>
|
||||||
|
/// Type of the Sensor
|
||||||
|
/// </summary>
|
||||||
public String Type { get; private set; }
|
public String Type { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Actual value of the Sensor
|
||||||
|
/// </summary>
|
||||||
public Double Level { get; private set; }
|
public Double Level { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Scale of the Sensor
|
||||||
|
/// </summary>
|
||||||
public String Scale { get; private set; }
|
public String Scale { get; private set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
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;
|
||||||
this.IsSub = true;
|
this.IsSub = true;
|
||||||
@@ -31,6 +45,20 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
|||||||
this.Scale = json["scaleString"]["value"].ToString();
|
this.Scale = json["scaleString"]["value"].ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
|
public override String ToString() {
|
||||||
|
return "Meter " + this.Name + " [" + this.Id + "]: " + this.Type + " " + this.Level + "" + this.Scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Dictionary<String, Object> ToDictionary() {
|
||||||
|
return new Dictionary<String, Object> {
|
||||||
|
{ "Level", this.Level },
|
||||||
|
{ "Type", this.Type },
|
||||||
|
{ "Scale", this.Scale },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
internal override void SetUpdate(JsonData json, Match match) {
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
if (json.Keys.Contains("val") && json["val"].Keys.Contains("value") &&
|
if (json.Keys.Contains("val") && json["val"].Keys.Contains("value") &&
|
||||||
@@ -44,18 +72,18 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override String ToString() {
|
|
||||||
return "Meter " + this.Name + " [" + this.Id + "]: " + this.Type + " " + this.Level + "" + this.Scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override void Poll() => this.PollNone();
|
internal override void Poll() => this.PollNone();
|
||||||
|
#endregion
|
||||||
|
|
||||||
public override Dictionary<String, Object> ToDictionary() {
|
#region ISenml
|
||||||
return new Dictionary<String, Object> {
|
protected override List<Senml> ToSenmlList() {
|
||||||
{ "Level", this.Level },
|
if (this.Scale == "W") {
|
||||||
{ "Type", this.Type },
|
return new List<Senml>() { new SenmlDouble("power", Senml.Units.Watt, this.Level) };
|
||||||
{ "Scale", this.Scale },
|
} else if(this.Scale == "kWh") {
|
||||||
};
|
return new List<Senml>() { new SenmlDouble("consumption", Senml.Units.Joule, this.Level * 1000 * 3.6 * 1000) };
|
||||||
}
|
}
|
||||||
|
return new List<Senml>() {};
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using BlubbFish.IoT.Zway.Events;
|
||||||
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
|
using LitJson;
|
||||||
|
|
||||||
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
||||||
|
public class Scenecontrollerconfsub : ACommandClass {
|
||||||
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public Int32 Scene { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public Int32 Duration { get; private set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
|
public Scenecontrollerconfsub(JsonData json, Tuple<Int32, Int32, Classes, Int32> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
|
this.IsSub = true;
|
||||||
|
InitComplex(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitComplex(JsonData json) {
|
||||||
|
if (json.Keys.Contains("scene") && json["scene"].Keys.Contains("value") &&
|
||||||
|
json.Keys.Contains("duration") && json["duration"].Keys.Contains("value")) {
|
||||||
|
this.Scene = Int32.Parse(json["scene"]["value"].ToString());
|
||||||
|
this.Duration = Int32.Parse(json["duration"]["value"].ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
|
public override String ToString() {
|
||||||
|
return "SceneControllerConf " + this.Name + " [" + this.Id + "]: " + this.Scene + " " + this.Duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Dictionary<String, Object> ToDictionary() {
|
||||||
|
return new Dictionary<String, Object> {
|
||||||
|
{ "Scene", this.Scene },
|
||||||
|
{ "Duration", this.Duration }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
|
if (json.Keys.Contains("scene") && json["scene"].Keys.Contains("value") &&
|
||||||
|
json.Keys.Contains("duration") && json["duration"].Keys.Contains("value") &&
|
||||||
|
this.CheckSetUpdateTime(json)) {
|
||||||
|
this.Scene = Int32.Parse(json["scene"]["value"].ToString());
|
||||||
|
this.Duration = Int32.Parse(json["duration"]["value"].ToString());
|
||||||
|
this.Update?.Invoke(this, new DeviceUpdateEvent(new Tuple<Int32, Int32>(this.Scene, this.Duration), this.LastUpdate, this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void Poll() => this.PollSub();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ISenml
|
||||||
|
protected override List<Senml> ToSenmlList() {
|
||||||
|
return new List<Senml>() { };
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using BlubbFish.IoT.Zway.Events;
|
||||||
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
|
using LitJson;
|
||||||
|
|
||||||
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
||||||
|
public class Sensorbinarysub : ACommandClass {
|
||||||
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public String Type { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public Boolean State { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public Int32 Level {
|
||||||
|
get {
|
||||||
|
return (this.State) ? 1 : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
|
public Sensorbinarysub(JsonData json, Tuple<Int32, Int32, Classes, Int32> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
|
this.IsSub = true;
|
||||||
|
InitComplex(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitComplex(JsonData json) {
|
||||||
|
if (json.Keys.Contains("sensorTypeString") &&
|
||||||
|
json["sensorTypeString"].Keys.Contains("value") &&
|
||||||
|
json.Keys.Contains("level") &&
|
||||||
|
json["level"].Keys.Contains("value")) {
|
||||||
|
this.Type = json["sensorTypeString"]["value"].ToString();
|
||||||
|
this.State = (Boolean)json["level"]["value"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
|
public override String ToString() {
|
||||||
|
return "SensorBinary " + this.Name + " [" + this.Id + "]: " + this.Type + " " + this.State.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Dictionary<String, Object> ToDictionary() {
|
||||||
|
return new Dictionary<String, Object> {
|
||||||
|
{ "State", this.State },
|
||||||
|
{ "Type", this.Type },
|
||||||
|
{ "Level", this.Level }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
|
if (json.Keys.Contains("level") && json["level"].Keys.Contains("value") &&
|
||||||
|
json.Keys.Contains("sensorTypeString") && json["sensorTypeString"].Keys.Contains("value") &&
|
||||||
|
this.CheckSetUpdateTime(json)) {
|
||||||
|
this.State = (Boolean)json["level"]["value"];
|
||||||
|
this.Type = json["sensorTypeString"]["value"].ToString();
|
||||||
|
this.Update?.Invoke(this, new DeviceUpdateEvent(new Tuple<String, Boolean>(this.Type, this.State), this.LastUpdate, this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void Poll() => this.PollNone();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ISenml
|
||||||
|
protected override List<Senml> ToSenmlList() {
|
||||||
|
return new List<Senml>() { };
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,16 +4,29 @@ using System.Text.RegularExpressions;
|
|||||||
using BlubbFish.IoT.Zway.Events;
|
using BlubbFish.IoT.Zway.Events;
|
||||||
using BlubbFish.IoT.Zway.Interfaces;
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
using BlubbFish.IoT.Zway.lib;
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
||||||
public class Sensormultilevelsub : ACommandClass {
|
public class Sensormultilevelsub : ACommandClass {
|
||||||
public override event UpdatedValue Update;
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
/// <summary>
|
||||||
|
/// Type of the Sensor
|
||||||
|
/// </summary>
|
||||||
public String Type { get; private set; }
|
public String Type { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Level of the sensor
|
||||||
|
/// </summary>
|
||||||
public Double Level { get; private set; }
|
public Double Level { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Scale of the sensor
|
||||||
|
/// </summary>
|
||||||
public String Scale { get; private set; }
|
public String Scale { get; private set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
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) {
|
||||||
this.IsSub = true;
|
this.IsSub = true;
|
||||||
InitComplex(json);
|
InitComplex(json);
|
||||||
@@ -31,8 +44,31 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
|||||||
this.Scale = json["scaleString"]["value"].ToString();
|
this.Scale = json["scaleString"]["value"].ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
|
public override String ToString() {
|
||||||
|
return "SensorMultilevel " + this.Name + " [" + this.Id + "]: " + this.Type + " " + this.Level + "" + this.Scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Dictionary<String, Object> ToDictionary() {
|
||||||
|
return new Dictionary<String, Object> {
|
||||||
|
{ "Level", this.Level },
|
||||||
|
{ "Type", this.Type },
|
||||||
|
{ "Scale", this.Scale },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
internal override void SetUpdate(JsonData json, Match match) {
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
|
if(json.Keys.Contains("val") && json["val"].Keys.Contains("value") && json.Keys.Contains("sensorTypeString") && json["sensorTypeString"].Keys.Contains("value")) {
|
||||||
|
String t = json["sensorTypeString"]["value"].ToString();
|
||||||
|
Double l = Double.Parse(json["val"]["value"].ToString());
|
||||||
|
if (t == "Power" && (l > 3660 || l < 0) ||
|
||||||
|
t == "Temperature" && (l > 65 || l < -25) ||
|
||||||
|
(t == "Temperature" && this.Level >= 4 && Math.Abs(l) <= 0.1)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(json.Keys.Contains("val") && json["val"].Keys.Contains("value") &&
|
if(json.Keys.Contains("val") && json["val"].Keys.Contains("value") &&
|
||||||
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") &&
|
||||||
@@ -44,18 +80,20 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override String ToString() {
|
|
||||||
return "SensorMultilevel " + this.Name + " [" + this.Id + "]: " + this.Type + " " + this.Level + "" + this.Scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override void Poll() => this.PollNone();
|
internal override void Poll() => this.PollNone();
|
||||||
|
#endregion
|
||||||
|
|
||||||
public override Dictionary<String, Object> ToDictionary() {
|
#region ISenml
|
||||||
return new Dictionary<String, Object> {
|
protected override List<Senml> ToSenmlList() {
|
||||||
{ "Level", this.Level },
|
if(this.Scale == "W") {
|
||||||
{ "Type", this.Type },
|
return new List<Senml>() { new SenmlDouble("power", Senml.Units.Watt, this.Level) };
|
||||||
{ "Scale", this.Scale },
|
} else if(this.Scale == "°C") {
|
||||||
};
|
return new List<Senml>() { new SenmlDouble("temperatur", Senml.Units.Celsius, this.Level) };
|
||||||
}
|
} else if(this.Scale == "Lux") {
|
||||||
|
return new List<Senml>() { new SenmlDouble("luminiscence", Senml.Units.Lux, this.Level) };
|
||||||
|
}
|
||||||
|
return new List<Senml>() { };
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,13 +4,18 @@ using System.Text.RegularExpressions;
|
|||||||
using BlubbFish.IoT.Zway.Events;
|
using BlubbFish.IoT.Zway.Events;
|
||||||
using BlubbFish.IoT.Zway.Interfaces;
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
using BlubbFish.IoT.Zway.lib;
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
||||||
class Thermostatsetpointsub : ACommandClass {
|
class Thermostatsetpointsub : ACommandClass {
|
||||||
public override event UpdatedValue Update;
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
private Double _level;
|
private Double _level;
|
||||||
|
/// <summary>
|
||||||
|
/// Target-Temperatur
|
||||||
|
/// </summary>
|
||||||
public Double Level {
|
public Double Level {
|
||||||
get {
|
get {
|
||||||
return this._level;
|
return this._level;
|
||||||
@@ -21,12 +26,29 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Scale of the actor
|
||||||
|
/// </summary>
|
||||||
public String Scale { get; private set; }
|
public String Scale { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Maximum Temperatur of the actor
|
||||||
|
/// </summary>
|
||||||
public Double TempMax { get; private set; }
|
public Double TempMax { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Minimum Temperatur of the actor
|
||||||
|
/// </summary>
|
||||||
public Double TempMin { get; private set; }
|
public Double TempMin { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Has Maximum and Minimum
|
||||||
|
/// </summary>
|
||||||
public Boolean HasMinMax { get; private set; }
|
public Boolean HasMinMax { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Type of the actor
|
||||||
|
/// </summary>
|
||||||
public String Type { get; private set; }
|
public String Type { get; private set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
public Thermostatsetpointsub(JsonData json, Tuple<Int32, Int32, Classes, Int32> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
public Thermostatsetpointsub(JsonData json, Tuple<Int32, Int32, Classes, Int32> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
this.IsSub = true;
|
this.IsSub = true;
|
||||||
InitComplex(json);
|
InitComplex(json);
|
||||||
@@ -49,6 +71,23 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
|||||||
this.HasMinMax = false;
|
this.HasMinMax = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
|
public override String ToString() {
|
||||||
|
return "ThermostatSetPoint " + this.Name + " [" + this.Id + "]: " + this.Type + " " + this.Level + "" + this.Scale + " [" + this.TempMin + "," + this.TempMax + "," + this.HasMinMax + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Dictionary<String, Object> ToDictionary() {
|
||||||
|
return new Dictionary<String, Object> {
|
||||||
|
{ "Level", this.Level },
|
||||||
|
{ "Type", this.Type },
|
||||||
|
{ "Scale", this.Scale },
|
||||||
|
{ "TempMax", this.TempMax },
|
||||||
|
{ "TempMin", this.TempMin },
|
||||||
|
{ "HasMinMax", this.HasMinMax },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
internal override void SetUpdate(JsonData json, Match match) {
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
Boolean ret = false;
|
Boolean ret = false;
|
||||||
@@ -74,21 +113,16 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override String ToString() {
|
|
||||||
return "ThermostatSetPoint " + this.Name + " [" + this.Id + "]: " + this.Type + " " + this.Level + "" + this.Scale + " [" + this.TempMin + "," + this.TempMax + "," + this.HasMinMax + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override void Poll() => this.PollSub();
|
internal override void Poll() => this.PollSub();
|
||||||
|
#endregion
|
||||||
|
|
||||||
public override Dictionary<String, Object> ToDictionary() {
|
#region ISenml
|
||||||
return new Dictionary<String, Object> {
|
protected override List<Senml> ToSenmlList() {
|
||||||
{ "Level", this.Level },
|
if(this.Scale == "°C") {
|
||||||
{ "Type", this.Type },
|
return new List<Senml>() { new SenmlDouble("temperatur", Senml.Units.Celsius, this.Level) };
|
||||||
{ "Scale", this.Scale },
|
}
|
||||||
{ "TempMax", this.TempMax },
|
return new List<Senml>() { };
|
||||||
{ "TempMin", this.TempMin },
|
}
|
||||||
{ "HasMinMax", this.HasMinMax },
|
#endregion
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ using BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs;
|
|||||||
using BlubbFish.IoT.Zway.Events;
|
using BlubbFish.IoT.Zway.Events;
|
||||||
using BlubbFish.IoT.Zway.Interfaces;
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
using BlubbFish.IoT.Zway.lib;
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
||||||
@@ -15,6 +16,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
class Configuration : ACommandClass {
|
class Configuration : ACommandClass {
|
||||||
public override event UpdatedValue Update;
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
public Configuration(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
public Configuration(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
this.HasSub = true;
|
this.HasSub = true;
|
||||||
this.InitComplex(json);
|
this.InitComplex(json);
|
||||||
@@ -23,10 +25,6 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeviceUpdate(Object sender, DeviceUpdateEvent e) {
|
|
||||||
this.Update?.Invoke(this, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitComplex(JsonData json) {
|
private void InitComplex(JsonData json) {
|
||||||
if (json.Keys.Contains("data")) {
|
if (json.Keys.Contains("data")) {
|
||||||
JsonData data = json["data"];
|
JsonData data = json["data"];
|
||||||
@@ -44,6 +42,12 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DeviceUpdate(Object sender, DeviceUpdateEvent e) {
|
||||||
|
this.Update?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
internal override void SetUpdate(JsonData json, Match match) {
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
if (match.Groups[4].Value.StartsWith(".data.")) {
|
if (match.Groups[4].Value.StartsWith(".data.")) {
|
||||||
Int32 subid = Int32.Parse(match.Groups[5].Value);
|
Int32 subid = Int32.Parse(match.Groups[5].Value);
|
||||||
@@ -58,5 +62,10 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
internal override void Poll() => this.PollPerSub();
|
internal override void Poll() => this.PollPerSub();
|
||||||
|
|
||||||
public override Dictionary<String, Object> ToDictionary() => this.ToDictionarySub();
|
public override Dictionary<String, Object> ToDictionary() => this.ToDictionarySub();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ISenml
|
||||||
|
protected override List<Senml> ToSenmlList() => this.ToSenmlListSub();
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Text.RegularExpressions;
|
|||||||
using BlubbFish.IoT.Zway.Events;
|
using BlubbFish.IoT.Zway.Events;
|
||||||
using BlubbFish.IoT.Zway.Interfaces;
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
using BlubbFish.IoT.Zway.lib;
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
||||||
@@ -11,47 +12,75 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
/// 135 = Indicator
|
/// 135 = Indicator
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class Indicator : ACommandClass {
|
class Indicator : ACommandClass {
|
||||||
private Boolean _level;
|
|
||||||
|
|
||||||
public override event UpdatedValue Update;
|
public override event UpdatedValue Update;
|
||||||
public Boolean Level {
|
|
||||||
|
#region Properties
|
||||||
|
private Boolean _state;
|
||||||
|
/// <summary>
|
||||||
|
/// Status of the Indicator
|
||||||
|
/// </summary>
|
||||||
|
public Boolean State {
|
||||||
get {
|
get {
|
||||||
return this._level;
|
return this._state;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
this.SetInt(value ? 255 : 0);
|
this.SetInt(value ? 255 : 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Int-Representation of the Indicator
|
||||||
|
/// </summary>
|
||||||
|
public Int32 Level {
|
||||||
|
get {
|
||||||
|
return (this.State) ? 1 : 0;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this.State = (value == 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
public Indicator(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
public Indicator(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
this.InitComplex(json);
|
this.InitComplex(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitComplex(JsonData json) {
|
private void InitComplex(JsonData json) {
|
||||||
if (json.Keys.Contains("data") && json["data"].Keys.Contains("stat") && json["data"]["stat"].Keys.Contains("value")) {
|
if (json.Keys.Contains("data") && json["data"].Keys.Contains("stat") && json["data"]["stat"].Keys.Contains("value")) {
|
||||||
this._level = Int32.Parse(json["data"]["stat"]["value"].ToString()) == 255;
|
this._state = Int32.Parse(json["data"]["stat"]["value"].ToString()) == 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
|
public override String ToString() {
|
||||||
|
return "Indicator " + this.Name + " [" + this.Id + "]: " + this.State;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Dictionary<String, Object> ToDictionary() {
|
||||||
|
return new Dictionary<String, Object> {
|
||||||
|
{ "State", this.State },
|
||||||
|
{ "Level", this.Level }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
internal override void SetUpdate(JsonData json, Match match) {
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
if(match.Groups[4].Value == ".data.stat") {
|
if(match.Groups[4].Value == ".data.stat") {
|
||||||
if (json.Keys.Contains("value") && this.CheckSetUpdateTime(json)) {
|
if (json.Keys.Contains("value") && this.CheckSetUpdateTime(json)) {
|
||||||
this._level = Int32.Parse(json["value"].ToString()) == 255;
|
this._state = Int32.Parse(json["value"].ToString()) == 255;
|
||||||
this.Update?.Invoke(this, new DeviceUpdateEvent(this.Level, this.LastUpdate, this));
|
this.Update?.Invoke(this, new DeviceUpdateEvent(this.State, this.LastUpdate, this));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public override String ToString() {
|
#region ISenml
|
||||||
return "Indicator " + this.Name + " [" + this.Id + "]: " + this.Level;
|
protected override List<Senml> ToSenmlList() {
|
||||||
|
return new List<Senml>() { new SenmlBool("status", Senml.Units.CounterValue, this.State) };
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public override Dictionary<String, Object> ToDictionary() {
|
|
||||||
return new Dictionary<String, Object> {
|
|
||||||
{ "Level", this.Level },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs;
|
|||||||
using BlubbFish.IoT.Zway.Events;
|
using BlubbFish.IoT.Zway.Events;
|
||||||
using BlubbFish.IoT.Zway.Interfaces;
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
using BlubbFish.IoT.Zway.lib;
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
||||||
@@ -15,6 +16,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
public class Meter : ACommandClass {
|
public class Meter : ACommandClass {
|
||||||
public override event UpdatedValue Update;
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
public Meter(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
public Meter(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
this.HasSub = true;
|
this.HasSub = true;
|
||||||
this.InitComplex(json);
|
this.InitComplex(json);
|
||||||
@@ -23,21 +25,6 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeviceUpdate(Object sender, DeviceUpdateEvent e) {
|
|
||||||
this.Update?.Invoke(this, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override void SetUpdate(JsonData json, Match match) {
|
|
||||||
if (match.Groups[4].Value.StartsWith(".data.")) {
|
|
||||||
Int32 subid = Int32.Parse(match.Groups[5].Value);
|
|
||||||
if (this.Sub.ContainsKey(subid)) {
|
|
||||||
this.Sub[subid].SetUpdate(json, match);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitComplex(JsonData json) {
|
private void InitComplex(JsonData json) {
|
||||||
if (json.Keys.Contains("data")) {
|
if (json.Keys.Contains("data")) {
|
||||||
JsonData data = json["data"];
|
JsonData data = json["data"];
|
||||||
@@ -54,8 +41,30 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DeviceUpdate(Object sender, DeviceUpdateEvent e) {
|
||||||
|
this.Update?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
|
if (match.Groups[4].Value.StartsWith(".data.")) {
|
||||||
|
Int32 subid = Int32.Parse(match.Groups[5].Value);
|
||||||
|
if (this.Sub.ContainsKey(subid)) {
|
||||||
|
this.Sub[subid].SetUpdate(json, match);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal override void Poll() => this.PollSubGlobal();
|
internal override void Poll() => this.PollSubGlobal();
|
||||||
|
|
||||||
public override Dictionary<String, Object> ToDictionary() => this.ToDictionarySub();
|
public override Dictionary<String, Object> ToDictionary() => this.ToDictionarySub();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ISenml
|
||||||
|
protected override List<Senml> ToSenmlList() => this.ToSenmlListSub();
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs;
|
||||||
|
using BlubbFish.IoT.Zway.Events;
|
||||||
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
|
using LitJson;
|
||||||
|
|
||||||
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
||||||
|
/// <summary>
|
||||||
|
/// 50 = Meter
|
||||||
|
/// </summary>
|
||||||
|
public class Scenecontrollerconf : ACommandClass {
|
||||||
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
|
public Scenecontrollerconf(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
|
this.HasSub = true;
|
||||||
|
this.InitComplex(json);
|
||||||
|
foreach (KeyValuePair<Int32, ACommandClass> item in this.Sub) {
|
||||||
|
item.Value.Update += this.DeviceUpdate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitComplex(JsonData json) {
|
||||||
|
if (json.Keys.Contains("data")) {
|
||||||
|
JsonData data = json["data"];
|
||||||
|
Dictionary<Int32, ACommandClass> subs = new Dictionary<Int32, ACommandClass>();
|
||||||
|
foreach (String item in data.Keys) {
|
||||||
|
if (Int32.TryParse(item, out Int32 subid) &&
|
||||||
|
data[item].Keys.Contains("scene") &&
|
||||||
|
data[item].Keys.Contains("duration")) {
|
||||||
|
subs.Add(subid, new Scenecontrollerconfsub(data[item], new Tuple<Int32, Int32, Classes, Int32>(this.DeviceId, this.Instance, this.Commandclass, subid), this.http, this.Polling));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.Sub = new ReadOnlyDictionary<Int32, ACommandClass>(subs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DeviceUpdate(Object sender, DeviceUpdateEvent e) {
|
||||||
|
this.Update?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
|
if (match.Groups[4].Value.StartsWith(".data.")) {
|
||||||
|
Int32 subid = Int32.Parse(match.Groups[5].Value);
|
||||||
|
if (this.Sub.ContainsKey(subid)) {
|
||||||
|
this.Sub[subid].SetUpdate(json, match);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void Poll() => this.PollPerSub();
|
||||||
|
|
||||||
|
public override Dictionary<String, Object> ToDictionary() => this.ToDictionarySub();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ISenml
|
||||||
|
protected override List<Senml> ToSenmlList() => this.ToSenmlListSub();
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs;
|
||||||
|
using BlubbFish.IoT.Zway.Events;
|
||||||
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
|
using LitJson;
|
||||||
|
|
||||||
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
||||||
|
/// <summary>
|
||||||
|
/// 48 = SensorBinary
|
||||||
|
/// </summary>
|
||||||
|
public class Sensorbinary : ACommandClass {
|
||||||
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
|
public Sensorbinary(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
|
this.HasSub = true;
|
||||||
|
this.InitComplex(json);
|
||||||
|
foreach (KeyValuePair<Int32, ACommandClass> item in this.Sub) {
|
||||||
|
item.Value.Update += this.DeviceUpdate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitComplex(JsonData json) {
|
||||||
|
if (json.Keys.Contains("data")) {
|
||||||
|
JsonData data = json["data"];
|
||||||
|
Dictionary<Int32, ACommandClass> subs = new Dictionary<Int32, ACommandClass>();
|
||||||
|
foreach (String item in data.Keys) {
|
||||||
|
if (Int32.TryParse(item, out Int32 subid) &&
|
||||||
|
data[item].Keys.Contains("sensorTypeString") &&
|
||||||
|
data[item].Keys.Contains("level")) {
|
||||||
|
subs.Add(subid, new Sensorbinarysub(data[item], new Tuple<Int32, Int32, Classes, Int32>(this.DeviceId, this.Instance, this.Commandclass, subid), this.http, this.Polling));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.Sub = new ReadOnlyDictionary<Int32, ACommandClass>(subs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DeviceUpdate(Object sender, DeviceUpdateEvent e) {
|
||||||
|
this.Update?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
|
if (match.Groups[4].Value.StartsWith(".data.")) {
|
||||||
|
Int32 subid = Int32.Parse(match.Groups[5].Value);
|
||||||
|
if (this.Sub.ContainsKey(subid)) {
|
||||||
|
this.Sub[subid].SetUpdate(json, match);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void Poll() => this.PollSubGlobal();
|
||||||
|
|
||||||
|
public override Dictionary<String, Object> ToDictionary() => this.ToDictionarySub();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ISenml
|
||||||
|
protected override List<Senml> ToSenmlList() => this.ToSenmlListSub();
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ using BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs;
|
|||||||
using BlubbFish.IoT.Zway.Events;
|
using BlubbFish.IoT.Zway.Events;
|
||||||
using BlubbFish.IoT.Zway.Interfaces;
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
using BlubbFish.IoT.Zway.lib;
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
||||||
@@ -15,6 +16,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
public class Sensormultilevel : ACommandClass {
|
public class Sensormultilevel : ACommandClass {
|
||||||
public override event UpdatedValue Update;
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
public Sensormultilevel(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
public Sensormultilevel(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
this.HasSub = true;
|
this.HasSub = true;
|
||||||
this.InitComplex(json);
|
this.InitComplex(json);
|
||||||
@@ -23,21 +25,6 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeviceUpdate(Object sender, DeviceUpdateEvent e) {
|
|
||||||
this.Update?.Invoke(this, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override void SetUpdate(JsonData json, Match match) {
|
|
||||||
if (match.Groups[4].Value.StartsWith(".data.")) {
|
|
||||||
Int32 subid = Int32.Parse(match.Groups[5].Value);
|
|
||||||
if (this.Sub.ContainsKey(subid)) {
|
|
||||||
this.Sub[subid].SetUpdate(json, match);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitComplex(JsonData json) {
|
private void InitComplex(JsonData json) {
|
||||||
if (json.Keys.Contains("data")) {
|
if (json.Keys.Contains("data")) {
|
||||||
JsonData data = json["data"];
|
JsonData data = json["data"];
|
||||||
@@ -54,8 +41,30 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DeviceUpdate(Object sender, DeviceUpdateEvent e) {
|
||||||
|
this.Update?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
|
if (match.Groups[4].Value.StartsWith(".data.")) {
|
||||||
|
Int32 subid = Int32.Parse(match.Groups[5].Value);
|
||||||
|
if (this.Sub.ContainsKey(subid)) {
|
||||||
|
this.Sub[subid].SetUpdate(json, match);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal override void Poll() => this.PollSubGlobal();
|
internal override void Poll() => this.PollSubGlobal();
|
||||||
|
|
||||||
public override Dictionary<String, Object> ToDictionary() => this.ToDictionarySub();
|
public override Dictionary<String, Object> ToDictionary() => this.ToDictionarySub();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ISenml
|
||||||
|
protected override List<Senml> ToSenmlList() => this.ToSenmlListSub();
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Text.RegularExpressions;
|
|||||||
using BlubbFish.IoT.Zway.Events;
|
using BlubbFish.IoT.Zway.Events;
|
||||||
using BlubbFish.IoT.Zway.Interfaces;
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
using BlubbFish.IoT.Zway.lib;
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
||||||
@@ -11,48 +12,74 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
/// 37 = SwitchBinary
|
/// 37 = SwitchBinary
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Switchbinary : ACommandClass {
|
public class Switchbinary : ACommandClass {
|
||||||
private Boolean _level;
|
|
||||||
|
|
||||||
public override event UpdatedValue Update;
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
public Boolean Level {
|
#region Properties
|
||||||
|
/// <summary>
|
||||||
|
/// Int representation of Boolean
|
||||||
|
/// </summary>
|
||||||
|
public Int32 Level {
|
||||||
get {
|
get {
|
||||||
return this._level;
|
return (this.State) ? 1 : 0;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this.State = (value == 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private Boolean _state;
|
||||||
|
/// <summary>
|
||||||
|
/// State if Switch is activated
|
||||||
|
/// </summary>
|
||||||
|
public Boolean State {
|
||||||
|
get {
|
||||||
|
return this._state;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
this.SetInt(value ? 255 : 0);
|
this.SetInt(value ? 255 : 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
public Switchbinary(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
public Switchbinary(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
this.InitComplex(json);
|
this.InitComplex(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void InitComplex(JsonData json) {
|
||||||
|
if (json.Keys.Contains("data") && json["data"].Keys.Contains("level") && json["data"]["level"].Keys.Contains("value") && json["data"]["level"]["value"].IsBoolean) {
|
||||||
|
this._state = (Boolean)json["data"]["level"]["value"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
|
public override String ToString() {
|
||||||
|
return "SwitchBinary " + this.Name + " [" + this.Id + "]: " + this.State;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Dictionary<String, Object> ToDictionary() {
|
||||||
|
return new Dictionary<String, Object> {
|
||||||
|
{ "State", this.State },
|
||||||
|
{ "Level", this.Level }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
internal override void SetUpdate(JsonData json, Match match) {
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
if(match.Groups[4].Value == ".data.level") {
|
if(match.Groups[4].Value == ".data.level") {
|
||||||
if (json.Keys.Contains("value") && json["value"].IsBoolean && this.CheckSetUpdateTime(json)) {
|
if (json.Keys.Contains("value") && json["value"].IsBoolean && this.CheckSetUpdateTime(json)) {
|
||||||
this._level = (Boolean)json["value"];
|
this._state = (Boolean)json["value"];
|
||||||
this.Update?.Invoke(this, new DeviceUpdateEvent(this.Level, this.LastUpdate, this));
|
this.Update?.Invoke(this, new DeviceUpdateEvent(this.State, this.LastUpdate, this));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
private void InitComplex(JsonData json) {
|
#region ISenml
|
||||||
if (json.Keys.Contains("data") && json["data"].Keys.Contains("level") && json["data"]["level"].Keys.Contains("value") && json["data"]["level"]["value"].IsBoolean) {
|
protected override List<Senml> ToSenmlList() {
|
||||||
this._level = (Boolean)json["data"]["level"]["value"];
|
return new List<Senml>() { new SenmlBool("state", Senml.Units.CounterValue, this.State) };
|
||||||
}
|
}
|
||||||
}
|
#endregion
|
||||||
|
|
||||||
public override String ToString() {
|
|
||||||
return "SwitchBinary " + this.Name + " [" + this.Id + "]: " + this.Level;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Dictionary<String, Object> ToDictionary() {
|
|
||||||
return new Dictionary<String, Object> {
|
|
||||||
{ "Level", this.Level }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Text.RegularExpressions;
|
|||||||
using BlubbFish.IoT.Zway.Events;
|
using BlubbFish.IoT.Zway.Events;
|
||||||
using BlubbFish.IoT.Zway.Interfaces;
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
using BlubbFish.IoT.Zway.lib;
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
||||||
@@ -11,10 +12,13 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
/// 38 = SwitchMultilevel
|
/// 38 = SwitchMultilevel
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Switchmultilevel : ACommandClass {
|
public class Switchmultilevel : ACommandClass {
|
||||||
private Int32 _level;
|
|
||||||
|
|
||||||
public override event UpdatedValue Update;
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
private Int32 _level;
|
||||||
|
/// <summary>
|
||||||
|
/// Level of thw Switch
|
||||||
|
/// </summary>
|
||||||
public Int32 Level {
|
public Int32 Level {
|
||||||
get {
|
get {
|
||||||
return this._level;
|
return this._level;
|
||||||
@@ -25,11 +29,31 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
public Switchmultilevel(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
public Switchmultilevel(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
this.InitComplex(json);
|
this.InitComplex(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void InitComplex(JsonData json) {
|
||||||
|
if (json.Keys.Contains("data") && json["data"].Keys.Contains("level") && json["data"]["level"].Keys.Contains("value")) {
|
||||||
|
this._level = Int32.Parse(json["data"]["level"]["value"].ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
|
public override String ToString() {
|
||||||
|
return "SwitchMultilevel " + this.Name + " [" + this.Id + "]: " + this.Level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Dictionary<String, Object> ToDictionary() {
|
||||||
|
return new Dictionary<String, Object> {
|
||||||
|
{ "Level", this.Level }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
internal override void SetUpdate(JsonData json, Match match) {
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
if(match.Groups[4].Value == ".data.level") {
|
if(match.Groups[4].Value == ".data.level") {
|
||||||
if(json.Keys.Contains("value") && this.CheckSetUpdateTime(json)) {
|
if(json.Keys.Contains("value") && this.CheckSetUpdateTime(json)) {
|
||||||
@@ -41,21 +65,12 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
private void InitComplex(JsonData json) {
|
#region ISenml
|
||||||
if (json.Keys.Contains("data") && json["data"].Keys.Contains("level") && json["data"]["level"].Keys.Contains("value")) {
|
protected override List<Senml> ToSenmlList() {
|
||||||
this._level = Int32.Parse(json["data"]["level"]["value"].ToString());
|
return new List<Senml>() { new SenmlDouble("state", Senml.Units.Percent, (Double)this.Level/255) };
|
||||||
}
|
}
|
||||||
}
|
#endregion
|
||||||
|
|
||||||
public override String ToString() {
|
|
||||||
return "SwitchMultilevel " + this.Name + " [" + this.Id + "]: " + this.Level;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Dictionary<String, Object> ToDictionary() {
|
|
||||||
return new Dictionary<String, Object> {
|
|
||||||
{ "Level", this.Level }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Text.RegularExpressions;
|
|||||||
using BlubbFish.IoT.Zway.Events;
|
using BlubbFish.IoT.Zway.Events;
|
||||||
using BlubbFish.IoT.Zway.Interfaces;
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
using BlubbFish.IoT.Zway.lib;
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
||||||
@@ -12,11 +13,17 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
/// 64 = ThermostatMode
|
/// 64 = ThermostatMode
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Thermostatmode : ACommandClass {
|
public class Thermostatmode : ACommandClass {
|
||||||
private Int32 _level;
|
|
||||||
|
|
||||||
public override event UpdatedValue Update;
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
/// <summary>
|
||||||
|
/// Allowd Modes
|
||||||
|
/// </summary>
|
||||||
public ReadOnlyDictionary<Int32, String> ValidModes { get; private set; }
|
public ReadOnlyDictionary<Int32, String> ValidModes { get; private set; }
|
||||||
|
private Int32 _level;
|
||||||
|
/// <summary>
|
||||||
|
/// Actual mode
|
||||||
|
/// </summary>
|
||||||
public Int32 Level {
|
public Int32 Level {
|
||||||
get { return this._level; }
|
get { return this._level; }
|
||||||
set {
|
set {
|
||||||
@@ -25,23 +32,14 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
public Thermostatmode(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
public Thermostatmode(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
this.ValidModes = new ReadOnlyDictionary<Int32, String>(new Dictionary<Int32, String>());
|
this.ValidModes = new ReadOnlyDictionary<Int32, String>(new Dictionary<Int32, String>());
|
||||||
this.InitComplex(json);
|
this.InitComplex(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void SetUpdate(JsonData json, Match match) {
|
|
||||||
if(match.Groups[4].Value == ".data.mode") {
|
|
||||||
if(json.Keys.Contains("value") && this.CheckSetUpdateTime(json)) {
|
|
||||||
this._level = Int32.Parse(json["value"].ToString());
|
|
||||||
this.Update?.Invoke(this, new DeviceUpdateEvent(this.Level, this.LastUpdate, this));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitComplex(JsonData json) {
|
private void InitComplex(JsonData json) {
|
||||||
if (json.Keys.Contains("data")) {
|
if (json.Keys.Contains("data")) {
|
||||||
JsonData data = json["data"];
|
JsonData data = json["data"];
|
||||||
@@ -60,7 +58,9 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
public override String ToString() {
|
public override String ToString() {
|
||||||
return "ThermostatMode " + this.Name + " [" + this.Id + "]: " + this.ValidModes[this.Level];
|
return "ThermostatMode " + this.Name + " [" + this.Id + "]: " + this.ValidModes[this.Level];
|
||||||
}
|
}
|
||||||
@@ -76,5 +76,23 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
};
|
};
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
|
if(match.Groups[4].Value == ".data.mode") {
|
||||||
|
if(json.Keys.Contains("value") && this.CheckSetUpdateTime(json)) {
|
||||||
|
this._level = Int32.Parse(json["value"].ToString());
|
||||||
|
this.Update?.Invoke(this, new DeviceUpdateEvent(this.Level, this.LastUpdate, this));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ISenml
|
||||||
|
protected override List<Senml> ToSenmlList() {
|
||||||
|
return new List<Senml>() { new SenmlDouble("mode", Senml.Units.CounterValue, this.Level) };
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs;
|
|||||||
using BlubbFish.IoT.Zway.Events;
|
using BlubbFish.IoT.Zway.Events;
|
||||||
using BlubbFish.IoT.Zway.Interfaces;
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
using BlubbFish.IoT.Zway.lib;
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
||||||
@@ -15,6 +16,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
public class Thermostatsetpoint : ACommandClass {
|
public class Thermostatsetpoint : ACommandClass {
|
||||||
public override event UpdatedValue Update;
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
public Thermostatsetpoint(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
public Thermostatsetpoint(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
this.HasSub = true;
|
this.HasSub = true;
|
||||||
this.InitComplex(json);
|
this.InitComplex(json);
|
||||||
@@ -23,21 +25,6 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeviceUpdate(Object sender, DeviceUpdateEvent e) {
|
|
||||||
this.Update?.Invoke(this, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override void SetUpdate(JsonData json, Match match) {
|
|
||||||
if (match.Groups[4].Value.StartsWith(".data.")) {
|
|
||||||
Int32 subid = Int32.Parse(match.Groups[5].Value);
|
|
||||||
if (this.Sub.ContainsKey(subid)) {
|
|
||||||
this.Sub[subid].SetUpdate(json, match);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitComplex(JsonData json) {
|
private void InitComplex(JsonData json) {
|
||||||
if (json.Keys.Contains("data")) {
|
if (json.Keys.Contains("data")) {
|
||||||
JsonData data = json["data"];
|
JsonData data = json["data"];
|
||||||
@@ -54,8 +41,30 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DeviceUpdate(Object sender, DeviceUpdateEvent e) {
|
||||||
|
this.Update?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
|
if (match.Groups[4].Value.StartsWith(".data.")) {
|
||||||
|
Int32 subid = Int32.Parse(match.Groups[5].Value);
|
||||||
|
if (this.Sub.ContainsKey(subid)) {
|
||||||
|
this.Sub[subid].SetUpdate(json, match);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Helper.WriteError("Kenne in " + this.Name + " [" + this.Id + "] " + match.Groups[4].Value + " nicht!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal override void Poll() => this.PollPerSub();
|
internal override void Poll() => this.PollPerSub();
|
||||||
|
|
||||||
public override Dictionary<String, Object> ToDictionary() => this.ToDictionarySub();
|
public override Dictionary<String, Object> ToDictionary() => this.ToDictionarySub();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ISenml
|
||||||
|
protected override List<Senml> ToSenmlList() => this.ToSenmlListSub();
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Text.RegularExpressions;
|
|||||||
using BlubbFish.IoT.Zway.Events;
|
using BlubbFish.IoT.Zway.Events;
|
||||||
using BlubbFish.IoT.Zway.Interfaces;
|
using BlubbFish.IoT.Zway.Interfaces;
|
||||||
using BlubbFish.IoT.Zway.lib;
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
||||||
@@ -11,10 +12,10 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
/// 132 = Wakeup
|
/// 132 = Wakeup
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class Wakeup : ACommandClass {
|
class Wakeup : ACommandClass {
|
||||||
private Int32 _interval;
|
|
||||||
private Int32 _againstNode;
|
|
||||||
|
|
||||||
public override event UpdatedValue Update;
|
public override event UpdatedValue Update;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
private Int32 _interval;
|
||||||
public Int32 Interval {
|
public Int32 Interval {
|
||||||
get {
|
get {
|
||||||
return this._interval;
|
return this._interval;
|
||||||
@@ -25,6 +26,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private Int32 _againstNode;
|
||||||
public Int32 AgainstNode { get {
|
public Int32 AgainstNode { get {
|
||||||
return this._againstNode;
|
return this._againstNode;
|
||||||
}
|
}
|
||||||
@@ -34,10 +36,16 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
}
|
}
|
||||||
public Int32 WakeupMin { get; private set; }
|
public Int32 WakeupMin { get; private set; }
|
||||||
public Int32 WakeupMax { get; private set; }
|
public Int32 WakeupMax { get; private set; }
|
||||||
|
public Boolean HasMinMaxState { get; private set; }
|
||||||
|
public Int32 HasMinMaxLevel { get { return (this.HasMinMaxState) ? 1 : 0; } }
|
||||||
public Int32 WakeupDefault { get; private set; }
|
public Int32 WakeupDefault { get; private set; }
|
||||||
|
public Boolean HasDefaultState { get; private set; }
|
||||||
|
public Int32 HasDefaultLevel { get { return (this.HasDefaultState) ? 1 : 0; } }
|
||||||
public DateTime LastWakeup { get; private set; }
|
public DateTime LastWakeup { get; private set; }
|
||||||
public DateTime LastSleep { get; private set; }
|
public DateTime LastSleep { get; private set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructor
|
||||||
public Wakeup(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
public Wakeup(JsonData json, Tuple<Int32, Int32, Classes> id, HttpConnection http, Boolean polling) : base(json, id, http, polling) {
|
||||||
this.InitComplex(json);
|
this.InitComplex(json);
|
||||||
}
|
}
|
||||||
@@ -51,23 +59,50 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
if (data.Keys.Contains("nodeId") && data["nodeId"].Keys.Contains("value")) {
|
if (data.Keys.Contains("nodeId") && data["nodeId"].Keys.Contains("value")) {
|
||||||
this._againstNode = Int32.Parse(data["nodeId"]["value"].ToString());
|
this._againstNode = Int32.Parse(data["nodeId"]["value"].ToString());
|
||||||
}
|
}
|
||||||
if (data.Keys.Contains("min") && data["min"].Keys.Contains("value")) {
|
this.HasMinMaxState = false;
|
||||||
|
if (data.Keys.Contains("min") && data["min"].Keys.Contains("value") && data["min"]["value"] != null) {
|
||||||
this.WakeupMin = Int32.Parse(data["min"]["value"].ToString());
|
this.WakeupMin = Int32.Parse(data["min"]["value"].ToString());
|
||||||
|
this.HasMinMaxState = true;
|
||||||
}
|
}
|
||||||
if (data.Keys.Contains("max") && data["max"].Keys.Contains("value")) {
|
if (data.Keys.Contains("max") && data["max"].Keys.Contains("value") && data["max"]["value"] != null) {
|
||||||
this.WakeupMax = Int32.Parse(data["max"]["value"].ToString());
|
this.WakeupMax = Int32.Parse(data["max"]["value"].ToString());
|
||||||
|
this.HasMinMaxState = true;
|
||||||
}
|
}
|
||||||
if (data.Keys.Contains("default") && data["default"].Keys.Contains("value")) {
|
this.HasDefaultState = false;
|
||||||
|
if (data.Keys.Contains("default") && data["default"].Keys.Contains("value") && data["default"]["value"] != null) {
|
||||||
this.WakeupDefault = Int32.Parse(data["default"]["value"].ToString());
|
this.WakeupDefault = Int32.Parse(data["default"]["value"].ToString());
|
||||||
|
this.HasDefaultState = true;
|
||||||
}
|
}
|
||||||
if (data.Keys.Contains("lastWakeup") && data["lastWakeup"].Keys.Contains("value")) {
|
if (data.Keys.Contains("lastWakeup") && data["lastWakeup"].Keys.Contains("value") && data["lastWakeup"]["value"] != null) {
|
||||||
this.LastWakeup = DateTimeOffset.FromUnixTimeSeconds(Int64.Parse(data["lastWakeup"]["value"].ToString())).DateTime.ToLocalTime();
|
this.LastWakeup = DateTimeOffset.FromUnixTimeSeconds(Int64.Parse(data["lastWakeup"]["value"].ToString())).DateTime.ToLocalTime();
|
||||||
}
|
}
|
||||||
if (data.Keys.Contains("lastSleep") && data["lastSleep"].Keys.Contains("value")) {
|
if (data.Keys.Contains("lastSleep") && data["lastSleep"].Keys.Contains("value") && data["lastSleep"]["value"] != null) {
|
||||||
this.LastSleep = DateTimeOffset.FromUnixTimeSeconds(Int64.Parse(data["lastSleep"]["value"].ToString())).DateTime.ToLocalTime();
|
this.LastSleep = DateTimeOffset.FromUnixTimeSeconds(Int64.Parse(data["lastSleep"]["value"].ToString())).DateTime.ToLocalTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ACommandClass
|
||||||
|
public override String ToString() {
|
||||||
|
return "Wakeup " + this.Name + " [" + this.Id + "]: " + this.LastWakeup + "-" + this.LastSleep + " " + this.Interval + " [" + this.WakeupMin + "," + this.WakeupMax + "," + this.WakeupDefault + "," + this.AgainstNode + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Dictionary<String, Object> ToDictionary() {
|
||||||
|
return new Dictionary<String, Object> {
|
||||||
|
{ "Interval", this.Interval },
|
||||||
|
{ "AgainstNode", this.AgainstNode },
|
||||||
|
{ "WakeupMin", this.WakeupMin },
|
||||||
|
{ "WakeupMax", this.WakeupMax },
|
||||||
|
{ "HasMinMaxState", this.HasMinMaxState },
|
||||||
|
{ "HasMinMaxLevel", this.HasMinMaxLevel },
|
||||||
|
{ "WakeupDefault", this.WakeupDefault },
|
||||||
|
{ "HasDefaultState", this.HasDefaultState },
|
||||||
|
{ "HasDefaultLevel", this.HasDefaultLevel },
|
||||||
|
{ "LastWakeup", this.LastWakeup.ToString() },
|
||||||
|
{ "LastSleep", this.LastSleep.ToString() }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
internal override void SetUpdate(JsonData json, Match match) {
|
internal override void SetUpdate(JsonData json, Match match) {
|
||||||
Boolean success = false;
|
Boolean success = false;
|
||||||
@@ -90,23 +125,28 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
this._againstNode = Int32.Parse(json["nodeId"]["value"].ToString());
|
this._againstNode = Int32.Parse(json["nodeId"]["value"].ToString());
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
if (json.Keys.Contains("min") && json["min"].Keys.Contains("value")) {
|
this.HasMinMaxState = false;
|
||||||
|
if (json.Keys.Contains("min") && json["min"].Keys.Contains("value") && json["min"]["value"] != null) {
|
||||||
this.WakeupMin = Int32.Parse(json["min"]["value"].ToString());
|
this.WakeupMin = Int32.Parse(json["min"]["value"].ToString());
|
||||||
success = true;
|
success = true;
|
||||||
|
this.HasMinMaxState = true;
|
||||||
}
|
}
|
||||||
if (json.Keys.Contains("max") && json["max"].Keys.Contains("value")) {
|
if (json.Keys.Contains("max") && json["max"].Keys.Contains("value") && json["max"]["value"] != null) {
|
||||||
this.WakeupMax = Int32.Parse(json["max"]["value"].ToString());
|
this.WakeupMax = Int32.Parse(json["max"]["value"].ToString());
|
||||||
success = true;
|
success = true;
|
||||||
|
this.HasMinMaxState = true;
|
||||||
}
|
}
|
||||||
if (json.Keys.Contains("default") && json["default"].Keys.Contains("value")) {
|
this.HasDefaultState = false;
|
||||||
|
if (json.Keys.Contains("default") && json["default"].Keys.Contains("value") && json["default"]["value"] != null) {
|
||||||
this.WakeupDefault = Int32.Parse(json["default"]["value"].ToString());
|
this.WakeupDefault = Int32.Parse(json["default"]["value"].ToString());
|
||||||
success = true;
|
success = true;
|
||||||
|
this.HasDefaultState = true;
|
||||||
}
|
}
|
||||||
if (json.Keys.Contains("lastWakeup") && json["lastWakeup"].Keys.Contains("value")) {
|
if (json.Keys.Contains("lastWakeup") && json["lastWakeup"].Keys.Contains("value") && json["lastWakeup"]["value"] != null) {
|
||||||
this.LastWakeup = DateTimeOffset.FromUnixTimeSeconds(Int64.Parse(json["lastWakeup"]["value"].ToString())).DateTime.ToLocalTime();
|
this.LastWakeup = DateTimeOffset.FromUnixTimeSeconds(Int64.Parse(json["lastWakeup"]["value"].ToString())).DateTime.ToLocalTime();
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
if (json.Keys.Contains("lastSleep") && json["lastSleep"].Keys.Contains("value")) {
|
if (json.Keys.Contains("lastSleep") && json["lastSleep"].Keys.Contains("value") && json["lastSleep"]["value"] != null) {
|
||||||
this.LastSleep = DateTimeOffset.FromUnixTimeSeconds(Int64.Parse(json["lastSleep"]["value"].ToString())).DateTime.ToLocalTime();
|
this.LastSleep = DateTimeOffset.FromUnixTimeSeconds(Int64.Parse(json["lastSleep"]["value"].ToString())).DateTime.ToLocalTime();
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
@@ -117,21 +157,12 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
this.Update?.Invoke(this, new DeviceUpdateEvent(0, this.LastUpdate, this));
|
this.Update?.Invoke(this, new DeviceUpdateEvent(0, this.LastUpdate, this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public override String ToString() {
|
#region ISenml
|
||||||
return "Wakeup " + this.Name + " [" + this.Id + "]: " + this.LastWakeup + "-" + this.LastSleep + " " + this.Interval + " [" + this.WakeupMin + "," + this.WakeupMax + "," + this.WakeupDefault + "," + this.AgainstNode + "]";
|
protected override List<Senml> ToSenmlList() {
|
||||||
}
|
return new List<Senml>() { };
|
||||||
|
|
||||||
public override Dictionary<String, Object> ToDictionary() {
|
|
||||||
return new Dictionary<String, Object> {
|
|
||||||
{ "Interval", this.Interval },
|
|
||||||
{ "AgainstNode", this.AgainstNode },
|
|
||||||
{ "WakeupMin", this.WakeupMin },
|
|
||||||
{ "WakeupMax", this.WakeupMax },
|
|
||||||
{ "WakeupDefault", this.WakeupDefault },
|
|
||||||
{ "LastWakeup", this.LastWakeup.ToString() },
|
|
||||||
{ "LastSleep", this.LastSleep.ToString() }
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using LitJson;
|
|||||||
|
|
||||||
namespace BlubbFish.IoT.Zway.Devices {
|
namespace BlubbFish.IoT.Zway.Devices {
|
||||||
public class Device {
|
public class Device {
|
||||||
private Boolean polling;
|
private readonly Boolean polling;
|
||||||
|
|
||||||
public delegate void UpdatedDevice(Object sender, DeviceUpdateEvent e);
|
public delegate void UpdatedDevice(Object sender, DeviceUpdateEvent e);
|
||||||
public event UpdatedDevice Update;
|
public event UpdatedDevice Update;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ using LitJson;
|
|||||||
namespace BlubbFish.IoT.Zway.Devices {
|
namespace BlubbFish.IoT.Zway.Devices {
|
||||||
public class Instance {
|
public class Instance {
|
||||||
private DateTime nextwakeup;
|
private DateTime nextwakeup;
|
||||||
private Boolean polling;
|
private readonly Boolean polling;
|
||||||
|
|
||||||
public delegate void UpdatedInstance(Object sender, DeviceUpdateEvent e);
|
public delegate void UpdatedInstance(Object sender, DeviceUpdateEvent e);
|
||||||
public event UpdatedInstance Update;
|
public event UpdatedInstance Update;
|
||||||
|
|||||||
@@ -10,55 +10,14 @@ namespace BlubbFish.IoT.Zway.Events {
|
|||||||
public DeviceUpdateEvent() {
|
public DeviceUpdateEvent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceUpdateEvent(Double value, DateTime time, Object parent) {
|
public DeviceUpdateEvent(Object value, DateTime time, Object parent) {
|
||||||
this.GetDouble = value;
|
this.GetValue = value;
|
||||||
this.UpdateTime = time;
|
this.UpdateTime = time;
|
||||||
this.Parent = parent;
|
this.Parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceUpdateEvent(Boolean value, DateTime time, Object parent) {
|
public Object GetValue { get; }
|
||||||
this.GetBoolean = value;
|
|
||||||
this.UpdateTime = time;
|
|
||||||
this.Parent = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeviceUpdateEvent(DateTime value, DateTime time, Object parent) {
|
|
||||||
this.GetDate = value;
|
|
||||||
this.UpdateTime = time;
|
|
||||||
this.Parent = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeviceUpdateEvent(Tuple<String, String, Double> value, DateTime time, Object parent) {
|
|
||||||
this.GetStringStringDoubleTuple = value;
|
|
||||||
this.UpdateTime = time;
|
|
||||||
this.Parent = parent;
|
|
||||||
}
|
|
||||||
public DeviceUpdateEvent(Tuple<String, String, Double, Double, Double, Boolean> value, DateTime time, Object parent) {
|
|
||||||
this.GetStringStringDoubleDoubleDoubleDoubleBooleanTuple = value;
|
|
||||||
this.UpdateTime = time;
|
|
||||||
this.Parent = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeviceUpdateEvent(Tuple<Int32, Int32> value, DateTime time, Object parent) {
|
|
||||||
this.GetIntegerTuple = value;
|
|
||||||
this.UpdateTime = time;
|
|
||||||
this.Parent = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeviceUpdateEvent(Tuple<Int64, Int32> value, DateTime time, Object parent) {
|
|
||||||
this.GetLongIntegerTuple = value;
|
|
||||||
this.UpdateTime = time;
|
|
||||||
this.Parent = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Double GetDouble { get; }
|
|
||||||
public DateTime GetDate { get; }
|
|
||||||
public Tuple<String, String, Double> GetStringStringDoubleTuple { get; }
|
|
||||||
public Tuple<String, String, Double, Double, Double, Boolean> GetStringStringDoubleDoubleDoubleDoubleBooleanTuple { 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; }
|
||||||
public Boolean GetBoolean { get; }
|
|
||||||
public Tuple<Int32,Int32> GetIntegerTuple { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,10 +4,12 @@ using System.Collections.ObjectModel;
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using BlubbFish.IoT.Zway.Events;
|
using BlubbFish.IoT.Zway.Events;
|
||||||
using BlubbFish.IoT.Zway.lib;
|
using BlubbFish.IoT.Zway.lib;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces;
|
||||||
|
using BlubbFish.Utils.IoT.Interfaces.Language;
|
||||||
using LitJson;
|
using LitJson;
|
||||||
|
|
||||||
namespace BlubbFish.IoT.Zway.Interfaces {
|
namespace BlubbFish.IoT.Zway.Interfaces {
|
||||||
public abstract class ACommandClass {
|
public abstract class ACommandClass : IMqtt, ISenml {
|
||||||
protected HttpConnection http;
|
protected HttpConnection http;
|
||||||
|
|
||||||
public delegate void UpdatedValue(Object sender, DeviceUpdateEvent e);
|
public delegate void UpdatedValue(Object sender, DeviceUpdateEvent e);
|
||||||
@@ -16,36 +18,56 @@ namespace BlubbFish.IoT.Zway.Interfaces {
|
|||||||
Basic = 32,
|
Basic = 32,
|
||||||
ControllerReplication = 33,
|
ControllerReplication = 33,
|
||||||
ApplicationStatus = 34,
|
ApplicationStatus = 34,
|
||||||
SensorBinary = 48,
|
SwitchAll = 39,
|
||||||
|
SceneActivation = 43,
|
||||||
SwitchColor = 51,
|
SwitchColor = 51,
|
||||||
MeterPulse = 53,
|
MeterPulse = 53,
|
||||||
|
MeterTableMonitor = 61,
|
||||||
|
ThermostatOperatingState = 66,
|
||||||
|
ClimateControlSchedule = 70,
|
||||||
|
CRC16 = 86,
|
||||||
|
AssociationGroupInformation = 89,
|
||||||
|
DeviceResetLocally = 90,
|
||||||
|
ZWavePlusInfo = 94,
|
||||||
MultiChannel = 96,
|
MultiChannel = 96,
|
||||||
Alarm = 113,
|
DoorLock = 98,
|
||||||
|
BarrierOperator = 102,
|
||||||
ManufacturerSpecific = 114,
|
ManufacturerSpecific = 114,
|
||||||
PowerLevel = 115,
|
PowerLevel = 115,
|
||||||
|
InclusionController = 116,
|
||||||
Protection = 117,
|
Protection = 117,
|
||||||
NodeNaming = 119,
|
NodeNaming = 119,
|
||||||
FirmwareUpdate = 122,
|
FirmwareUpdate = 122,
|
||||||
|
Clock = 129,
|
||||||
Association = 133,
|
Association = 133,
|
||||||
Version = 134,
|
Version = 134,
|
||||||
|
Proprietary = 136,
|
||||||
|
TimeParameters = 139,
|
||||||
MultiChannelAssociation = 142,
|
MultiChannelAssociation = 142,
|
||||||
MultiCmd = 143
|
MultiCmd = 143,
|
||||||
|
SimpleAVControl = 148,
|
||||||
|
Security = 152
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Classes : Int32 {
|
public enum Classes : Int32 {
|
||||||
SwitchBinary = 37,
|
SwitchBinary = 37,
|
||||||
SwitchMultilevel = 38,
|
SwitchMultilevel = 38,
|
||||||
|
SceneControllerConf = 45,
|
||||||
|
SensorBinary = 48,
|
||||||
SensorMultilevel = 49,
|
SensorMultilevel = 49,
|
||||||
Meter = 50,
|
Meter = 50,
|
||||||
ThermostatMode = 64,
|
ThermostatMode = 64,
|
||||||
ThermostatSetPoint = 67,
|
ThermostatSetPoint = 67,
|
||||||
CentralScene = 91,
|
CentralScene = 91,
|
||||||
Configuration = 112,
|
Configuration = 112,
|
||||||
|
Alarm = 113,
|
||||||
Battery = 128,
|
Battery = 128,
|
||||||
Wakeup = 132,
|
Wakeup = 132,
|
||||||
Indicator = 135
|
Indicator = 135,
|
||||||
|
AlarmSensor = 156
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Properties
|
||||||
public Int32 DeviceId { get; }
|
public Int32 DeviceId { get; }
|
||||||
public Int32 Instance { get; }
|
public Int32 Instance { get; }
|
||||||
public Classes Commandclass { get; }
|
public Classes Commandclass { get; }
|
||||||
@@ -59,9 +81,9 @@ namespace BlubbFish.IoT.Zway.Interfaces {
|
|||||||
public Boolean HasSub { get; protected set; }
|
public Boolean HasSub { get; protected set; }
|
||||||
public Boolean IsSub { get; protected set; }
|
public Boolean IsSub { get; protected set; }
|
||||||
public Boolean HasReset { get; protected set; }
|
public Boolean HasReset { get; protected set; }
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
|
|
||||||
protected ACommandClass(JsonData json, Tuple<Int32, Int32, Classes, Int32> id, HttpConnection http, Boolean polling) {
|
protected ACommandClass(JsonData json, Tuple<Int32, Int32, Classes, Int32> id, HttpConnection http, Boolean polling) {
|
||||||
this.DeviceId = id.Item1;
|
this.DeviceId = id.Item1;
|
||||||
this.Instance = id.Item2;
|
this.Instance = id.Item2;
|
||||||
@@ -107,7 +129,7 @@ namespace BlubbFish.IoT.Zway.Interfaces {
|
|||||||
return GetInstanceConcrete(objectName, json, http, id, polling);
|
return GetInstanceConcrete(objectName, json, http, id, polling);
|
||||||
}
|
}
|
||||||
if (!Enum.IsDefined(typeof(IgnoredClasses), (Int32)id.Item3) && !Enum.IsDefined(typeof(Classes), id.Item3)) {
|
if (!Enum.IsDefined(typeof(IgnoredClasses), (Int32)id.Item3) && !Enum.IsDefined(typeof(Classes), id.Item3)) {
|
||||||
Helper.WriteError("CommandClass " + id.Item3 + " not exist.");
|
Helper.WriteError("CommandClass " + id.Item3 + " not exist. (" + id.Item1 + ", " + id.Item2 + ")");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -170,7 +192,6 @@ namespace BlubbFish.IoT.Zway.Interfaces {
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region SetValues
|
#region SetValues
|
||||||
|
|
||||||
protected void SetInt(Int32 value) {
|
protected void SetInt(Int32 value) {
|
||||||
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 + ")");
|
||||||
}
|
}
|
||||||
@@ -205,22 +226,7 @@ namespace BlubbFish.IoT.Zway.Interfaces {
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Output
|
#region InternalHelper
|
||||||
|
|
||||||
public String MqttTopic() {
|
|
||||||
return this.DeviceId + "/" + this.Instance + "/" + ((Int32)this.Commandclass).ToString() + (this.IsSub ? "/" + this.SensorId : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
public String ToJson() {
|
|
||||||
Dictionary<String, Object> json = this.ToDictionary();
|
|
||||||
json.Add("date", this.LastUpdate.ToString());
|
|
||||||
json.Add("name", this.Name);
|
|
||||||
json.Add("class", this.Commandclass.ToString());
|
|
||||||
return JsonMapper.ToJson(json);
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract Dictionary<String, Object> ToDictionary();
|
|
||||||
|
|
||||||
protected Dictionary<String, Object> ToDictionarySub() {
|
protected Dictionary<String, Object> ToDictionarySub() {
|
||||||
Dictionary<String, Object> json = new Dictionary<String, Object>();
|
Dictionary<String, Object> json = new Dictionary<String, Object>();
|
||||||
foreach (KeyValuePair<Int32, ACommandClass> item in this.Sub) {
|
foreach (KeyValuePair<Int32, ACommandClass> item in this.Sub) {
|
||||||
@@ -229,8 +235,52 @@ namespace BlubbFish.IoT.Zway.Interfaces {
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected List<Senml> ToSenmlListSub() {
|
||||||
|
List<Senml> list = new List<Senml>();
|
||||||
|
foreach (KeyValuePair<Int32, ACommandClass> item in this.Sub) {
|
||||||
|
list.AddRange(item.Value.ToSenmlList());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region IMqtt
|
||||||
|
public String MqttTopic() {
|
||||||
|
return this.DeviceId + "/" + this.Instance + "/" + ((Int32)this.Commandclass).ToString() + (this.IsSub ? "/" + this.SensorId : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String ToJson() {
|
||||||
|
Dictionary<String, Object> json = this.ToDictionary();
|
||||||
|
json.Add("LastUpdate", this.LastUpdate.ToString());
|
||||||
|
json.Add("Name", this.Name);
|
||||||
|
json.Add("Commandclass", this.Commandclass.ToString());
|
||||||
|
return JsonMapper.ToJson(json);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ISenml
|
||||||
|
public String ToSenml() {
|
||||||
|
List<Senml> l = this.ToSenmlList();
|
||||||
|
if(l.Count == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Dictionary<String, Object> json = new Dictionary<String, Object> {
|
||||||
|
{ "e", l },
|
||||||
|
{ "bn", this.DeviceId + "/" + this.Instance + "/" + ((Int32)this.Commandclass).ToString() + (this.IsSub ? "/" + this.SensorId : "") + "/" },
|
||||||
|
{ "bt", ((DateTimeOffset)this.LastUpdate).ToUnixTimeSeconds() }
|
||||||
|
};
|
||||||
|
return JsonMapper.ToJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String SenmlTopic() {
|
||||||
|
return "LS/v2/ZGW/";
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Abstract
|
||||||
|
protected abstract List<Senml> ToSenmlList();
|
||||||
|
public abstract Dictionary<String, Object> ToDictionary();
|
||||||
internal abstract void SetUpdate(JsonData json, Match match);
|
internal abstract void SetUpdate(JsonData json, Match match);
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("Zway")]
|
[assembly: AssemblyProduct("Zway")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
[assembly: AssemblyCopyright("Copyright © 2017 - 29.09.2018")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
@@ -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.4.0")]
|
[assembly: AssemblyVersion("1.5.1")]
|
||||||
[assembly: AssemblyFileVersion("1.3.4.0")]
|
[assembly: AssemblyFileVersion("1.5.1")]
|
||||||
|
|||||||
+17
-6
@@ -9,8 +9,9 @@
|
|||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>BlubbFish.IoT.Zway</RootNamespace>
|
<RootNamespace>BlubbFish.IoT.Zway</RootNamespace>
|
||||||
<AssemblyName>Zway</AssemblyName>
|
<AssemblyName>Zway</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
@@ -30,9 +31,6 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="LitJson, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\..\IoT-Bot\packages\LitJson.0.9.0\lib\LitJson.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
@@ -43,14 +41,21 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Devices\CommandClasses\Alarm.cs" />
|
||||||
<Compile Include="Devices\CommandClasses\Battery.cs" />
|
<Compile Include="Devices\CommandClasses\Battery.cs" />
|
||||||
<Compile Include="Devices\CommandClasses\CommandClassSubs\Configurationsub.cs" />
|
<Compile Include="Devices\CommandClasses\CommandClassSubs\Configurationsub.cs" />
|
||||||
|
<Compile Include="Devices\CommandClasses\CommandClassSubs\Alarmsensorsub.cs" />
|
||||||
|
<Compile Include="Devices\CommandClasses\CommandClassSubs\SceneControllerConfSub.cs" />
|
||||||
|
<Compile Include="Devices\CommandClasses\CommandClassSubs\SensorBinarySub.cs" />
|
||||||
<Compile Include="Devices\CommandClasses\CommandClassSubs\ThermostatSetPointSub.cs" />
|
<Compile Include="Devices\CommandClasses\CommandClassSubs\ThermostatSetPointSub.cs" />
|
||||||
<Compile Include="Devices\CommandClasses\Configuration.cs" />
|
<Compile Include="Devices\CommandClasses\Configuration.cs" />
|
||||||
<Compile Include="Devices\CommandClasses\Indicator.cs" />
|
<Compile Include="Devices\CommandClasses\Indicator.cs" />
|
||||||
|
<Compile Include="Devices\CommandClasses\AlarmSensor.cs" />
|
||||||
<Compile Include="Devices\CommandClasses\Meter.cs" />
|
<Compile Include="Devices\CommandClasses\Meter.cs" />
|
||||||
<Compile Include="Devices\CommandClasses\CommandClassSubs\MeterSub.cs" />
|
<Compile Include="Devices\CommandClasses\CommandClassSubs\MeterSub.cs" />
|
||||||
<Compile Include="Devices\CommandClasses\CommandClassSubs\SensorMultilevelSub.cs" />
|
<Compile Include="Devices\CommandClasses\CommandClassSubs\SensorMultilevelSub.cs" />
|
||||||
|
<Compile Include="Devices\CommandClasses\SceneControllerConf.cs" />
|
||||||
|
<Compile Include="Devices\CommandClasses\SensorBinary.cs" />
|
||||||
<Compile Include="Devices\CommandClasses\Wakeup.cs" />
|
<Compile Include="Devices\CommandClasses\Wakeup.cs" />
|
||||||
<Compile Include="Devices\Device.cs" />
|
<Compile Include="Devices\Device.cs" />
|
||||||
<Compile Include="Interfaces\ACommandClass.cs" />
|
<Compile Include="Interfaces\ACommandClass.cs" />
|
||||||
@@ -69,8 +74,14 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="packages.config" />
|
<ProjectReference Include="..\..\Librarys\litjson\litjson\litjson_4.7.1.csproj">
|
||||||
|
<Project>{91a14cd2-2940-4500-8193-56d37edddbaa}</Project>
|
||||||
|
<Name>litjson_4.7.1</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\..\Utils\IoT\Interfaces\Iot-Interfaces.csproj">
|
||||||
|
<Project>{4daada29-c600-4cf3-8ad3-9c97c8d7f632}</Project>
|
||||||
|
<Name>Iot-Interfaces</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup />
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Reflection;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using BlubbFish.IoT.Zway.Devices;
|
using BlubbFish.IoT.Zway.Devices;
|
||||||
@@ -17,7 +16,7 @@ namespace BlubbFish.IoT.Zway {
|
|||||||
private Thread updatethread;
|
private Thread updatethread;
|
||||||
private Thread pollthread;
|
private Thread pollthread;
|
||||||
public static ReadOnlyDictionary<String, String> namelist;
|
public static ReadOnlyDictionary<String, String> namelist;
|
||||||
private Boolean polling;
|
private readonly Boolean polling;
|
||||||
|
|
||||||
public delegate void DataUpdate(Object sender, DeviceUpdateEvent e);
|
public delegate void DataUpdate(Object sender, DeviceUpdateEvent e);
|
||||||
public event DataUpdate Update;
|
public event DataUpdate Update;
|
||||||
@@ -105,8 +104,10 @@ namespace BlubbFish.IoT.Zway {
|
|||||||
CultureInfo.DefaultThreadCurrentUICulture = info;
|
CultureInfo.DefaultThreadCurrentUICulture = info;
|
||||||
Thread.CurrentThread.CurrentCulture = info;
|
Thread.CurrentThread.CurrentCulture = info;
|
||||||
Thread.CurrentThread.CurrentUICulture = info;
|
Thread.CurrentThread.CurrentUICulture = info;
|
||||||
|
DateTime lastRequest = DateTime.Now.AddSeconds(-2);
|
||||||
while (true) {
|
while (true) {
|
||||||
Int64 date = ((DateTimeOffset)DateTime.Now.AddSeconds(-2)).ToUnixTimeSeconds();
|
Int64 date = ((DateTimeOffset)lastRequest).ToUnixTimeSeconds();
|
||||||
|
lastRequest = DateTime.Now;
|
||||||
JsonData notifications = this.http.GetJson("ZWave.zway/Data/" + date);
|
JsonData notifications = this.http.GetJson("ZWave.zway/Data/" + date);
|
||||||
foreach (String item in notifications.Keys) {
|
foreach (String item in notifications.Keys) {
|
||||||
Match match = new Regex("^devices\\.([0-9]+)\\.instances\\.([0-9]+)\\.commandClasses\\.([0-9]+)(\\.data\\.([0-9]+)|\\.data\\.[a-z].*|\\.data)$", RegexOptions.IgnoreCase).Match(item);
|
Match match = new Regex("^devices\\.([0-9]+)\\.instances\\.([0-9]+)\\.commandClasses\\.([0-9]+)(\\.data\\.([0-9]+)|\\.data\\.[a-z].*|\\.data)$", RegexOptions.IgnoreCase).Match(item);
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
+33
-10
@@ -6,9 +6,9 @@ using LitJson;
|
|||||||
|
|
||||||
namespace BlubbFish.IoT.Zway.lib {
|
namespace BlubbFish.IoT.Zway.lib {
|
||||||
public class HttpConnection {
|
public class HttpConnection {
|
||||||
private String auth;
|
private readonly String auth;
|
||||||
private String server;
|
private readonly String server;
|
||||||
private Object getLock = new Object();
|
private static readonly Object getLock = new Object();
|
||||||
|
|
||||||
internal HttpConnection(String server, String user, String pass) {
|
internal HttpConnection(String server, String user, String pass) {
|
||||||
this.auth = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(user + ":" + pass));
|
this.auth = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(user + ":" + pass));
|
||||||
@@ -17,11 +17,23 @@ namespace BlubbFish.IoT.Zway.lib {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void Init() {
|
private void Init() {
|
||||||
this.GetString("ZAutomation/api/v1/status");
|
this.GetVoid("ZAutomation/api/v1/status");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal JsonData GetJson(String v) {
|
internal JsonData GetJson(String v) {
|
||||||
String text = this.GetString(v);
|
String text = null;
|
||||||
|
for (Int32 i = 0; i < 3; i++) {
|
||||||
|
try {
|
||||||
|
text = this.GetString(v);
|
||||||
|
break;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Helper.WriteError(e.Message);
|
||||||
|
if(i==2) {
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
System.Threading.Thread.Sleep(30000);
|
||||||
|
}
|
||||||
|
}
|
||||||
if(text == null) {
|
if(text == null) {
|
||||||
return new JsonData();
|
return new JsonData();
|
||||||
}
|
}
|
||||||
@@ -33,14 +45,25 @@ namespace BlubbFish.IoT.Zway.lib {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal void GetVoid(String v) {
|
internal void GetVoid(String v) {
|
||||||
|
for (Int32 i = 0; i < 3; i++) {
|
||||||
|
try {
|
||||||
this.GetString(v, false);
|
this.GetString(v, false);
|
||||||
|
break;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Helper.WriteError(e.Message);
|
||||||
|
if (i == 2) {
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
System.Threading.Thread.Sleep(30000);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String GetString(String v, Boolean withoutput = true) {
|
private String GetString(String v, Boolean withoutput = true) {
|
||||||
String ret = null;
|
String ret = null;
|
||||||
lock (this.getLock) {
|
lock (getLock) {
|
||||||
HttpWebRequest request = WebRequest.CreateHttp(this.server + v);
|
HttpWebRequest request = WebRequest.CreateHttp(this.server + v);
|
||||||
request.Timeout = 5000;
|
request.Timeout = 10000;
|
||||||
request.Headers.Add(HttpRequestHeader.Authorization, this.auth);
|
request.Headers.Add(HttpRequestHeader.Authorization, this.auth);
|
||||||
try {
|
try {
|
||||||
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
|
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
|
||||||
@@ -54,9 +77,9 @@ namespace BlubbFish.IoT.Zway.lib {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Helper.WriteError("Konnte keine Verbindung zum Razzbery Server herstellen. Resource: \"" + this.server + v + "\" Fehler: " + e.Message);
|
//Helper.WriteError("Konnte keine Verbindung zum Razzbery Server herstellen. Resource: \"" + this.server + v + "\" Fehler: " + e.Message);
|
||||||
return null;
|
//return null;
|
||||||
//throw new Exceptions.ConnectionException("Konnte keine Verbindung zum Razzbery Server herstellen: " + e.Message);
|
throw new Exceptions.ConnectionException("Konnte keine Verbindung zum Razzbery Server herstellen: " + e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<packages>
|
|
||||||
<package id="LitJson" version="0.9.0" targetFramework="net461" />
|
|
||||||
</packages>
|
|
||||||
Reference in New Issue
Block a user