public HeatingThermostatDiff(String Name, Int32 Room_ID, String Room_Name) { _DeviceType = DeviceTypes.HeatingThermostat; _DeviceName = Name; _RoomID = Room_ID; _RoomName = Room_Name; lowBattery = BatteryStatus.unchanged; temperature = Double.NaN; mode = ThermostatModes.unchanged; }
public async Task <IActionResult> SetModeAsync([FromBody] ThermostatModes mode) { try { var status = await _thermostatService.SetModeAsync(mode); return(Ok(status)); } catch (Exception ex) { await _mailService.SendEmailAsync("Error in ThermostatController SetModeAsync", ex.ToString()); return(StatusCode(500, ex.ToString())); } }
public async Task <ThermostatStatus> SetModeAsync(ThermostatModes mode) { _thermostatConfig.Mode = mode; _db.Entry(_thermostatConfig).State = EntityState.Modified; await _db.SaveChangesAsync(); if (mode == ThermostatModes.Off) { await _relayService.PowerOffAsync(); } else { await CheckAsync(); } return(await GetStatusAsync()); }
public async Task SetModeAsync(ThermostatModes mode, bool isInit = false) { Mode = mode; switch (mode) { case ThermostatModes.Off: OffColor = _enabledColor; ManualColor = _disabledColor; CalendarColor = _disabledColor; break; case ThermostatModes.Manual: ManualColor = _enabledColor; OffColor = _disabledColor; CalendarColor = _disabledColor; break; // Not implemented. The button is disabled case ThermostatModes.Calendar: CalendarColor = _enabledColor; ManualColor = _disabledColor; OffColor = _disabledColor; break; } if (!isInit) { // Changing mode checks operation conditions on the server // and returns a ThermostatStatus var thermostatStatus = await _momitKillerApi.ThermostatSetModeAsync(Mode); CurrentTemp = thermostatStatus.Temperature; Setpoint = thermostatStatus.Setpoint; IsRelayOn = thermostatStatus.RelayStatus == RelayStatuses.On; } }
public async Task <ThermostatStatus> ThermostatSetModeAsync(ThermostatModes mode) { var stringContent = new StringContent(((int)mode).ToString(), Encoding.UTF8, "application/json"); using (HttpResponseMessage res = await _httpClient .PutAsync("api/thermostat/mode", stringContent)) using (HttpContent content = res.Content) { var data = await content.ReadAsStringAsync(); if (res.StatusCode != HttpStatusCode.OK) { Debug.WriteLine(data); throw new Exception("An error has ocurred setting thermostat mode", new Exception(data)); } return(Serialize <ThermostatStatus>(data)); } }
private void TestPropertyThermostatMode(Property p, DateTime time, int uncertainty, string customname, ThermostatModes value) { TestFunctionsV3.TestContextProperty(p, PropertyNames.THERMOSTATMODE, Namespaces.ALEXA_THERMOSTATCONTROLLER, time, uncertainty, customname); Assert.Equal(typeof(ThermostatModes), p.Value.GetType()); Assert.Equal(value, p.Value); }
public Task ThermostatModeAsync(int vid, ThermostatModes mode) { return(_control.WriteLineAsync($"THERMOP {vid} {mode.ToString().ToUpper()}")); }
public void ThermostatMode(int vid, ThermostatModes mode) { _control.WriteLine($"THERMOP {vid} {mode.ToString().ToUpper()}"); }