private string GetNextProgramChange(RadioThermostat.Api.Models.ProgramModel program) { if (program == null) { return(null); } var data = program.GetNextProgramChange(this.Status.Time.AsDateTime()); if (data != null) { return(string.Format("At {0} the target will be set to {1}º", data.Item1, data.Item2)); } else { return(null); } }
private async Task <string> GetProgramStatus(CancellationToken ct) { _needsProgramStatusUpdate = false; if (this.Status == null) { return(null); } else if (this.Status.Hold) { return("Hold maintains your current target temperature. Your schedule will not run while Hold is enabled."); } try { using (var client = new RadioThermostat.Api.ThermostatClient(this.IPAddress, ApiLogger.Current)) { RadioThermostat.Api.Models.ProgramModel program = null; if (this.Status.Mode == Api.Models.ThermostatModes.Heat) { program = await client.GetProgramHeat(ct); } else if (this.Status.Mode == Api.Models.ThermostatModes.Cool) { program = await client.GetProgramCool(ct); } return(this.GetNextProgramChange(program)); } } catch (Exception ex) { Platform.Current.Logger.LogError(ex, "Failure during GetProgramStatus"); return(null); } }