示例#1
0
        public async Task <Thermostat> ApplySetting(Guid thermostatSettingId, [FromServices] IThermostatSettingRepository settingRepository, [FromServices] IThermostatSubsystemManager <ThermostatInput, Thermostat> thermostats)
        {
            var setting = await settingRepository.Get(thermostatSettingId);

            var cached = await repo.Get(setting.ThermostatId);

            var thermostat = new ThermostatInput();

            thermostat.Bridge    = cached.Bridge;
            thermostat.Subsystem = cached.Subsystem;
            thermostat.Id        = cached.Id;
            if (setting.On)
            {
                thermostat.HeatTemp = setting.HeatTemp;
                thermostat.CoolTemp = setting.CoolTemp;
                thermostat.Fan      = FanSetting.Auto;
                thermostat.Mode     = Mode.Auto;
            }
            else
            {
                thermostat.HeatTemp = 70;
                thermostat.CoolTemp = 75;
                thermostat.Fan      = FanSetting.Auto;
                thermostat.Mode     = Mode.Off;
            }
            await thermostats.Set(thermostat);

            var live = await thermostats.Get(cached.Subsystem, cached.Bridge, cached.Id);

            return(await repo.Update(setting.ThermostatId, live));
        }
 public async Task <ThermostatSetting> Get(Guid thermostatSettingId)
 {
     return(await repo.Get(thermostatSettingId));
 }