diff --git a/src/I8Beef.Ecobee.TestClient/Program.cs b/src/I8Beef.Ecobee.TestClient/Program.cs index 1a4e8b6..3d21b9b 100644 --- a/src/I8Beef.Ecobee.TestClient/Program.cs +++ b/src/I8Beef.Ecobee.TestClient/Program.cs @@ -1,6 +1,9 @@ +using I8Beef.Ecobee.Protocol; using I8Beef.Ecobee.Protocol.Thermostat; using System; +using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -86,31 +89,38 @@ private static async Task Main() //Console.WriteLine(); //Console.WriteLine(JsonSerializer.Serialize(thermoResponse)); - // Set thermostat fan - //Console.WriteLine("Setting thermostat fan hold"); - - //var themroFanRequest = new ThermostatUpdateRequest + //var thermostat = thermoResponse.ThermostatList.FirstOrDefault(); + //if (thermostat != null) //{ - // Selection = new Protocol.Objects.Selection - // { - // SelectionType = "registered" - // }, - // Functions = new List + // // Set thermostat fan + // Console.WriteLine("Setting thermostat fan hold"); + + // var themroFanRequest = new ThermostatUpdateRequest // { - // new Protocol.Functions.SetHoldFunction + // Selection = new Protocol.Objects.Selection // { - // Params = new Protocol.Functions.SetHoldParams + // SelectionType = "registered" + // }, + // Functions = new List + // { + // new Protocol.Functions.SetHoldFunction // { - // HoldType = "nextTransition", - // Fan = "on" + // Params = new Protocol.Functions.SetHoldParams + // { + // HoldType = "nextTransition", + // //CoolHoldTemp = thermostat.Runtime.DesiredCool, + // //HeatHoldTemp = thermostat.Runtime.DesiredHeat, + // Fan = "on" + // } // } // } - // } - //}; + // }; + + // var themroFanResponse = await client.PostAsync(themroFanRequest); + // Console.WriteLine(); + // Console.WriteLine(JsonSerializer.Serialize(themroFanResponse)); + //} - //var themroFanResponse = await client.PostAsync(themroFanRequest); - //Console.WriteLine(); - //Console.WriteLine(JsonSerializer.Serialize(themroFanResponse)); Console.ReadLine(); } diff --git a/src/I8Beef.Ecobee/Protocol/Objects/Functions/SetHoldParams.cs b/src/I8Beef.Ecobee/Protocol/Objects/Functions/SetHoldParams.cs index 23b364d..d2af39f 100644 --- a/src/I8Beef.Ecobee/Protocol/Objects/Functions/SetHoldParams.cs +++ b/src/I8Beef.Ecobee/Protocol/Objects/Functions/SetHoldParams.cs @@ -12,19 +12,19 @@ public class SetHoldParams : FunctionParams /// /// The temperature to set the cool hold at. /// - [JsonProperty(PropertyName = "coolHoldTemp", Required = Required.Always)] - public int CoolHoldTemp { get; set; } + [JsonProperty(PropertyName = "coolHoldTemp", NullValueHandling = NullValueHandling.Ignore)] + public int? CoolHoldTemp { get; set; } /// /// The temperature to set the heat hold at. /// - [JsonProperty(PropertyName = "heatHoldTemp", Required = Required.Always)] - public int HeatHoldTemp { get; set; } + [JsonProperty(PropertyName = "heatHoldTemp", NullValueHandling = NullValueHandling.Ignore)] + public int? HeatHoldTemp { get; set; } /// /// The fan state. /// - [JsonProperty(PropertyName = "fan")] + [JsonProperty(PropertyName = "fan", NullValueHandling = NullValueHandling.Ignore)] public string Fan { get; set; } /// @@ -32,44 +32,44 @@ public class SetHoldParams : FunctionParams /// settings for this hold. If this value is passed the coolHoldTemp and heatHoldTemp /// are not required. /// - [JsonProperty(PropertyName = "holdClimateRef")] + [JsonProperty(PropertyName = "holdClimateRef", NullValueHandling = NullValueHandling.Ignore)] public string HoldClimateRef { get; set; } /// /// The start date in thermostat time. /// - [JsonProperty(PropertyName = "startDate")] + [JsonProperty(PropertyName = "startDate", NullValueHandling = NullValueHandling.Ignore)] public string StartDate { get; set; } /// /// The start time in thermostat time. /// - [JsonProperty(PropertyName = "startTime")] + [JsonProperty(PropertyName = "startTime", NullValueHandling = NullValueHandling.Ignore)] public string StartTime { get; set; } /// /// The end date in thermostat time. /// - [JsonProperty(PropertyName = "endDate")] + [JsonProperty(PropertyName = "endDate", NullValueHandling = NullValueHandling.Ignore)] public string EndDate { get; set; } /// /// The end time in thermostat time. /// - [JsonProperty(PropertyName = "endTime")] + [JsonProperty(PropertyName = "endTime", NullValueHandling = NullValueHandling.Ignore)] public string EndTime { get; set; } /// /// The hold duration type. Valid values: dateTime, nextTransition, indefinite, /// holdHours. /// - [JsonProperty(PropertyName = "holdType")] + [JsonProperty(PropertyName = "holdType", NullValueHandling = NullValueHandling.Ignore)] public string HoldType { get; set; } /// /// The number of hours to hold for, used and required if holdType='holdHours'. /// - [JsonProperty(PropertyName = "holdHours")] - public int HoldHours { get; set; } + [JsonProperty(PropertyName = "holdHours", NullValueHandling = NullValueHandling.Ignore)] + public int? HoldHours { get; set; } } }