mirror of
https://github.com/excaliburpartners/OmniLinkBridge
synced 2024-12-22 18:52:24 +00:00
1.0.6 - Added thermostat status and auxiliary temp to web service API
This commit is contained in:
parent
828308717a
commit
b4f4e5f795
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||
using System.Data;
|
||||
using System.Data.Odbc;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
|
@ -47,11 +48,12 @@ namespace HAILogger
|
|||
Global.event_source = "HAI Logger";
|
||||
|
||||
if (string.IsNullOrEmpty(Global.dir_config))
|
||||
Global.dir_config = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
|
||||
Global.dir_config = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
||||
|
||||
Settings.LoadSettings();
|
||||
|
||||
Event.WriteInfo("CoreServer", "Starting up server");
|
||||
Event.WriteInfo("CoreServer", "Starting up server " +
|
||||
Assembly.GetExecutingAssembly().GetName().Version.ToString());
|
||||
|
||||
tstat_timer.Elapsed += tstat_timer_Elapsed;
|
||||
tstat_timer.AutoReset = false;
|
||||
|
@ -491,6 +493,10 @@ namespace HAILogger
|
|||
break;
|
||||
case enuObjectType.Zone:
|
||||
HAC.Zones.CopyProperties(MSG);
|
||||
|
||||
if (HAC.Zones[MSG.ObjectNumber].IsTemperatureZone())
|
||||
HAC.Connection.Send(new clsOL2MsgRequestExtendedStatus(HAC.Connection, enuObjectType.Auxillary, MSG.ObjectNumber, MSG.ObjectNumber), HandleRequestAuxillaryStatus);
|
||||
|
||||
break;
|
||||
case enuObjectType.Thermostat:
|
||||
HAC.Thermostats.CopyProperties(MSG);
|
||||
|
@ -753,6 +759,19 @@ namespace HAILogger
|
|||
MSG.ObjectNumber(i), HAC.Areas[MSG.ObjectNumber(i)])));
|
||||
}
|
||||
break;
|
||||
case enuObjectType.Auxillary:
|
||||
for (byte i = 0; i < MSG.AuxStatusCount(); i++)
|
||||
{
|
||||
HAC.Zones[MSG.ObjectNumber(i)].CopyAuxExtendedStatus(MSG, i);
|
||||
LogZoneStatus(MSG.ObjectNumber(i));
|
||||
|
||||
if (HAC.Zones[MSG.ObjectNumber(i)].IsTemperatureZone())
|
||||
{
|
||||
WebNotification.Send("temp", Helper.Serialize<ZoneContract>(Helper.ConvertZone(
|
||||
MSG.ObjectNumber(i), HAC.Zones[MSG.ObjectNumber(i)])));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case enuObjectType.Zone:
|
||||
for (byte i = 0; i < MSG.ZoneStatusCount(); i++)
|
||||
{
|
||||
|
@ -837,6 +856,19 @@ namespace HAILogger
|
|||
}
|
||||
#endregion
|
||||
|
||||
private void HandleRequestAuxillaryStatus(clsOmniLinkMessageQueueItem M, byte[] B, bool Timeout)
|
||||
{
|
||||
if (Timeout)
|
||||
return;
|
||||
|
||||
clsOL2MsgExtendedStatus MSG = new clsOL2MsgExtendedStatus(HAC.Connection, B);
|
||||
|
||||
for (byte i = 0; i < MSG.AuxStatusCount(); i++)
|
||||
{
|
||||
HAC.Zones[MSG.ObjectNumber(i)].CopyAuxExtendedStatus(MSG, i);
|
||||
}
|
||||
}
|
||||
|
||||
#region Thermostats
|
||||
static double ThermostatTimerInterval()
|
||||
{
|
||||
|
@ -1092,8 +1124,13 @@ namespace HAILogger
|
|||
VALUES ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','" + id.ToString() + "','" + unit.Name + "','" + unit.StatusText() + "')");
|
||||
|
||||
if (Global.verbose_zone)
|
||||
{
|
||||
if (unit.IsTemperatureZone())
|
||||
Event.WriteVerbose("ZoneStatus", id + " " + unit.Name + ", Temp: " + unit.TempText());
|
||||
else
|
||||
Event.WriteVerbose("ZoneStatus", id + " " + unit.Name + ", Status: " + unit.StatusText());
|
||||
}
|
||||
}
|
||||
|
||||
private void LogThermostatStatus(ushort id)
|
||||
{
|
||||
|
|
|
@ -119,12 +119,33 @@ namespace HAILogger
|
|||
return names;
|
||||
}
|
||||
|
||||
public List<NameContract> ListZonesTemp()
|
||||
{
|
||||
Event.WriteVerbose("WebService", "ListZonesTemp");
|
||||
|
||||
List<NameContract> names = new List<NameContract>();
|
||||
for (ushort i = 1; i < WebService.HAC.Zones.Count; i++)
|
||||
{
|
||||
clsZone zone = WebService.HAC.Zones[i];
|
||||
|
||||
if (zone.IsTemperatureZone() && zone.DefaultProperties == false)
|
||||
names.Add(new NameContract() { id = i, name = zone.Name });
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
public ZoneContract GetZone(ushort id)
|
||||
{
|
||||
Event.WriteVerbose("WebService", "GetZone: " + id);
|
||||
|
||||
WebOperationContext ctx = WebOperationContext.Current;
|
||||
|
||||
if (WebService.HAC.Zones[id].IsTemperatureZone())
|
||||
{
|
||||
ctx.OutgoingResponse.Headers.Add("type", "temp");
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (WebService.HAC.Zones[id].ZoneType)
|
||||
{
|
||||
case enuZoneType.EntryExit:
|
||||
|
@ -149,6 +170,7 @@ namespace HAILogger
|
|||
ctx.OutgoingResponse.Headers.Add("type", "unknown");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
clsZone unit = WebService.HAC.Zones[id];
|
||||
return Helper.ConvertZone(id, unit);
|
||||
|
@ -251,6 +273,12 @@ namespace HAILogger
|
|||
WebService.HAC.SendCommand(enuUnitCommand.Fan, BitConverter.GetBytes(unit.value)[0], unit.id);
|
||||
}
|
||||
|
||||
public void SetThermostatHold(CommandContract unit)
|
||||
{
|
||||
Event.WriteVerbose("WebService", "SetThermostatHold: " + unit.id + " to " + unit.value);
|
||||
WebService.HAC.SendCommand(enuUnitCommand.Hold, BitConverter.GetBytes(unit.value)[0], unit.id);
|
||||
}
|
||||
|
||||
public List<NameContract> ListButtons()
|
||||
{
|
||||
Event.WriteVerbose("WebService", "ListButtons");
|
||||
|
|
|
@ -21,9 +21,7 @@ namespace HAILogger
|
|||
|
||||
string mode = area.ModeText();
|
||||
|
||||
if (mode.Contains("OFF"))
|
||||
ret.mode = "OFF";
|
||||
else if (mode.Contains("DAY"))
|
||||
if (mode.Contains("DAY"))
|
||||
ret.mode = "DAY";
|
||||
else if (mode.Contains("NIGHT"))
|
||||
ret.mode = "NIGHT";
|
||||
|
@ -31,6 +29,8 @@ namespace HAILogger
|
|||
ret.mode = "AWAY";
|
||||
else if (mode.Contains("VACATION"))
|
||||
ret.mode = "VACATION";
|
||||
else
|
||||
ret.mode = "OFF";
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -40,8 +40,10 @@ namespace HAILogger
|
|||
ZoneContract ret = new ZoneContract();
|
||||
|
||||
ret.id = id;
|
||||
ret.zonetype = zone.ZoneType;
|
||||
ret.name = zone.Name;
|
||||
ret.status = zone.StatusText();
|
||||
ret.temp = zone.TempText();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -83,6 +85,16 @@ namespace HAILogger
|
|||
ret.coolsetpoint = cool;
|
||||
ret.mode = unit.Mode;
|
||||
ret.fanmode = unit.FanMode;
|
||||
ret.hold = unit.HoldStatus;
|
||||
|
||||
string status = unit.HorC_StatusText();
|
||||
|
||||
if (status.Contains("COOLING"))
|
||||
ret.status = "COOLING";
|
||||
else if (status.Contains("HEATING"))
|
||||
ret.status = "HEATING";
|
||||
else
|
||||
ret.status = "OFF";
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,10 @@ namespace HAILogger
|
|||
[WebGet(ResponseFormat = WebMessageFormat.Json)]
|
||||
List<NameContract> ListZonesCO();
|
||||
|
||||
[OperationContract]
|
||||
[WebGet(ResponseFormat = WebMessageFormat.Json)]
|
||||
List<NameContract> ListZonesTemp();
|
||||
|
||||
[OperationContract]
|
||||
[WebGet(ResponseFormat = WebMessageFormat.Json)]
|
||||
ZoneContract GetZone(ushort id);
|
||||
|
@ -83,6 +87,10 @@ namespace HAILogger
|
|||
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
|
||||
void SetThermostatFanMode(CommandContract unit);
|
||||
|
||||
[OperationContract]
|
||||
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
|
||||
void SetThermostatHold(CommandContract unit);
|
||||
|
||||
[OperationContract]
|
||||
[WebGet(ResponseFormat = WebMessageFormat.Json)]
|
||||
List<NameContract> ListButtons();
|
||||
|
|
|
@ -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.5.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.5.0")]
|
||||
[assembly: AssemblyVersion("1.0.6.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.6.0")]
|
||||
|
|
|
@ -29,5 +29,11 @@ namespace HAILogger
|
|||
|
||||
[DataMember]
|
||||
public enuThermostatFanMode fanmode { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public enuThermostatHoldMode hold { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string status { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System.Runtime.Serialization;
|
||||
using HAI_Shared;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace HAILogger
|
||||
{
|
||||
|
@ -8,10 +9,16 @@ namespace HAILogger
|
|||
[DataMember]
|
||||
public ushort id { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public enuZoneType zonetype { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string name { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string status { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string temp { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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_5.zip)
|
||||
You can download the [binary here](http://www.excalibur-partners.com/downloads/HAILogger_1_0_6.zip)
|
||||
|
||||
##Requirements
|
||||
- .NET Framework 4.0
|
||||
|
@ -58,6 +58,9 @@ 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.6 - 2016-11-20
|
||||
- Added thermostat status and auxiliary temp to web service API
|
||||
|
||||
Version 1.0.5 - 2016-11-15
|
||||
- Added web service API for Samsung SmartThings integration
|
||||
|
||||
|
|
Loading…
Reference in a new issue