public Thermostat SetTargetAircoTemperature([Service] IClient client, decimal targetAircoTemperature) { if (targetAircoTemperature < 5 || targetAircoTemperature > 50) { throw new ArgumentOutOfRangeException(nameof(targetAircoTemperature), "Value must be in the range [5, 50]"); } Items.Room room = client.GetRoom(_id); room.AircoTemp = (float)targetAircoTemperature; return(Thermostat.Create(room)); }
public Thermostat ChangeMode([Service] IClient client, ThermostatMode mode) { Items.Room room = client.GetRoom(_id); room.ControlMode = mode switch { ThermostatMode.Off => RoomControlMode.Off, ThermostatMode.DayTemperature => RoomControlMode.Day, ThermostatMode.NightTemperature => RoomControlMode.Night, ThermostatMode.AircoTemperature => RoomControlMode.AircoTemp, ThermostatMode.AircoContinuous => RoomControlMode.AircoContinu, ThermostatMode.Curve => RoomControlMode.Auto, _ => throw new InvalidOperationException($"Unknown mode {mode}"), }; return(Thermostat.Create(room).WithMode(mode)); }