diff --git a/Zway/Devices/Instance.cs b/Zway/Devices/Instance.cs index 72a75a6..f267740 100644 --- a/Zway/Devices/Instance.cs +++ b/Zway/Devices/Instance.cs @@ -10,7 +10,7 @@ using LitJson; namespace BlubbFish.IoT.Zway.Devices { public class Instance { private DateTime nextwakeup; - private Boolean polling; + private readonly Boolean polling; public delegate void UpdatedInstance(Object sender, DeviceUpdateEvent e); public event UpdatedInstance Update; diff --git a/Zway/Interfaces/ACommandClass.cs b/Zway/Interfaces/ACommandClass.cs index fcb3fe3..3ed8ea5 100644 --- a/Zway/Interfaces/ACommandClass.cs +++ b/Zway/Interfaces/ACommandClass.cs @@ -31,18 +31,21 @@ namespace BlubbFish.IoT.Zway.Interfaces { ZWavePlusInfo = 94, MultiChannel = 96, DoorLock = 98, + BarrierOperator = 102, ManufacturerSpecific = 114, PowerLevel = 115, InclusionController = 116, Protection = 117, NodeNaming = 119, FirmwareUpdate = 122, + Clock = 129, Association = 133, Version = 134, Proprietary = 136, TimeParameters = 139, MultiChannelAssociation = 142, MultiCmd = 143, + SimpleAVControl = 148, Security = 152 } diff --git a/Zway/Properties/AssemblyInfo.cs b/Zway/Properties/AssemblyInfo.cs index 47877e2..fd97e1f 100644 --- a/Zway/Properties/AssemblyInfo.cs +++ b/Zway/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Zway")] -[assembly: AssemblyCopyright("Copyright © 2017 - 03.05.2018")] +[assembly: AssemblyCopyright("Copyright © 2017 - 29.09.2018")] [assembly: AssemblyTrademark("")] [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, // indem Sie "*" wie unten gezeigt eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.4.4")] -[assembly: AssemblyFileVersion("1.4.4")] +[assembly: AssemblyVersion("1.5.0")] +[assembly: AssemblyFileVersion("1.5.0")] diff --git a/Zway/ZwayController.cs b/Zway/ZwayController.cs index 96bf6d6..2bf26f9 100644 --- a/Zway/ZwayController.cs +++ b/Zway/ZwayController.cs @@ -104,9 +104,11 @@ namespace BlubbFish.IoT.Zway { CultureInfo.DefaultThreadCurrentUICulture = info; Thread.CurrentThread.CurrentCulture = info; Thread.CurrentThread.CurrentUICulture = info; + DateTime lastRequest = DateTime.Now.AddSeconds(-2); while (true) { - Int64 date = ((DateTimeOffset)DateTime.Now.AddSeconds(-2)).ToUnixTimeSeconds(); - JsonData notifications = this.http.GetJson("ZWave.zway/Data/"+date); + Int64 date = ((DateTimeOffset)lastRequest).ToUnixTimeSeconds(); + lastRequest = DateTime.Now; + JsonData notifications = this.http.GetJson("ZWave.zway/Data/" + date); 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); if(match.Success) { diff --git a/Zway/bin/Release/Zway.dll b/Zway/bin/Release/Zway.dll index 4050284..41321df 100644 Binary files a/Zway/bin/Release/Zway.dll and b/Zway/bin/Release/Zway.dll differ diff --git a/Zway/lib/HttpClient.cs b/Zway/lib/HttpClient.cs index 0f153b6..18e041a 100644 --- a/Zway/lib/HttpClient.cs +++ b/Zway/lib/HttpClient.cs @@ -8,7 +8,7 @@ namespace BlubbFish.IoT.Zway.lib { public class HttpConnection { private readonly String auth; private readonly String server; - private readonly Object getLock = new Object(); + private static readonly Object getLock = new Object(); internal HttpConnection(String server, String user, String pass) { this.auth = "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(user + ":" + pass)); @@ -17,11 +17,23 @@ namespace BlubbFish.IoT.Zway.lib { } private void Init() { - this.GetString("ZAutomation/api/v1/status"); + this.GetVoid("ZAutomation/api/v1/status"); } 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) { return new JsonData(); } @@ -33,14 +45,25 @@ namespace BlubbFish.IoT.Zway.lib { } 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) { String ret = null; - lock (this.getLock) { + lock (getLock) { HttpWebRequest request = WebRequest.CreateHttp(this.server + v); - request.Timeout = 5000; + request.Timeout = 10000; request.Headers.Add(HttpRequestHeader.Authorization, this.auth); try { using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {