/// <inheritdoc /> public async Task <EcobeeThermostat> ForceGetThermostatAsync() { await Validate(); string url = API_URL + "1/thermostat?json={\"selection\":{\"selectionType\":\"registered\",\"selectionMatch\":\"\"," + "\"includeRuntime\":\"true\",\"includeSettings\":\"true\",\"includeEquipmentStatus\":\"true\",\"includeSensors\":\"true\"}}";//includeSettings, includeEquipmentStatus, includeSensors try { using (HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, url)) { message.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", credentials.AccessToken); HttpResponseMessage response = await _client.SendAsync(message); if (response.IsSuccessStatusCode) { string content = await response.Content.ReadAsStringAsync(); JObject obj = JObject.Parse(content); if (obj.TryGetValue("thermostatList", out JToken thermostats)) { foreach (JToken thermostat in thermostats) { //convert to a thermostat, but we'll actually stop after the first one because we're not handling the list right now _lastThermostat = thermostat.ToObject <EcobeeThermostat>(); return(_lastThermostat); } } } } } catch (Exception) { throw; } return(null); }
public async Task OnGetAsync() { Thermostat = await _ecobeeConnector.GetThermostatAsync(); }