diff --git a/HAILogger/Helper.cs b/HAILogger/Helper.cs index 4188cf9..849220c 100644 --- a/HAILogger/Helper.cs +++ b/HAILogger/Helper.cs @@ -8,6 +8,8 @@ namespace HAILogger { static class Helper { + private static string lastmode = "OFF"; + public static AreaContract ConvertArea(ushort id, clsArea area) { AreaContract ret = new AreaContract(); @@ -19,18 +21,15 @@ namespace HAILogger ret.fire = area.AreaFireAlarmText; ret.water = area.AreaWaterAlarmText; - string mode = area.ModeText(); - - if (mode.Contains("DAY")) - ret.mode = "DAY"; - else if (mode.Contains("NIGHT")) - ret.mode = "NIGHT"; - else if (mode.Contains("AWAY")) - ret.mode = "AWAY"; - else if (mode.Contains("VACATION")) - ret.mode = "VACATION"; + if (area.ExitTimer > 0) + { + ret.mode = lastmode; + } else - ret.mode = "OFF"; + { + ret.mode = area.ModeText(); + lastmode = ret.mode; + } return ret; } diff --git a/HAILogger/Program.cs b/HAILogger/Program.cs index b9fbd6f..08f1f42 100644 --- a/HAILogger/Program.cs +++ b/HAILogger/Program.cs @@ -10,17 +10,27 @@ namespace HAILogger static void Main(string[] args) { + bool interactive = false; + for (int i = 0; i < args.Length; i++) { switch (args[i]) { + case "/?": + case "-h": + case "-help": + ShowHelp(); + return; case "-c": Global.dir_config = args[++i]; break; + case "-i": + interactive = true; + break; } } - if (Environment.UserInteractive) + if (Environment.UserInteractive || interactive) { Console.TreatControlCAsInput = false; Console.CancelKeyPress += new ConsoleCancelEventHandler(myHandler); @@ -50,5 +60,13 @@ namespace HAILogger server.Shutdown(); args.Cancel = true; } + + static void ShowHelp() + { + Console.WriteLine( + AppDomain.CurrentDomain.FriendlyName + " [-c config_file] [-i]\n" + + "\t-c Specifies the name of the config file. Default is HAILogger.ini.\n" + + "\t-i Run in interactive mode."); + } } } diff --git a/HAILogger/Properties/AssemblyInfo.cs b/HAILogger/Properties/AssemblyInfo.cs index 0493b4c..9be8e2e 100644 --- a/HAILogger/Properties/AssemblyInfo.cs +++ b/HAILogger/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.6.0")] -[assembly: AssemblyFileVersion("1.0.6.0")] +[assembly: AssemblyVersion("1.0.7.0")] +[assembly: AssemblyFileVersion("1.0.7.0")] diff --git a/HAILogger/Settings.cs b/HAILogger/Settings.cs index 1083ac4..2033154 100644 --- a/HAILogger/Settings.cs +++ b/HAILogger/Settings.cs @@ -10,7 +10,7 @@ namespace HAILogger { public static void LoadSettings() { - NameValueCollection settings = LoadCollection(Global.dir_config + "\\HAILogger.ini"); + NameValueCollection settings = LoadCollection(Global.dir_config + Path.DirectorySeparatorChar + "HAILogger.ini"); // HAI Controller Global.hai_address = settings["hai_address"]; diff --git a/README.md b/README.md index 556083f..734f249 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Provides logging and web service API for HAI/Leviton OmniPro II controllers ##Download -You can download the [binary here](http://www.excalibur-partners.com/downloads/HAILogger_1_0_6.zip) +You can download the [binary here](http://www.excalibur-partners.com/downloads/HAILogger_1_0_7.zip) ##Requirements - .NET Framework 4.0 @@ -58,6 +58,10 @@ To test the API you can use your browser to view a page or PowerShell (see below - Invoke-WebRequest -Uri "http://localhost:8000/SetUnit" -Method POST -ContentType "application/json" -Body (convertto-json -InputObject @{"id"=1;"value"=100}) -UseBasicParsing ##Change Log +Version 1.0.7 - 2016-11-25 +- Use previous area state when area is arming for web service API +- Add interactive command line option and use path separator for Mono compatibility + Version 1.0.6 - 2016-11-20 - Added thermostat status and auxiliary temp to web service API