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 |
@@ -31,11 +31,19 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void InitComplex(JsonData json) {
|
private void InitComplex(JsonData json) {
|
||||||
if (json.Keys.Contains("data") && json["data"].Keys.Contains("V1event") &&
|
if (json.Keys.Contains("data") && json["data"].Keys.Contains("V1event")) {
|
||||||
json["data"]["V1event"].Keys.Contains("alarmType") && json["data"]["V1event"]["alarmType"].Keys.Contains("value") &&
|
if(json["data"]["V1event"].Keys.Contains("alarmType") &&
|
||||||
json["data"]["V1event"].Keys.Contains("level") && json["data"]["V1event"]["level"].Keys.Contains("value")) {
|
json["data"]["V1event"]["alarmType"].Keys.Contains("value") &&
|
||||||
this.AlarmType = Int32.Parse(json["data"]["V1event"]["alarmType"]["value"].ToString());
|
json["data"]["V1event"]["alarmType"]["value"] != null &&
|
||||||
this.Level = Int32.Parse(json["data"]["V1event"]["level"]["value"].ToString());
|
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
|
#endregion
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
|||||||
Double l = Double.Parse(json["val"]["value"].ToString());
|
Double l = Double.Parse(json["val"]["value"].ToString());
|
||||||
if (t == "Power" && (l > 3660 || l < 0) ||
|
if (t == "Power" && (l > 3660 || l < 0) ||
|
||||||
t == "Temperature" && (l > 65 || l < -25) ||
|
t == "Temperature" && (l > 65 || l < -25) ||
|
||||||
(t == "Temperature" && this.Level >= 4 && l == 0)) {
|
(t == "Temperature" && this.Level >= 4 && Math.Abs(l) <= 0.1)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,6 +89,8 @@ namespace BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs {
|
|||||||
return new List<Senml>() { new SenmlDouble("power", Senml.Units.Watt, this.Level) };
|
return new List<Senml>() { new SenmlDouble("power", Senml.Units.Watt, this.Level) };
|
||||||
} else if(this.Scale == "°C") {
|
} else if(this.Scale == "°C") {
|
||||||
return new List<Senml>() { new SenmlDouble("temperatur", Senml.Units.Celsius, this.Level) };
|
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>() { };
|
return new List<Senml>() { };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -23,22 +23,29 @@ namespace BlubbFish.IoT.Zway.Interfaces {
|
|||||||
SwitchColor = 51,
|
SwitchColor = 51,
|
||||||
MeterPulse = 53,
|
MeterPulse = 53,
|
||||||
MeterTableMonitor = 61,
|
MeterTableMonitor = 61,
|
||||||
|
ThermostatOperatingState = 66,
|
||||||
|
ClimateControlSchedule = 70,
|
||||||
CRC16 = 86,
|
CRC16 = 86,
|
||||||
AssociationGroupInformation = 89,
|
AssociationGroupInformation = 89,
|
||||||
DeviceResetLocally = 90,
|
DeviceResetLocally = 90,
|
||||||
ZWavePlusInfo = 94,
|
ZWavePlusInfo = 94,
|
||||||
MultiChannel = 96,
|
MultiChannel = 96,
|
||||||
DoorLock = 98,
|
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,
|
Proprietary = 136,
|
||||||
|
TimeParameters = 139,
|
||||||
MultiChannelAssociation = 142,
|
MultiChannelAssociation = 142,
|
||||||
MultiCmd = 143,
|
MultiCmd = 143,
|
||||||
|
SimpleAVControl = 148,
|
||||||
Security = 152
|
Security = 152
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,14 +266,14 @@ namespace BlubbFish.IoT.Zway.Interfaces {
|
|||||||
}
|
}
|
||||||
Dictionary<String, Object> json = new Dictionary<String, Object> {
|
Dictionary<String, Object> json = new Dictionary<String, Object> {
|
||||||
{ "e", l },
|
{ "e", l },
|
||||||
{ "bn", "urn:dev:id:" + this.SenmlTopic() },
|
{ "bn", this.DeviceId + "/" + this.Instance + "/" + ((Int32)this.Commandclass).ToString() + (this.IsSub ? "/" + this.SensorId : "") + "/" },
|
||||||
{ "bt", ((DateTimeOffset)this.LastUpdate).ToUnixTimeSeconds() }
|
{ "bt", ((DateTimeOffset)this.LastUpdate).ToUnixTimeSeconds() }
|
||||||
};
|
};
|
||||||
return JsonMapper.ToJson(json);
|
return JsonMapper.ToJson(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String SenmlTopic() {
|
public String SenmlTopic() {
|
||||||
return this.DeviceId + "/" + this.Instance + "/" + ((Int32)this.Commandclass).ToString() + (this.IsSub ? "/" + this.SensorId : "");
|
return "LS/v2/ZGW/";
|
||||||
}
|
}
|
||||||
#endregion
|
#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 - 03.05.2018")]
|
[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.4.0.0")]
|
[assembly: AssemblyVersion("1.5.1")]
|
||||||
[assembly: AssemblyFileVersion("1.4.0.0")]
|
[assembly: AssemblyFileVersion("1.5.1")]
|
||||||
|
|||||||
@@ -16,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;
|
||||||
@@ -104,9 +104,11 @@ 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();
|
||||||
JsonData notifications = this.http.GetJson("ZWave.zway/Data/"+date);
|
lastRequest = DateTime.Now;
|
||||||
|
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);
|
||||||
if(match.Success) {
|
if(match.Success) {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
+34
-11
@@ -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) {
|
||||||
this.GetString(v, false);
|
for (Int32 i = 0; i < 3; i++) {
|
||||||
|
try {
|
||||||
|
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user