Compare commits

..
15 Commits
Author SHA1 Message Date
BlubbFish c792ea20ad Utils.csproj
[NF] Programmlogger added (v1.1.0)
[NF] Utils fixing tiny issues

Zway-Bot.csproj
[NF] changes Topics without beginning /
[NF] Using programmlogger (v1.4.0)
2018-05-15 18:49:03 +00:00
BlubbFish 611205e78f [BF] Fixing Issue with Math.Abs(l) 2018-05-12 12:36:32 +00:00
BlubbFish 4be8bb72f4 [BF] Some sensors make wrong measurements near 0 not exactly 0, so ABS(value) >= 0.1 is alse false 2018-05-10 06:26:39 +00:00
BlubbFish 76cb025606 [NF] Cleaning up
[NF] Create Debian Package
2018-05-08 17:25:39 +00:00
BlubbFish aa84aa0539 [BF] BOM from Settings file removed 2018-05-08 07:39:13 +00:00
BlubbFish 04f43b95ff [BF] Fixing Senml
[NF] Senml now has a configure option to setup the guid
[NF] Zway-Bot now listen on /exit
[NF] Implment searchpath for Zway-Bot (/etc/zwaybot and %appdata%/zwaybot)
2018-05-07 16:52:24 +00:00
BlubbFish a1009b5293 [NF] Now creating correct Senml for Linksmart 2018-05-07 14:02:57 +00:00
BlubbFish 91a05f882e [NF] Create Senml Messages for Linksmart 2018-05-03 14:43:50 +00:00
BlubbFish 74d270b6d2 [NF] Create Senml Messages for Linksmart 2018-05-03 14:39:08 +00:00
BlubbFish 200420c9b0 [NF] Create Senml Messages for Linksmart 2018-05-03 14:35:02 +00:00
BlubbFish acf5cea593 [DW] Flex4Grid deleted
[NF] BosMon Mqtt Plugin created
2018-03-31 20:42:28 +00:00
BlubbFish 307f03c7c0 [NF] v1.3.6.0 Better levelcheck and Alarmsensor added 2018-01-01 02:09:55 +00:00
BlubbFish 32b4daf3fb [BF] v1.3.5.3 Change Level to numeric and create State for Bollean values, because telegraf only parse numeric 2017-12-25 18:11:01 +00:00
BlubbFish 55e88f7b45 [[BF] v1.3.5.2 Check to avoid megapeaks in data now also for temperature 2017-12-24 10:43:58 +00:00
BlubbFish 8baef3b2b5 [BF] v1.3.5.1 Check to avoid megapeaks in Data 2017-12-23 22:37:36 +00:00
63 changed files with 834 additions and 252 deletions
+18 -6
View File
@@ -11,10 +11,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils", "..\Utils\Utils\Uti
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utils-IoT", "..\Utils\IoT\Utils-IoT.csproj", "{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorDataMosquitto", "..\Utils\IoT\Connector\Data\Mosquitto\ConnectorDataMosquitto.csproj", "{39235FAD-BA9D-4B51-82FC-6969967BEAE9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConnectorDataMqtt", "..\Utils\IoT\Connector\Data\Mqtt\ConnectorDataMqtt.csproj", "{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Iot-Interfaces", "..\Utils\IoT\Interfaces\Iot-Interfaces.csproj", "{4DAADA29-C600-4CF3-8AD3-9C97C8D7F632}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "litjson_4.7.1", "..\Librarys\litjson\litjson\litjson_4.7.1.csproj", "{91A14CD2-2940-4500-8193-56D37EDDDBAA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "M2Mqtt", "..\Librarys\mqtt\M2Mqtt\M2Mqtt_4.7.1.csproj", "{A11AEF5A-B246-4FE8-8330-06DB73CC8074}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -37,14 +41,22 @@ Global
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B870E4D5-6806-4A0B-B233-8907EEDC5AFC}.Release|Any CPU.Build.0 = Release|Any CPU
{39235FAD-BA9D-4B51-82FC-6969967BEAE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39235FAD-BA9D-4B51-82FC-6969967BEAE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39235FAD-BA9D-4B51-82FC-6969967BEAE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39235FAD-BA9D-4B51-82FC-6969967BEAE9}.Release|Any CPU.Build.0 = Release|Any CPU
{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EE6C8F68-ED46-4C1C-ABDD-CFCDF75104F2}.Release|Any CPU.Build.0 = Release|Any CPU
{4DAADA29-C600-4CF3-8AD3-9C97C8D7F632}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4DAADA29-C600-4CF3-8AD3-9C97C8D7F632}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4DAADA29-C600-4CF3-8AD3-9C97C8D7F632}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4DAADA29-C600-4CF3-8AD3-9C97C8D7F632}.Release|Any CPU.Build.0 = Release|Any CPU
{91A14CD2-2940-4500-8193-56D37EDDDBAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91A14CD2-2940-4500-8193-56D37EDDDBAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91A14CD2-2940-4500-8193-56D37EDDDBAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91A14CD2-2940-4500-8193-56D37EDDDBAA}.Release|Any CPU.Build.0 = Release|Any CPU
{A11AEF5A-B246-4FE8-8330-06DB73CC8074}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A11AEF5A-B246-4FE8-8330-06DB73CC8074}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A11AEF5A-B246-4FE8-8330-06DB73CC8074}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A11AEF5A-B246-4FE8-8330-06DB73CC8074}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
+9
View File
@@ -54,6 +54,15 @@ namespace ZwayBot {
return false;
}
internal static Boolean HasInterface(this Object o, Type interf) {
foreach(Type item in o.GetType().GetInterfaces()) {
if(item == interf) {
return true;
}
}
return false;
}
internal static void WriteError(String text) {
Console.ForegroundColor = ConsoleColor.Red;
Console.Error.WriteLine("ERROR: " + text);
-193
View File
@@ -1,193 +0,0 @@
using System;
using System.Collections.Generic;
using System.Net;
using BlubbFish.IoT.Zway;
using BlubbFish.IoT.Zway.Devices;
using BlubbFish.IoT.Zway.Devices.CommandClasses;
using BlubbFish.IoT.Zway.Devices.CommandClasses.CommandClassSubs;
using BlubbFish.IoT.Zway.Events;
using BlubbFish.IoT.Zway.Interfaces;
using BlubbFish.Utils;
using BlubbFish.Utils.IoT.Connector;
using LitJson;
namespace ZwayBot.Moduls {
class Flex4Grid : AModul, IDisposable {
private ADataBackend mqtt;
private String household = "";
private Object requestalivelock = new Object();
public override event ModulEvent Update;
public Flex4Grid(ZwayController zway, InIReader settings) : base(zway, settings) {
if (this.config.ContainsKey("settings")) {
this.mqtt = ADataBackend.GetInstance(this.config["settings"]);
this.ParseIni();
this.mqtt.MessageIncomming += this.Mqtt_MessageIncomming;
}
}
private void ParseIni() {
if (this.config.ContainsKey("zway") && this.config["zway"].ContainsKey("devices")) {
foreach (String device in this.config["zway"]["devices"].Split(',')) {
Int32 deviceid = Int32.Parse(device);
if (this.zw.Devices.ContainsKey(deviceid) && this.zw.Devices[deviceid].Instances.ContainsKey(0)) {
this.zw.Devices[deviceid].Instances[0].Update += this.DeviceUpdate;
}
}
}
if(this.config.ContainsKey("f4g") && this.config["f4g"].ContainsKey("household")) {
this.household = this.config["f4g"]["household"];
}
}
private void DeviceUpdate(Object sender, DeviceUpdateEvent e) {
Instance instance = (Instance)sender;
if(e.Parent.GetType() == typeof(Switchbinary)) {
if (instance.CommandClasses.ContainsKey(ACommandClass.Classes.SwitchBinary)) {
String topic = "/flex4grid/v1/households/" + this.household + "/device/state";
String text = JsonMapper.ToJson(new Dictionary<String, String>() {
{ "status", ((Switchbinary)instance.CommandClasses[ACommandClass.Classes.SwitchBinary]).Level?"active":"idle" },
{ "timestamp", DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffff'Z'") },
{ "type", ((Switchbinary)instance.CommandClasses[ACommandClass.Classes.SwitchBinary]).Name },
{ "id", instance.DeviceId.ToString() }
}).ToString();
this.mqtt.Send(topic, text);
this.Update?.Invoke(this, new Flex4gridEvent(topic, text));
}
} else if(e.Parent.GetType() == typeof(Sensormultilevelsub) || e.Parent.GetType() == typeof(Metersub)) {
if (instance.CommandClasses.ContainsKey(ACommandClass.Classes.SensorMultilevel) &&
((Sensormultilevel)instance.CommandClasses[ACommandClass.Classes.SensorMultilevel]).Sub.ContainsKey(4) &&
instance.CommandClasses.ContainsKey(ACommandClass.Classes.Meter) && ((Meter)instance.CommandClasses[ACommandClass.Classes.Meter]).Sub.ContainsKey(0)) {
String topic = "/flex4grid/v1/households/" + this.household + "/device/consumption";
String text = JsonMapper.ToJson(new Dictionary<String, String>() {
{ "timestamp", DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffff'Z'") },
{ "id", instance.DeviceId.ToString() },
{ "power", Math.Round(((Sensormultilevelsub)((Sensormultilevel)instance.CommandClasses[ACommandClass.Classes.SensorMultilevel]).Sub[4]).Level).ToString("F0") },
{ "energyCumul", ((Metersub)((Meter)instance.CommandClasses[ACommandClass.Classes.Meter]).Sub[0]).Level.ToString() }
}).ToString();
this.mqtt.Send(topic, text);
this.Update?.Invoke(this, new Flex4gridEvent(topic, text));
}
}
}
private void Mqtt_MessageIncomming(Object sender, MqttEventArgs e) {
JsonData message;
String topic = e.Topic;
try {
if (e.Message.StartsWith("{")) {
message = JsonMapper.ToObject(e.Message);
} else {
return;
}
} catch (Exception) {
return;
}
if(topic == "/flex4grid/v1/households/" + this.household + "/device/actuate") {
if(message.Keys.Contains("deviceId") && message.Keys.Contains("command")) {
String device = message["deviceId"].ToString();
if(this.config.ContainsKey("zway") && this.config["zway"].ContainsKey("devices")) {
foreach (String item in this.config["zway"]["devices"].Split(',')) {
if (item == device) {
Int32 deviceid = Int32.Parse(device);
if (this.zw.Devices.ContainsKey(deviceid) && this.zw.Devices[deviceid].Instances.ContainsKey(0) &&
this.zw.Devices[deviceid].Instances[0].CommandClasses.ContainsKey(ACommandClass.Classes.SwitchBinary)) {
((Switchbinary)this.zw.Devices[deviceid].Instances[0].CommandClasses[ACommandClass.Classes.SwitchBinary]).Level = message["command"].ToString() == "ON";
}
}
}
}
}
}
if (topic == "/flex4grid/v1/households/" + this.household + "/devices/state/request") {
if (this.config.ContainsKey("zway") && this.config["zway"].ContainsKey("devices")) {
Dictionary<String, String> response = new Dictionary<String, String>();
foreach (String device in this.config["zway"]["devices"].Split(',')) {
Int32 deviceid = Int32.Parse(device);
if (this.zw.Devices.ContainsKey(deviceid) && this.zw.Devices[deviceid].Instances.ContainsKey(0)) {
if (this.zw.Devices[deviceid].Instances[0].CommandClasses.ContainsKey(ACommandClass.Classes.SwitchBinary)) {
Switchbinary sw = ((Switchbinary)this.zw.Devices[deviceid].Instances[0].CommandClasses[ACommandClass.Classes.SwitchBinary]);
response.Add(sw.DeviceId.ToString(), sw.Level ? "active" : "idle");
}
}
}
if(response.Count != 0) {
response.Add("timestamp", DateTime.Now.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffff'Z'"));
String rtopic = "/flex4grid/v1/households/" + this.household + "/devices/state/response";
String rtext = JsonMapper.ToJson(response).ToString();
}
}
}
}
private void RequestAlive(Object o) {
if (this.config.ContainsKey("f4g") && this.config["f4g"].ContainsKey("raspi")) {
String raspi = this.config["f4g"]["raspi"];
lock (this.requestalivelock) {
String req = "https://wiki.flex4grid.eu/rupdate/rupdate_general.yml.gpg.asc?gw=" + raspi;
HttpWebRequest request = WebRequest.CreateHttp(req);
try {
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
this.Update?.Invoke(this, new Flex4gridEvent(req, response.StatusCode.ToString()));
}
} catch (Exception) { }
}
lock (this.requestalivelock) {
String req = "https://wiki.flex4grid.eu/rupdate/rupdate_general.yml?gw=" + raspi;
HttpWebRequest request = WebRequest.CreateHttp(req);
try {
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
this.Update?.Invoke(this, new Flex4gridEvent(req, response.StatusCode.ToString()));
}
} catch (Exception) { }
}
lock (this.requestalivelock) {
String req = "http://swb.pcs.flex4grid.eu/gateway/" + raspi;
HttpWebRequest request = WebRequest.CreateHttp(req);
try {
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
this.Update?.Invoke(this, new Flex4gridEvent(req, response.StatusCode.ToString()));
}
} catch (Exception) { }
}
}
}
public override void Interconnect(Dictionary<String, AModul> moduls) {
if (this.config.ContainsKey("f4g") && this.config["f4g"].ContainsKey("raspi")) {
foreach (KeyValuePair<String, AModul> item in moduls) {
if (item.Value is CronJob) {
item.Value.SetInterconnection("10,40 * * * *", new Action<Object>(this.RequestAlive), null);
}
}
}
}
protected override void UpdateConfig() { }
#region IDisposable Support
private Boolean disposedValue = false;
protected virtual void Dispose(Boolean disposing) {
if (!this.disposedValue) {
if (disposing) {
this.mqtt.Dispose();
}
this.disposedValue = true;
}
}
~Flex4Grid() {
Dispose(false);
}
public override void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
}
}
+18 -21
View File
@@ -6,18 +6,19 @@ using BlubbFish.IoT.Zway.Events;
using BlubbFish.IoT.Zway.Interfaces;
using BlubbFish.Utils;
using BlubbFish.Utils.IoT.Connector;
using BlubbFish.Utils.IoT.Events;
using LitJson;
namespace ZwayBot.Moduls {
class Mqtt : AModul, IDisposable {
private ADataBackend mqtt;
private ABackend mqtt;
private Dictionary<String, AModul> modules;
public override event ModulEvent Update;
public Mqtt(ZwayController zway, InIReader settings) : base(zway, settings) {
if (this.config.ContainsKey("settings")) {
this.mqtt = ADataBackend.GetInstance(this.config["settings"]);
this.mqtt = ABackend.GetInstance(this.config["settings"], ABackend.BackendType.Data);
this.mqtt.MessageIncomming += this.Mqtt_MessageIncomming;
this.zw.Update += this.ZwayEvent;
}
@@ -28,18 +29,18 @@ namespace ZwayBot.Moduls {
String data = "";
if(e.Parent.HasAbstract(typeof(ACommandClass))) {
ACommandClass sensor = (ACommandClass)e.Parent;
topic = "/zwavebot/devices/" + sensor.MqttTopic();
topic = "zwavebot/devices/" + sensor.MqttTopic();
data = sensor.ToJson();
}
if(topic != "" && data != "") {
this.mqtt.Send(topic, data);
((ADataBackend)this.mqtt).Send(topic, data);
this.Update?.Invoke(this, new MqttEvent(topic, data));
}
}
private void Mqtt_MessageIncomming(Object sender, MqttEventArgs e) {
if (e.Topic.StartsWith("/zwavebot/devices/") && (e.Topic.EndsWith("/set") || e.Topic.EndsWith("/get"))) {
Match m = new Regex("^/zwavebot/devices/(\\d+)/(\\d+)/(\\d+)/[gs]et$|^/zwavebot/devices/(\\d+)/(\\d+)/(\\d+)/(\\d+)/[gs]et$").Match(e.Topic);
private void Mqtt_MessageIncomming(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;
@@ -51,7 +52,7 @@ namespace ZwayBot.Moduls {
if(c == null) {
return;
}
if (e.Topic.EndsWith("/set")) {
if (e.From.ToString().EndsWith("/set")) {
try {
JsonData a = JsonMapper.ToObject(e.Message);
foreach (String item in a.Keys) {
@@ -62,14 +63,14 @@ namespace ZwayBot.Moduls {
}
}
} catch (Exception) { }
} else if(e.Topic.EndsWith("/get")) {
} else if(e.From.ToString().EndsWith("/get")) {
c.PollOnce = true;
this.mqtt.Send("/zwavebot/devices/" + c.MqttTopic(), c.ToJson());
this.Update?.Invoke(this, new MqttEvent(e.Topic, "Dataget"));
((ADataBackend)this.mqtt).Send("zwavebot/devices/" + c.MqttTopic(), c.ToJson());
this.Update?.Invoke(this, new MqttEvent(e.From.ToString(), "Dataget"));
}
}
if (e.Topic.StartsWith("/zwavebot/config/") && (e.Topic.EndsWith("/set") || e.Topic.EndsWith("/get"))) {
Match m = new Regex("^/zwavebot/config/(\\w+)/[gs]et$|").Match(e.Topic);
if (e.From.ToString().StartsWith("zwavebot/config/") && (e.From.ToString().EndsWith("/set") || e.From.ToString().EndsWith("/get"))) {
Match m = new Regex("^zwavebot/config/(\\w+)/[gs]et$|").Match(e.From.ToString());
if (!m.Groups[1].Success) {
return;
}
@@ -82,13 +83,13 @@ namespace ZwayBot.Moduls {
if (modul == null) {
return;
}
if(e.Topic.EndsWith("/get") && modul.HasConfig && modul.ConfigPublic) {
String topic = "/zwavebot/config/" + m.Groups[1].Value;
if(e.From.ToString().EndsWith("/get") && modul.HasConfig && modul.ConfigPublic) {
String topic = "zwavebot/config/" + m.Groups[1].Value;
String data = JsonMapper.ToJson(modul.GetConfig()).ToString();
this.mqtt.Send(topic, data);
((ADataBackend)this.mqtt).Send(topic, data);
this.Update?.Invoke(this, new MqttEvent(topic, data));
}
if (e.Topic.EndsWith("/set") && modul.HasConfig && modul.ConfigPublic) {
if (e.From.ToString().EndsWith("/set") && modul.HasConfig && modul.ConfigPublic) {
try {
JsonData a = JsonMapper.ToObject(e.Message);
Dictionary<String, Dictionary<String, String>> newconf = new Dictionary<String, Dictionary<String, String>>();
@@ -124,10 +125,6 @@ namespace ZwayBot.Moduls {
}
}
~Mqtt() {
Dispose(false);
}
public override void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
+64
View File
@@ -0,0 +1,64 @@
using System;
using BlubbFish.IoT.Zway;
using BlubbFish.IoT.Zway.Events;
using BlubbFish.Utils;
using BlubbFish.Utils.IoT.Connector;
using BlubbFish.Utils.IoT.Events;
using BlubbFish.Utils.IoT.Interfaces;
namespace ZwayBot.Moduls {
class Senml : AModul {
public override event ModulEvent Update;
private ABackend mqtt;
private String SenmlGuid;
public Senml(ZwayController zway, InIReader settings) : base(zway, settings) {
if (this.config.ContainsKey("settings")) {
this.mqtt = ABackend.GetInstance(this.config["settings"], ABackend.BackendType.Data);
this.mqtt.MessageIncomming += this.EventInput;
this.zw.Update += this.EventOutput;
this.SenmlGuid = this.config["settings"]["guid"];
}
}
#region Events
private void EventOutput(Object sender, DeviceUpdateEvent e) {
String topic = "";
String data = "";
if (e.Parent.HasInterface(typeof(ISenml))) {
ISenml sensor = (ISenml)e.Parent;
topic = sensor.SenmlTopic() + this.SenmlGuid+ "/senml";
data = sensor.ToSenml();
}
if (topic != "" && data != null && data != "") {
((ADataBackend)this.mqtt).Send(topic, data);
this.Update?.Invoke(this, new MqttEvent(topic, data));
}
}
private void EventInput(Object sender, BackendEvent e) { }
#endregion
#region Config
protected override void UpdateConfig() { }
#endregion
#region IDisposable Support
private Boolean disposedValue = false;
protected virtual void Dispose(Boolean disposing) {
if (!this.disposedValue) {
if (disposing) {
this.mqtt.Dispose();
}
this.disposedValue = true;
}
}
public override void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
}
}
+18 -15
View File
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using BlubbFish.IoT.Zway;
using BlubbFish.Utils;
@@ -9,21 +8,25 @@ namespace ZwayBot {
class Program {
static void Main(String[] args) => new Program(args);
private ZwayController zw;
private Dictionary<String, AModul> moduls = new Dictionary<String, AModul>();
private readonly ZwayController zw;
private readonly Dictionary<String, AModul> moduls = new Dictionary<String, AModul>();
private Boolean RunningProcess = true;
private readonly ProgramLogger logger = new ProgramLogger();
public Program(String[] args) {
InIReader.SetSearchPath(new List<String>() { "/etc/zwaybot", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\zwaybot" });
Dictionary<String, String> names;
if(File.Exists("names.ini")) {
names = InIReader.GetInstance("names.ini").GetSection("names");
if(InIReader.ConfigExist("names")) {
names = InIReader.GetInstance("names").GetSection("names");
} else {
names = new Dictionary<String, String>();
}
if(!File.Exists("settings.ini")) {
if(!InIReader.ConfigExist("settings")) {
Helper.WriteError("No settings.ini found. Abord!");
return;
}
this.zw = new ZwayController(InIReader.GetInstance("settings.ini").GetSection("zway"), names, false);
this.logger.SetPath(InIReader.GetInstance("settings").GetValue("logging", "path"));
this.zw = new ZwayController(InIReader.GetInstance("settings").GetSection("zway"), names, false);
this.zw.Update += this.ZwayDataUpate;
this.ModulLoader();
this.ModulInterconnect();
@@ -39,15 +42,15 @@ namespace ZwayBot {
}
private void WaitForShutdown() {
while (true) {
Console.CancelKeyPress += new ConsoleCancelEventHandler(this.SetupShutdown);
while (this.RunningProcess) {
System.Threading.Thread.Sleep(100);
if (Console.KeyAvailable) {
ConsoleKeyInfo key = Console.ReadKey(false);
if (key.Key == ConsoleKey.Escape) {
break;
}
}
}
private void SetupShutdown(Object sender, ConsoleCancelEventArgs e) {
e.Cancel = true;
this.RunningProcess = false;
}
private void ModulDispose() {
@@ -74,8 +77,8 @@ namespace ZwayBot {
if(item.Namespace == "ZwayBot.Moduls") {
Type t = item;
String name = t.Name;
if (File.Exists(name.ToLower() + ".ini")) {
this.moduls.Add(name, (AModul)t.GetConstructor(new Type[] { typeof(ZwayController), typeof(InIReader) }).Invoke(new Object[] { this.zw, InIReader.GetInstance(name.ToLower() + ".ini") }));
if (InIReader.ConfigExist(name.ToLower())) {
this.moduls.Add(name, (AModul)t.GetConstructor(new Type[] { typeof(ZwayController), typeof(InIReader) }).Invoke(new Object[] { this.zw, InIReader.GetInstance(name.ToLower()) }));
Console.WriteLine("Load Modul " + name);
} else if(t.HasInterface("IForceLoad")) {
this.moduls.Add(name, (AModul)t.GetConstructor(new Type[] { typeof(ZwayController), typeof(InIReader) }).Invoke(new Object[] { this.zw, null }));
+3 -4
View File
@@ -10,7 +10,7 @@ using System.Runtime.InteropServices;
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("BlubbFish")]
[assembly: AssemblyProduct("Zway-Bot")]
[assembly: AssemblyCopyright("Copyright © 2017 - 22.12.2017")]
[assembly: AssemblyCopyright("Copyright © 2017 - 15.05.2018")]
[assembly: AssemblyTrademark("BlubbFish")]
[assembly: AssemblyCulture("")]
@@ -27,13 +27,12 @@ using System.Runtime.InteropServices;
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// 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.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyVersion("1.4.0")]
[assembly: AssemblyFileVersion("1.4.0")]
[assembly: NeutralResourcesLanguage("de-DE")]
// “Internet Of Things” icon by By Michael Wohlwend, US, from thenounproject.com.
+62 -8
View File
@@ -39,9 +39,6 @@
<ApplicationIcon>Resources\Icon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="LitJson, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\LitJson.0.9.0\lib\LitJson.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
@@ -53,14 +50,15 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<None Include="dpkg\preinst" />
<Compile Include="Events.cs" />
<Compile Include="Interfaces\IForceLoad.cs" />
<Compile Include="Moduls\AModul.cs" />
<Compile Include="Moduls\CronJob.cs" />
<Compile Include="Helper.cs" />
<Compile Include="Moduls\Flex4Grid.cs" />
<Compile Include="Moduls\Mqtt.cs" />
<Compile Include="Moduls\Overtaker.cs" />
<Compile Include="Moduls\Senml.cs" />
<Compile Include="Moduls\StatusPolling.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -71,14 +69,18 @@
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Utils\IoT\Connector\Data\Mosquitto\ConnectorDataMosquitto.csproj">
<Project>{39235fad-ba9d-4b51-82fc-6969967beae9}</Project>
<Name>ConnectorDataMosquitto</Name>
<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\Connector\Data\Mqtt\ConnectorDataMqtt.csproj">
<Project>{ee6c8f68-ed46-4c1c-abdd-cfcdf75104f2}</Project>
<Name>ConnectorDataMqtt</Name>
</ProjectReference>
<ProjectReference Include="..\..\Utils\IoT\Interfaces\Iot-Interfaces.csproj">
<Project>{4daada29-c600-4cf3-8ad3-9c97c8d7f632}</Project>
<Name>Iot-Interfaces</Name>
</ProjectReference>
<ProjectReference Include="..\..\Utils\IoT\Utils-IoT.csproj">
<Project>{b870e4d5-6806-4a0b-b233-8907eedc5afc}</Project>
<Name>Utils-IoT</Name>
@@ -93,9 +95,61 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="control\control.sh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="control\join.sh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="control\loop.sh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="control\restart.sh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="control\settings.cfg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="control\start.sh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="control\stop.sh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="control\stuff.sh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="control\view.sh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="config-example\cronjob.conf.example">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="config-example\names.conf.example">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="config-example\senml.conf.example">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="config-example\settings.conf.example">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="config-example\statuspolling.conf.example">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Include="config-example\mqtt.conf.example">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="config-example\overtaker.conf.example">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="dpkg\control" />
<None Include="dpkg\create-Builds.bat" />
<None Include="dpkg\make-deb.sh" />
<None Include="dpkg\prerm" />
<None Include="dpkg\zwaybot.service" />
<None Include="Resources\Icon.ico" />
<Content Include="Resources\icon.svg" />
</ItemGroup>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,10 @@
[modul]
config=public
[cold]
cron=0 23 * * 0-4
set=7-0-67-2:Level-19;7-0-112-8:Level-2
[hot]
cron=0 16 * * 1-5
set=7-0-67-1:Level-22;7-0-112-8:Level-1
@@ -0,0 +1,6 @@
[modul]
config=private
[settings]
type=mqtt
server=localhost
@@ -0,0 +1,24 @@
[names]
2-0-37=Kühlschrank Schalter
2-0-49-4=Kühlschrank Leistung
2-0-50-0=Kühlschrank Verbrauch [kWh]
2-0-50-2=Kühlschrank Verbrauch [Wh]
2-0-112-1=Kühlschrank Config (Immer AN)
2-0-112-16=Kühlschrank Config (Zurück zu altem Status nach Stromausfall)
2-0-112-34=Kühlschrank Config (Reaktion auf Alarm)
2-0-112-35=Kühlschrank Config (Antwort auf Alarmmeldung)
2-0-112-39=Kühlschrank Config (Alarm Dauer)
2-0-112-40=Kühlschrank Config (Sofortiger Bericht über Stromverbrauch)
2-0-112-42=Kühlschrank Config (Änderung der Leistung zum Generieren eines Reports)
2-0-112-43=Kühlschrank Config (Regelmäßiges Senden eines Reports über die Stromaufnahme)
2-0-112-45=Kühlschrank Config (Automatisches Senden eines Reportes über Stromverbrauch bei Verbrauchsänderung)
2-0-112-47=Kühlschrank Config (Zeitinterval zum Senden eines Reportes ohne Änderung im Verbrauch)
2-0-112-49=Kühlschrank Config (Messen des Eigenstromverbrauches)
2-0-112-50=Kühlschrank Config (unterer Leistungsschwellwert)
2-0-112-51=Kühlschrank Config (oberer Leistungsschwellwert)
2-0-112-52=Kühlschrank Config (Aktion bei Erreichen des definierten Schwellwertes (Parameter 50/51))
2-0-112-60=Kühlschrank Config (Leistungsschwellwert für violettes Blinken)
2-0-112-61=Kühlschrank Config (LED Ring Farbe im Einschaltzustand)
2-0-112-62=Kühlschrank Config (LED Ring Farbe im Ausschaltzustand)
2-0-112-63=Kühlschrank Config (LED Ring Farbe bei Z-Wave Alarmmeldungen)
2-0-112-70=Kühlschrank Config (Überlastabschaltung)
@@ -0,0 +1,12 @@
[hot]
from=7-0-67-1:Level
to=8-0-67-1:Level;9-0-67-1:Level
[cold]
from=7-0-67-2:Level
to=8-0-67-11:Level;9-0-67-11:Level
[mode]
from=7-0-112-8:Level
to=8-0-64:Level;9-0-64:Level
convert=1-1;2-11
@@ -0,0 +1,7 @@
[modul]
config=private
[settings]
type=mqtt
server=localhost
guid=linksmart-zwaybot
@@ -0,0 +1,7 @@
[zway]
server=localhost
user=admin
pass=pass
[logging]
path=/var/log/zwaybot.log
@@ -0,0 +1,3 @@
[temp]
cron=30 * * * *
devices=7-0-49-1,8-0-49-1,9-0-49-1,10-0-49-1,11-0-49-1
+92
View File
@@ -0,0 +1,92 @@
#!/bin/bash
# Read Settings
DIR=`dirname $0`
source $DIR/settings.cfg
cd $control_root
for(( ; ; ))
do
# Test for Running Servers
servers=$(./view.sh | grep $screen_name)
clear
if [[ -z $servers ]];
then
echo "Zway-Bot not Running!"
echo ""
echo "1) Start Zway-Bot"
else
echo "Zway-Bot is Running :)"
echo ""
echo "2) Stop Zway-Bot"
echo "3) Restart Zway-Bot"
echo "4) Attach to Servers Screen-Session"
echo "5) Put Command to Zway-Bot"
fi
echo "q) Quit"
echo ""
read -p "Choice: " choice
case "$choice" in
q) #Quit
exit 0
;;
1) #Start Server
if [[ -z $servers ]];
then
echo "Starting Zway-Bot..."
./start.sh
else
echo "Zway-Bot Allready started!"
fi
;;
2) #Stop Server
if [[ -z $servers ]];
then
echo "Zway-Bot is not Running!"
else
echo "Stopping Zway-Bot..."
./stop.sh
fi
;;
3) #Restart Server
if [[ -z $servers ]];
then
echo "Zway-Bot is not Running!"
else
echo "Restarting Zway-Bot..."
./restart.sh
fi
;;
4) #Attach to Screen
if [[ -z $servers ]];
then
echo "Zway-Bot is not Running!"
else
./join.sh
fi
;;
5) #Put Command to Server
if [[ -z $servers ]];
then
echo "Zway-Bot is not Running!"
else
read -p "Please enter Zway-Bot-Command: " mc_cmd
./stuff.sh "$mc_cmd"
fi
;;
*) #Invalid Selection
echo "Wrong Selection!"
;;
esac
done
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
# Read Settings
DIR=`dirname $0`
source $DIR/settings.cfg
echo Press STRG+A then D to detach from Console
read -p "Press [Enter] to continue..."
screen -R $screen_name
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
# Read Settings
DIR=`dirname $0`
source $DIR/settings.cfg
rm $control_root/stop_server.info
for(( ; ; ))
do
if [ ! -e $control_root/stop_server.info ];
then
cd $mc_root
$mc_cmd
else
echo "Stopped Server!"
break
fi
done
rm $control_root/stop_server.info
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
# Read Settings
DIR=`dirname $0`
source $DIR/settings.cfg
cd $control_root
# Be Shure theere is no Stop-Info
rm $control_root/stop_server.info
echo "Server will be restarted in 5 Seconds..."
./stuff.sh "/say ReStarting Server in 5 seconds!"
sleep 1
echo "4..."
./stuff.sh "/say 4..."
sleep 1
echo "3..."
./stuff.sh "/say 3..."
sleep 1
echo "2..."
./stuff.sh "/say 2..."
sleep 1
echo "1..."
./stuff.sh "/say 1..."
sleep 1
echo "Restarting Server..."
./stuff.sh "/say Restart Now!"
./stuff.sh "stop"
+23
View File
@@ -0,0 +1,23 @@
#!/bin/bash
# Minecraft Control-Scripts Config-File
# (please remember that there are no spaces allowed around the =-Sign
# in the config-lines)
# Minecraft-Dir & JAR
# Directory where minecraft is in
mc_root="/home/pi/Zway-Bot"
# Root of Control-Scripts
control_root="$mc_root/control"
# MC-Server-Jar (will be executed in mc_root)
mc_jar="$mc_root/Zway-Bot.exe"
# MC-Server Start-Command
mc_cmd="mono $mc_jar"
# Screen
screen_name="Zway-Bot"
+14
View File
@@ -0,0 +1,14 @@
#!/bin/bash
# Read Settings
DIR=`dirname $0`
source $DIR/settings.cfg
# Start Loop in Screen
screen -A -m -d -S $screen_name $control_root/loop.sh
# Allow other users to control this screen-Session!
screen -r $screen_name -X multiuser on
screen -r $screen_name -X addacl www-data
screen -r $screen_name -X addacl mc
screen -r $screen_name -X addacl mw
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
# Read Settings
DIR=`dirname $0`
source $DIR/settings.cfg
cd $control_root
# Create Stop-Info!
touch $control_root/stop_server.info
echo "Shuting Down Server..."
./stuff.sh "/exit"
screen -R $screen_name
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
# Read Settings
DIR=`dirname $0`
source $DIR/settings.cfg
# screen -r $screen_name -X stuff "$1\n"
screen -p 0 -S $screen_name -X eval "stuff '$1'\015"
# as_user "screen -p 0 -S minecraft -X eval 'stuff \"$command\"\015'"
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
screen -ls
Binary file not shown.
@@ -0,0 +1,10 @@
[modul]
config=public
[cold]
cron=0 23 * * 0-4
set=7-0-67-2:Level-19;7-0-112-8:Level-2
[hot]
cron=0 16 * * 1-5
set=7-0-67-1:Level-22;7-0-112-8:Level-1
@@ -0,0 +1,6 @@
[modul]
config=private
[settings]
type=mqtt
server=localhost
@@ -0,0 +1,24 @@
[names]
2-0-37=Kühlschrank Schalter
2-0-49-4=Kühlschrank Leistung
2-0-50-0=Kühlschrank Verbrauch [kWh]
2-0-50-2=Kühlschrank Verbrauch [Wh]
2-0-112-1=Kühlschrank Config (Immer AN)
2-0-112-16=Kühlschrank Config (Zurück zu altem Status nach Stromausfall)
2-0-112-34=Kühlschrank Config (Reaktion auf Alarm)
2-0-112-35=Kühlschrank Config (Antwort auf Alarmmeldung)
2-0-112-39=Kühlschrank Config (Alarm Dauer)
2-0-112-40=Kühlschrank Config (Sofortiger Bericht über Stromverbrauch)
2-0-112-42=Kühlschrank Config (Änderung der Leistung zum Generieren eines Reports)
2-0-112-43=Kühlschrank Config (Regelmäßiges Senden eines Reports über die Stromaufnahme)
2-0-112-45=Kühlschrank Config (Automatisches Senden eines Reportes über Stromverbrauch bei Verbrauchsänderung)
2-0-112-47=Kühlschrank Config (Zeitinterval zum Senden eines Reportes ohne Änderung im Verbrauch)
2-0-112-49=Kühlschrank Config (Messen des Eigenstromverbrauches)
2-0-112-50=Kühlschrank Config (unterer Leistungsschwellwert)
2-0-112-51=Kühlschrank Config (oberer Leistungsschwellwert)
2-0-112-52=Kühlschrank Config (Aktion bei Erreichen des definierten Schwellwertes (Parameter 50/51))
2-0-112-60=Kühlschrank Config (Leistungsschwellwert für violettes Blinken)
2-0-112-61=Kühlschrank Config (LED Ring Farbe im Einschaltzustand)
2-0-112-62=Kühlschrank Config (LED Ring Farbe im Ausschaltzustand)
2-0-112-63=Kühlschrank Config (LED Ring Farbe bei Z-Wave Alarmmeldungen)
2-0-112-70=Kühlschrank Config (Überlastabschaltung)
@@ -0,0 +1,12 @@
[hot]
from=7-0-67-1:Level
to=8-0-67-1:Level;9-0-67-1:Level
[cold]
from=7-0-67-2:Level
to=8-0-67-11:Level;9-0-67-11:Level
[mode]
from=7-0-112-8:Level
to=8-0-64:Level;9-0-64:Level
convert=1-1;2-11
@@ -0,0 +1,7 @@
[modul]
config=private
[settings]
type=mqtt
server=localhost
guid=linksmart-zwaybot
@@ -0,0 +1,7 @@
[zway]
server=localhost
user=admin
pass=pass
[logging]
path=/var/log/zwaybot.log
@@ -0,0 +1,3 @@
[temp]
cron=30 * * * *
devices=7-0-49-1,8-0-49-1,9-0-49-1,10-0-49-1,11-0-49-1
+92
View File
@@ -0,0 +1,92 @@
#!/bin/bash
# Read Settings
DIR=`dirname $0`
source $DIR/settings.cfg
cd $control_root
for(( ; ; ))
do
# Test for Running Servers
servers=$(./view.sh | grep $screen_name)
clear
if [[ -z $servers ]];
then
echo "Zway-Bot not Running!"
echo ""
echo "1) Start Zway-Bot"
else
echo "Zway-Bot is Running :)"
echo ""
echo "2) Stop Zway-Bot"
echo "3) Restart Zway-Bot"
echo "4) Attach to Servers Screen-Session"
echo "5) Put Command to Zway-Bot"
fi
echo "q) Quit"
echo ""
read -p "Choice: " choice
case "$choice" in
q) #Quit
exit 0
;;
1) #Start Server
if [[ -z $servers ]];
then
echo "Starting Zway-Bot..."
./start.sh
else
echo "Zway-Bot Allready started!"
fi
;;
2) #Stop Server
if [[ -z $servers ]];
then
echo "Zway-Bot is not Running!"
else
echo "Stopping Zway-Bot..."
./stop.sh
fi
;;
3) #Restart Server
if [[ -z $servers ]];
then
echo "Zway-Bot is not Running!"
else
echo "Restarting Zway-Bot..."
./restart.sh
fi
;;
4) #Attach to Screen
if [[ -z $servers ]];
then
echo "Zway-Bot is not Running!"
else
./join.sh
fi
;;
5) #Put Command to Server
if [[ -z $servers ]];
then
echo "Zway-Bot is not Running!"
else
read -p "Please enter Zway-Bot-Command: " mc_cmd
./stuff.sh "$mc_cmd"
fi
;;
*) #Invalid Selection
echo "Wrong Selection!"
;;
esac
done
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
# Read Settings
DIR=`dirname $0`
source $DIR/settings.cfg
echo Press STRG+A then D to detach from Console
read -p "Press [Enter] to continue..."
screen -R $screen_name
+21
View File
@@ -0,0 +1,21 @@
#!/bin/bash
# Read Settings
DIR=`dirname $0`
source $DIR/settings.cfg
rm $control_root/stop_server.info
for(( ; ; ))
do
if [ ! -e $control_root/stop_server.info ];
then
cd $mc_root
$mc_cmd
else
echo "Stopped Server!"
break
fi
done
rm $control_root/stop_server.info
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
# Read Settings
DIR=`dirname $0`
source $DIR/settings.cfg
cd $control_root
# Be Shure theere is no Stop-Info
rm $control_root/stop_server.info
echo "Server will be restarted in 5 Seconds..."
./stuff.sh "/say ReStarting Server in 5 seconds!"
sleep 1
echo "4..."
./stuff.sh "/say 4..."
sleep 1
echo "3..."
./stuff.sh "/say 3..."
sleep 1
echo "2..."
./stuff.sh "/say 2..."
sleep 1
echo "1..."
./stuff.sh "/say 1..."
sleep 1
echo "Restarting Server..."
./stuff.sh "/say Restart Now!"
./stuff.sh "stop"
+23
View File
@@ -0,0 +1,23 @@
#!/bin/bash
# Minecraft Control-Scripts Config-File
# (please remember that there are no spaces allowed around the =-Sign
# in the config-lines)
# Minecraft-Dir & JAR
# Directory where minecraft is in
mc_root="/home/pi/Zway-Bot"
# Root of Control-Scripts
control_root="$mc_root/control"
# MC-Server-Jar (will be executed in mc_root)
mc_jar="$mc_root/Zway-Bot.exe"
# MC-Server Start-Command
mc_cmd="mono $mc_jar"
# Screen
screen_name="Zway-Bot"
+14
View File
@@ -0,0 +1,14 @@
#!/bin/bash
# Read Settings
DIR=`dirname $0`
source $DIR/settings.cfg
# Start Loop in Screen
screen -A -m -d -S $screen_name $control_root/loop.sh
# Allow other users to control this screen-Session!
screen -r $screen_name -X multiuser on
screen -r $screen_name -X addacl www-data
screen -r $screen_name -X addacl mc
screen -r $screen_name -X addacl mw
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
# Read Settings
DIR=`dirname $0`
source $DIR/settings.cfg
cd $control_root
# Create Stop-Info!
touch $control_root/stop_server.info
echo "Shuting Down Server..."
./stuff.sh "/exit"
screen -R $screen_name
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
# Read Settings
DIR=`dirname $0`
source $DIR/settings.cfg
# screen -r $screen_name -X stuff "$1\n"
screen -p 0 -S $screen_name -X eval "stuff '$1'\015"
# as_user "screen -p 0 -S minecraft -X eval 'stuff \"$command\"\015'"
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
screen -ls
+10
View File
@@ -0,0 +1,10 @@
Package: zwaybot
Version: x.x-x
Section: base
Priority: optional
Architecture: i386
Depends: mono-complete (>= 5.4.1.6)
Maintainer: BlubbFish <dev@blubbfish.net>
Description: Zway-Bot
Zway-Bot manage a Zwave.me installation
so that it has more features
+6
View File
@@ -0,0 +1,6 @@
set /P maj=Enter Major Version:
set /P min=Enter Minor Version:
set /P bui=Enter Build Version:
bash.exe -c "./make-deb.sh %maj% %min% %bui%"
pause
+34
View File
@@ -0,0 +1,34 @@
#!/bin/bash
WORKDIR="/home/blubb"
ROOT="$WORKDIR/deb"
OUTPUT="../bin/Release"
EXEC="$ROOT/usr/local/bin/zwaybot"
CONFIG="$ROOT/etc/zwaybot"
SYSTEMD="$ROOT/etc/systemd/system"
DEBIAN="$ROOT/DEBIAN"
VMAJOR=$1
VMINOR=$2
VBUILD=$3
mkdir -p $EXEC
mkdir -p $CONFIG
mkdir -p $DEBIAN
mkdir -p $SYSTEMD
cp control $DEBIAN
cp preinst $DEBIAN
cp prerm $DEBIAN
sed -i s/Version:\ x\.x-x/"Version: $VMAJOR.$VMINOR-$VBUILD"/ $DEBIAN/control
chmod 755 $DEBIAN -R
cp zwaybot.service $SYSTEMD
chmod 755 $SYSTEMD -R
cp $OUTPUT/*.exe $EXEC/
cp $OUTPUT/*.dll $EXEC/
cp $OUTPUT/config-example/* $CONFIG
cp $OUTPUT/control $EXEC/ -r
dpkg-deb --build $ROOT
mv $WORKDIR/deb.deb ../bin/Builds/"zwaybot_$VMAJOR.$VMINOR-$VBUILD.deb"
rm $WORKDIR/deb -r
+1
View File
@@ -0,0 +1 @@
Name "Example1"
+4
View File
@@ -0,0 +1,4 @@
#!/bin/sh
service zwaybot stop
adduser --system zwaybot
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
service zwaybot stop
+17
View File
@@ -0,0 +1,17 @@
# If you modify this, please also make sure to edit init.sh
[Unit]
Description=Zway-Bot manage a Zwave.me installation so that it has more features
After=network-online.target
[Service]
User=zwaybot
Group=zwaybot
WorkingDirectory=/usr/local/bin/zwaybot
ExecStart=/usr/bin/mono /usr/local/bin/zwaybot/Zway-Bot.exe
KillMode=control-group
Restart=on-failure
[Install]
WantedBy=multi-user.target
Alias=zwaybot.service
-4
View File
@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="LitJson" version="0.9.0" targetFramework="net461" />
</packages>