示例#1
0
        private async Task SetTemperature(string commandText)
        {
            Models.Hvac firstHvac = _context.Hvacs?.Include(x => x.Hooks).FirstOrDefault();
            if (firstHvac != null)
            {
                Models.WebHook tempHook = firstHvac.Hooks?.FirstOrDefault(hook => hook.ActivationCommand == Models.Enums.RmsCommand.HvacSetTemperature);
                if (tempHook != null)
                {
                    double dt;
                    var    temperature = commandText
                                         .Replace("set", "")
                                         .Replace("temperature", "")
                                         .Replace("the", "")
                                         .Replace("to", "")
                                         .Replace(" ", "");
                    if (double.TryParse(temperature, out dt))
                    {
                        var restoreHookBody = tempHook.Body.ToString();
                        tempHook.Body = tempHook.Body.Replace("{setTemperature}", temperature);

                        await _rmsService.ActOnWebHook(tempHook);

                        Console.WriteLine($"-------- TEMPERATURE IS SET TO {temperature} --------- i think");
                        //temp workaround for demo - this is dbcontext scope issue
                        tempHook.Body = restoreHookBody;
                    }
                }
            }
        }
示例#2
0
 private async Task LightsOff()
 {
     Models.Light firstLights = _context.Lights?.Include(x => x.Hooks).FirstOrDefault(dev => dev.Type == Models.Enums.DeviceType.LightOnOff);
     if (firstLights != null)
     {
         Models.WebHook ofHook = firstLights.Hooks?.FirstOrDefault(hook => hook.ActivationCommand == Models.Enums.RmsCommand.LightsOff);
         if (ofHook != null)
         {
             await _rmsService.ActOnWebHook(ofHook);
         }
     }
     Console.WriteLine("-------- LIGHTS ARE OFF -------- i think");
 }
示例#3
0
 private async Task LightsOn()
 {
     Models.Light firstLights = _context.RmsList?.Include(x => x.Lights).FirstOrDefault()?.Lights?.FirstOrDefault();//
     if (firstLights != null)
     {
         Models.WebHook onHook = firstLights.Hooks?.FirstOrDefault(hook => hook.ActivationCommand == Models.Enums.RmsCommand.LightsOn);
         if (onHook != null)
         {
             await _rmsService.ActOnWebHook(onHook);
         }
     }
     Console.WriteLine("-------- LIGHTS ARE ON --------- i think");
 }