diff --git a/Zway-Bot/Moduls/Mqtt.cs b/Zway-Bot/Moduls/Mqtt.cs index b1a7aa4..e334c65 100644 --- a/Zway-Bot/Moduls/Mqtt.cs +++ b/Zway-Bot/Moduls/Mqtt.cs @@ -63,40 +63,44 @@ namespace BlubbFish.IoT.Bots.ZwayBot.Moduls { } protected virtual void MqttUpdate(Object sender, BackendEvent e) { - if (e.From.ToString().StartsWith("zwavebot/devices/") && (e.From.ToString().EndsWith("/set") || e.From.ToString().EndsWith("/get"))) { - Match m = new Regex("^zwavebot/devices/(\\d+)/(\\d+)/(\\d+)/[gs]et$|^zwavebot/devices/(\\d+)/(\\d+)/(\\d+)/(\\d+)/[gs]et$").Match(e.From.ToString()); - String id = ""; - if (m.Groups[1].Success) { - id = m.Groups[1].Value + "-" + m.Groups[2].Value + "-" + m.Groups[3].Value; - } - if (m.Groups[4].Success) { - id = m.Groups[4].Value + "-" + m.Groups[5].Value + "-" + m.Groups[6].Value + "-" + m.Groups[7].Value; - } - ACommandClass c = this.library.GetCommandClass(id); - if (c == null) { - return; - } - if (e.From.ToString().EndsWith("/set")) { - try { - JsonData a = JsonMapper.ToObject(e.Message); - foreach (String item in a.Keys) { - String key = item.ToUpperLower(); - if (c.HasProperty(key)) { - c.SetProperty(key, a[item].ToString()); - this.Update?.Invoke(this, new MqttEvent(c.Id, a[item].ToString())); - } + try { + if (this.mqttConnect) { + if (e.From.ToString().StartsWith("zwavebot/devices/") && (e.From.ToString().EndsWith("/set") || e.From.ToString().EndsWith("/get"))) { + Match m = new Regex("^zwavebot/devices/(\\d+)/(\\d+)/(\\d+)/[gs]et$|^zwavebot/devices/(\\d+)/(\\d+)/(\\d+)/(\\d+)/[gs]et$").Match(e.From.ToString()); + String id = ""; + if (m.Groups[1].Success) { + id = m.Groups[1].Value + "-" + m.Groups[2].Value + "-" + m.Groups[3].Value; } - } catch (Exception) { } - } else if (e.From.ToString().EndsWith("/get")) { - c.PollOnce = true; - ((ADataBackend)this.mqtt).Send("zwavebot/devices/" + c.MqttTopic(), c.ToJson()); - this.Update?.Invoke(this, new MqttEvent(e.From.ToString(), "Dataget")); + if (m.Groups[4].Success) { + id = m.Groups[4].Value + "-" + m.Groups[5].Value + "-" + m.Groups[6].Value + "-" + m.Groups[7].Value; + } + ACommandClass c = this.library.GetCommandClass(id); + if (c == null) { + return; + } + if (e.From.ToString().EndsWith("/set")) { + try { + JsonData a = JsonMapper.ToObject(e.Message); + foreach (String item in a.Keys) { + String key = item.ToUpperLower(); + if (c.HasProperty(key)) { + c.SetProperty(key, a[item].ToString()); + this.Update?.Invoke(this, new MqttEvent(c.Id, a[item].ToString())); + } + } + } catch (Exception) { } + } else if (e.From.ToString().EndsWith("/get")) { + c.PollOnce = true; + ((ADataBackend)this.mqtt).Send("zwavebot/devices/" + c.MqttTopic(), c.ToJson()); + this.Update?.Invoke(this, new MqttEvent(e.From.ToString(), "Dataget")); + } + } + Tuple cs = this.ChangeConfig(e, "zwavebot/config/"); + if (cs.Item1) { + this.Update?.Invoke(this, cs.Item2); + } } - } - Tuple cs = this.ChangeConfig(e, "zwavebot/config/"); - if (cs.Item1) { - this.Update?.Invoke(this, cs.Item2); - } + } catch { } } #endregion } diff --git a/Zway-Bot/Properties/AssemblyInfo.cs b/Zway-Bot/Properties/AssemblyInfo.cs index f89170c..1e30730 100644 --- a/Zway-Bot/Properties/AssemblyInfo.cs +++ b/Zway-Bot/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("BlubbFish")] [assembly: AssemblyProduct("Zway-Bot")] -[assembly: AssemblyCopyright("Copyright © 2017 - 05.06.2018")] +[assembly: AssemblyCopyright("Copyright © 2017 - 29.09.2018")] [assembly: AssemblyTrademark("BlubbFish")] [assembly: AssemblyCulture("")] @@ -31,8 +31,8 @@ using System.Runtime.InteropServices; // Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.6.2")] -[assembly: AssemblyFileVersion("1.6.2")] +[assembly: AssemblyVersion("1.7.0")] +[assembly: AssemblyFileVersion("1.7.0")] [assembly: NeutralResourcesLanguage("de-DE")] // “Internet Of Things” icon by By Michael Wohlwend, US, from thenounproject.com. diff --git a/Zway-Bot/bin/Release/Bot-Utils.dll b/Zway-Bot/bin/Release/Bot-Utils.dll index 76f5df2..69fc9ca 100644 Binary files a/Zway-Bot/bin/Release/Bot-Utils.dll and b/Zway-Bot/bin/Release/Bot-Utils.dll differ diff --git a/Zway-Bot/bin/Release/ConnectorDataMqtt.dll b/Zway-Bot/bin/Release/ConnectorDataMqtt.dll index b867903..67940f6 100644 Binary files a/Zway-Bot/bin/Release/ConnectorDataMqtt.dll and b/Zway-Bot/bin/Release/ConnectorDataMqtt.dll differ diff --git a/Zway-Bot/bin/Release/Iot-Interfaces.dll b/Zway-Bot/bin/Release/Iot-Interfaces.dll index 195cade..1f83324 100644 Binary files a/Zway-Bot/bin/Release/Iot-Interfaces.dll and b/Zway-Bot/bin/Release/Iot-Interfaces.dll differ diff --git a/Zway-Bot/bin/Release/M2Mqtt.dll b/Zway-Bot/bin/Release/M2Mqtt.dll index 8bd599a..3c3304a 100644 Binary files a/Zway-Bot/bin/Release/M2Mqtt.dll and b/Zway-Bot/bin/Release/M2Mqtt.dll differ diff --git a/Zway-Bot/bin/Release/Utils-IoT.dll b/Zway-Bot/bin/Release/Utils-IoT.dll index be72ead..b2cf770 100644 Binary files a/Zway-Bot/bin/Release/Utils-IoT.dll and b/Zway-Bot/bin/Release/Utils-IoT.dll differ diff --git a/Zway-Bot/bin/Release/Utils.dll b/Zway-Bot/bin/Release/Utils.dll index 4e71b2a..b8603a4 100644 Binary files a/Zway-Bot/bin/Release/Utils.dll and b/Zway-Bot/bin/Release/Utils.dll differ diff --git a/Zway-Bot/bin/Release/Zway-Bot.exe b/Zway-Bot/bin/Release/Zway-Bot.exe index 16d5af9..83a0231 100644 Binary files a/Zway-Bot/bin/Release/Zway-Bot.exe and b/Zway-Bot/bin/Release/Zway-Bot.exe differ diff --git a/Zway-Bot/bin/Release/Zway.dll b/Zway-Bot/bin/Release/Zway.dll index 4050284..41321df 100644 Binary files a/Zway-Bot/bin/Release/Zway.dll and b/Zway-Bot/bin/Release/Zway.dll differ diff --git a/Zway-Bot/bin/Release/litjson.dll b/Zway-Bot/bin/Release/litjson.dll index 84ff2fe..a685153 100644 Binary files a/Zway-Bot/bin/Release/litjson.dll and b/Zway-Bot/bin/Release/litjson.dll differ diff --git a/Zway-Bot/dpkg/make-deb.sh b/Zway-Bot/dpkg/make-deb.sh index d4a5801..cf4fba8 100644 --- a/Zway-Bot/dpkg/make-deb.sh +++ b/Zway-Bot/dpkg/make-deb.sh @@ -6,7 +6,7 @@ OUTPUT="../bin/Release" EXEC="$ROOT/usr/local/bin/zwaybot" CONFIG="$ROOT/etc/zwaybot" -SYSTEMD="$ROOT/etc/systemd/system" +SYSTEMD="$ROOT/lib/systemd/system" LOGROTATE="$ROOT/etc/logrotate.d" DEBIAN="$ROOT/DEBIAN" diff --git a/Zway-Bot/dpkg/postinst b/Zway-Bot/dpkg/postinst index 4a8d244..c673213 100644 --- a/Zway-Bot/dpkg/postinst +++ b/Zway-Bot/dpkg/postinst @@ -1,5 +1,6 @@ #!/bin/bash +systemctl enable zwaybot systemctl daemon-reload if [[ $(systemctl is-active zwaybot || true) == "active" ]] then diff --git a/Zway-Bot/dpkg/zwaybot.service b/Zway-Bot/dpkg/zwaybot.service index 356e3d8..7df3b3e 100644 --- a/Zway-Bot/dpkg/zwaybot.service +++ b/Zway-Bot/dpkg/zwaybot.service @@ -11,6 +11,7 @@ WorkingDirectory=/usr/local/bin/zwaybot # ExecStartPre=/bin/rm /var/log/zwaybot.log && /bin/touch /var/log/zwaybot.log && /bin/chown zwaybot:zwaybot /var/log/zwaybot.log && /bin/chmod 644 /var/log/zwaybot.log ExecStart=/usr/bin/mono /usr/local/bin/zwaybot/Zway-Bot.exe KillMode=control-group +TimeoutStopSec=5 Restart=on-failure StandardOutput=null StandardError=syslog