Skip to content

Commit

Permalink
Addresses #12 some possible issues with setHolds
Browse files Browse the repository at this point in the history
  • Loading branch information
i8beef committed Mar 23, 2021
1 parent 1063a25 commit b7f6a37
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 31 deletions.
46 changes: 28 additions & 18 deletions src/I8Beef.Ecobee.TestClient/Program.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -86,31 +89,38 @@ private static async Task Main()
//Console.WriteLine();
//Console.WriteLine(JsonSerializer<ThermostatResponse>.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<Protocol.Objects.Function>
// // 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<Protocol.Objects.Function>
// {
// 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<ThermostatUpdateRequest, Response>(themroFanRequest);
// Console.WriteLine();
// Console.WriteLine(JsonSerializer<Response>.Serialize(themroFanResponse));
//}

//var themroFanResponse = await client.PostAsync<ThermostatUpdateRequest, Response>(themroFanRequest);
//Console.WriteLine();
//Console.WriteLine(JsonSerializer<Response>.Serialize(themroFanResponse));

Console.ReadLine();
}
Expand Down
26 changes: 13 additions & 13 deletions src/I8Beef.Ecobee/Protocol/Objects/Functions/SetHoldParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,64 +12,64 @@ public class SetHoldParams : FunctionParams
/// <summary>
/// The temperature to set the cool hold at.
/// </summary>
[JsonProperty(PropertyName = "coolHoldTemp", Required = Required.Always)]
public int CoolHoldTemp { get; set; }
[JsonProperty(PropertyName = "coolHoldTemp", NullValueHandling = NullValueHandling.Ignore)]
public int? CoolHoldTemp { get; set; }

/// <summary>
/// The temperature to set the heat hold at.
/// </summary>
[JsonProperty(PropertyName = "heatHoldTemp", Required = Required.Always)]
public int HeatHoldTemp { get; set; }
[JsonProperty(PropertyName = "heatHoldTemp", NullValueHandling = NullValueHandling.Ignore)]
public int? HeatHoldTemp { get; set; }

/// <summary>
/// The fan state.
/// </summary>
[JsonProperty(PropertyName = "fan")]
[JsonProperty(PropertyName = "fan", NullValueHandling = NullValueHandling.Ignore)]
public string Fan { get; set; }

/// <summary>
/// The Climate to use as reference for setting the coolHoldTemp, heatHoldTemp and fan
/// settings for this hold. If this value is passed the coolHoldTemp and heatHoldTemp
/// are not required.
/// </summary>
[JsonProperty(PropertyName = "holdClimateRef")]
[JsonProperty(PropertyName = "holdClimateRef", NullValueHandling = NullValueHandling.Ignore)]
public string HoldClimateRef { get; set; }

/// <summary>
/// The start date in thermostat time.
/// </summary>
[JsonProperty(PropertyName = "startDate")]
[JsonProperty(PropertyName = "startDate", NullValueHandling = NullValueHandling.Ignore)]
public string StartDate { get; set; }

/// <summary>
/// The start time in thermostat time.
/// </summary>
[JsonProperty(PropertyName = "startTime")]
[JsonProperty(PropertyName = "startTime", NullValueHandling = NullValueHandling.Ignore)]
public string StartTime { get; set; }

/// <summary>
/// The end date in thermostat time.
/// </summary>
[JsonProperty(PropertyName = "endDate")]
[JsonProperty(PropertyName = "endDate", NullValueHandling = NullValueHandling.Ignore)]
public string EndDate { get; set; }

/// <summary>
/// The end time in thermostat time.
/// </summary>
[JsonProperty(PropertyName = "endTime")]
[JsonProperty(PropertyName = "endTime", NullValueHandling = NullValueHandling.Ignore)]
public string EndTime { get; set; }

/// <summary>
/// The hold duration type. Valid values: dateTime, nextTransition, indefinite,
/// holdHours.
/// </summary>
[JsonProperty(PropertyName = "holdType")]
[JsonProperty(PropertyName = "holdType", NullValueHandling = NullValueHandling.Ignore)]
public string HoldType { get; set; }

/// <summary>
/// The number of hours to hold for, used and required if holdType='holdHours'.
/// </summary>
[JsonProperty(PropertyName = "holdHours")]
public int HoldHours { get; set; }
[JsonProperty(PropertyName = "holdHours", NullValueHandling = NullValueHandling.Ignore)]
public int? HoldHours { get; set; }
}
}

0 comments on commit b7f6a37

Please sign in to comment.