Esempio n. 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));
        }
Esempio n. 2
0
        public async Task <Thermostat> Update(Guid thermostatId, [FromBody] ThermostatInput thermostat, [FromServices] IThermostatSubsystemManager <ThermostatInput, Thermostat> thermostats)
        {
            var cached = await repo.Get(thermostatId);

            thermostat.Bridge    = cached.Bridge;
            thermostat.Subsystem = cached.Subsystem;
            thermostat.Id        = cached.Id;
            await thermostats.Set(thermostat);

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

            return(await repo.Update(thermostatId, live));
        }
Esempio n. 3
0
        public async Task <Thermostat> SetTemp(Guid thermostatId, [FromBody] ThermostatTempInput tempInput, [FromServices] IThermostatSubsystemManager <ThermostatInput, Thermostat> thermostats)
        {
            var cached = await repo.Get(thermostatId);

            var thermostat = new ThermostatInput();

            thermostat.Bridge    = cached.Bridge;
            thermostat.Subsystem = cached.Subsystem;
            thermostat.Id        = cached.Id;
            thermostat.HeatTemp  = tempInput.HeatTemp;
            thermostat.CoolTemp  = tempInput.CoolTemp;
            thermostat.Fan       = FanSetting.Auto;
            thermostat.Mode      = Mode.Auto;
            await thermostats.Set(thermostat);

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

            return(await repo.Update(thermostatId, live));
        }