Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
        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()));
            }
        }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
0
        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;
            }
        }
Ejemplo n.º 6
0
        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));
                }
        }
Ejemplo n.º 7
0
 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);
 }
Ejemplo n.º 8
0
 public Task ThermostatModeAsync(int vid, ThermostatModes mode)
 {
     return(_control.WriteLineAsync($"THERMOP {vid} {mode.ToString().ToUpper()}"));
 }
Ejemplo n.º 9
0
 public void ThermostatMode(int vid, ThermostatModes mode)
 {
     _control.WriteLine($"THERMOP {vid} {mode.ToString().ToUpper()}");
 }