コード例 #1
0
        public CabLog RecordTemperature(CabUser user, int temp)
        {
            var tempLog = new CabLog(user.UserId, LogAction.IncomingTemperature, temp);

            _cabLogRepository.SaveLog(tempLog);

            //Find temperature information of house
            var houseConditions = new NestObject();

            try
            {
                houseConditions = _nestAPI.GetCurrentHouseConditions(user.NestToken, user.ThermostatId);
                _logger.LogInformation("Current Nest House Ambient Temperature is: " + houseConditions.ambient_temperature_f);
            }
            catch (Exception ex)
            {
                throw new Exception("Error Calling Nest API to get current house conditions: " + ex.Message, ex);
            }

            //If Nest is Away, return
            if (houseConditions.hvac_mode == "eco")
            {
                return(tempLog);
            }

            //Check if there has been a NestSet created with this UserID in the past 20 minutes OR NestFan Log created with this UserID in the past 60 minutes.  If yes, just return tempLog

            //If Nest temperature is greater than the incoming temp given && the Nest Temperature is less than the set CeilingTemperature  -----> raise the Nest Temp by 1 degree.

            //If Nest Temperature is greater than the incoming temp given && the Nest Temperature is Equeal to or Greater than the ceilingTemperature && Nest Fan is not active --> Turn on Nest Fan for 1 Hour.

            return(tempLog);
        }
コード例 #2
0
        public CabUser SaveUser(BaseCabUser baseUser)
        {
            var user = new CabUser(baseUser.NestToken, baseUser.STToken, baseUser.ThermostatId, baseUser.RoomTargetTemperature, baseUser.CeilingSetTemperature, baseUser.UserName, baseUser.PhoneNumber);

            _userRepository.SaveUser(user);
            _cabLogRepository.SaveLog(new CabLog(user.UserId, LogAction.UserCreated));
            return(user);
        }