From a1b15cd08b8341d8417b4a289fd3d8c6c87a77fe Mon Sep 17 00:00:00 2001
From: Ryan Wagoner <rwagoner@excalibur-partners.com>
Date: Wed, 30 Oct 2019 00:21:42 -0400
Subject: [PATCH] - Fix missing last area, zone, unit, thermostat, and button

---
 OmniLinkBridge/Modules/MQTTModule.cs         | 12 ++++++------
 OmniLinkBridge/WebService/OmniLinkService.cs | 20 ++++++++++----------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/OmniLinkBridge/Modules/MQTTModule.cs b/OmniLinkBridge/Modules/MQTTModule.cs
index cf19395..3500d9e 100644
--- a/OmniLinkBridge/Modules/MQTTModule.cs
+++ b/OmniLinkBridge/Modules/MQTTModule.cs
@@ -306,7 +306,7 @@ namespace OmniLinkBridge.Modules
         {
             log.Debug("Publishing areas");
 
-            for (ushort i = 1; i < OmniLink.Controller.Areas.Count; i++)
+            for (ushort i = 1; i <= OmniLink.Controller.Areas.Count; i++)
             {
                 clsArea area = OmniLink.Controller.Areas[i];
 
@@ -353,7 +353,7 @@ namespace OmniLinkBridge.Modules
         {
             log.Debug("Publishing zones");
 
-            for (ushort i = 1; i < OmniLink.Controller.Zones.Count; i++)
+            for (ushort i = 1; i <= OmniLink.Controller.Zones.Count; i++)
             {
                 clsZone zone = OmniLink.Controller.Zones[i];
 
@@ -386,7 +386,7 @@ namespace OmniLinkBridge.Modules
         {
             log.Debug("Publishing units");
 
-            for (ushort i = 1; i < OmniLink.Controller.Units.Count; i++)
+            for (ushort i = 1; i <= OmniLink.Controller.Units.Count; i++)
             {
                 clsUnit unit = OmniLink.Controller.Units[i];
                 
@@ -412,7 +412,7 @@ namespace OmniLinkBridge.Modules
         {
             log.Debug("Publishing thermostats");
 
-            for (ushort i = 1; i < OmniLink.Controller.Thermostats.Count; i++)
+            for (ushort i = 1; i <= OmniLink.Controller.Thermostats.Count; i++)
             {
                 clsThermostat thermostat = OmniLink.Controller.Thermostats[i];
 
@@ -439,7 +439,7 @@ namespace OmniLinkBridge.Modules
         {
             log.Debug("Publishing buttons");
 
-            for (ushort i = 1; i < OmniLink.Controller.Buttons.Count; i++)
+            for (ushort i = 1; i <= OmniLink.Controller.Buttons.Count; i++)
             {
                 clsButton button = OmniLink.Controller.Buttons[i];
 
@@ -463,7 +463,7 @@ namespace OmniLinkBridge.Modules
 
             // Since the controller doesn't fire zone status change on area status change
             // request update so armed, tripped, and secure statuses are correct
-            for (ushort i = 1; i < OmniLink.Controller.Zones.Count; i++)
+            for (ushort i = 1; i <= OmniLink.Controller.Zones.Count; i++)
             {
                 clsZone zone = OmniLink.Controller.Zones[i];
 
diff --git a/OmniLinkBridge/WebService/OmniLinkService.cs b/OmniLinkBridge/WebService/OmniLinkService.cs
index 015c74c..a007806 100644
--- a/OmniLinkBridge/WebService/OmniLinkService.cs
+++ b/OmniLinkBridge/WebService/OmniLinkService.cs
@@ -25,7 +25,7 @@ namespace OmniLinkBridge.WebAPI
             log.Debug("ListAreas");
 
             List<NameContract> names = new List<NameContract>();
-            for (ushort i = 1; i < WebServiceModule.OmniLink.Controller.Areas.Count; i++)
+            for (ushort i = 1; i <= WebServiceModule.OmniLink.Controller.Areas.Count; i++)
             {
                 clsArea area = WebServiceModule.OmniLink.Controller.Areas[i];
 
@@ -52,7 +52,7 @@ namespace OmniLinkBridge.WebAPI
             log.Debug("ListZonesContact");
 
             List<NameContract> names = new List<NameContract>();
-            for (ushort i = 1; i < WebServiceModule.OmniLink.Controller.Zones.Count; i++)
+            for (ushort i = 1; i <= WebServiceModule.OmniLink.Controller.Zones.Count; i++)
             {
                 clsZone zone = WebServiceModule.OmniLink.Controller.Zones[i];
 
@@ -67,7 +67,7 @@ namespace OmniLinkBridge.WebAPI
             log.Debug("ListZonesMotion");
 
             List<NameContract> names = new List<NameContract>();
-            for (ushort i = 1; i < WebServiceModule.OmniLink.Controller.Zones.Count; i++)
+            for (ushort i = 1; i <= WebServiceModule.OmniLink.Controller.Zones.Count; i++)
             {
                 clsZone zone = WebServiceModule.OmniLink.Controller.Zones[i];
 
@@ -82,7 +82,7 @@ namespace OmniLinkBridge.WebAPI
             log.Debug("ListZonesWater");
 
             List<NameContract> names = new List<NameContract>();
-            for (ushort i = 1; i < WebServiceModule.OmniLink.Controller.Zones.Count; i++)
+            for (ushort i = 1; i <= WebServiceModule.OmniLink.Controller.Zones.Count; i++)
             {
                 clsZone zone = WebServiceModule.OmniLink.Controller.Zones[i];
 
@@ -97,7 +97,7 @@ namespace OmniLinkBridge.WebAPI
             log.Debug("ListZonesSmoke");
 
             List<NameContract> names = new List<NameContract>();
-            for (ushort i = 1; i < WebServiceModule.OmniLink.Controller.Zones.Count; i++)
+            for (ushort i = 1; i <= WebServiceModule.OmniLink.Controller.Zones.Count; i++)
             {
                 clsZone zone = WebServiceModule.OmniLink.Controller.Zones[i];
 
@@ -112,7 +112,7 @@ namespace OmniLinkBridge.WebAPI
             log.Debug("ListZonesCO");
 
             List<NameContract> names = new List<NameContract>();
-            for (ushort i = 1; i < WebServiceModule.OmniLink.Controller.Zones.Count; i++)
+            for (ushort i = 1; i <= WebServiceModule.OmniLink.Controller.Zones.Count; i++)
             {
                 clsZone zone = WebServiceModule.OmniLink.Controller.Zones[i];
 
@@ -127,7 +127,7 @@ namespace OmniLinkBridge.WebAPI
             log.Debug("ListZonesTemp");
 
             List<NameContract> names = new List<NameContract>();
-            for (ushort i = 1; i < WebServiceModule.OmniLink.Controller.Zones.Count; i++)
+            for (ushort i = 1; i <= WebServiceModule.OmniLink.Controller.Zones.Count; i++)
             {
                 clsZone zone = WebServiceModule.OmniLink.Controller.Zones[i];
 
@@ -161,7 +161,7 @@ namespace OmniLinkBridge.WebAPI
             log.Debug("ListUnits");
 
             List<NameContract> names = new List<NameContract>();
-            for (ushort i = 1; i < WebServiceModule.OmniLink.Controller.Units.Count; i++)
+            for (ushort i = 1; i <= WebServiceModule.OmniLink.Controller.Units.Count; i++)
             {
                 clsUnit unit = WebServiceModule.OmniLink.Controller.Units[i];
 
@@ -205,7 +205,7 @@ namespace OmniLinkBridge.WebAPI
             log.Debug("ListThermostats");
 
             List<NameContract> names = new List<NameContract>();
-            for (ushort i = 1; i < WebServiceModule.OmniLink.Controller.Thermostats.Count; i++)
+            for (ushort i = 1; i <= WebServiceModule.OmniLink.Controller.Thermostats.Count; i++)
             {
                 clsThermostat unit = WebServiceModule.OmniLink.Controller.Thermostats[i];
 
@@ -278,7 +278,7 @@ namespace OmniLinkBridge.WebAPI
             log.Debug("ListButtons");
 
             List<NameContract> names = new List<NameContract>();
-            for (ushort i = 1; i < WebServiceModule.OmniLink.Controller.Buttons.Count; i++)
+            for (ushort i = 1; i <= WebServiceModule.OmniLink.Controller.Buttons.Count; i++)
             {
                 clsButton unit = WebServiceModule.OmniLink.Controller.Buttons[i];