Esempio n. 1
0
 public IActionResult CoolKitchen()
 {
     GreeBridge.GetControllerByName("kit").SetDeviceParameters(new List <Param>()
     {
         new Param()
         {
             name  = DeviceParameterKeys.Power,
             value = 1,
         },
         new Param()
         {
             name  = DeviceParameterKeys.FanSpeed,
             value = 3,
         },
         new Param()
         {
             name  = DeviceParameterKeys.AirMode,
             value = 0,
         },
         new Param()
         {
             name  = DeviceParameterKeys.SetTemperature,
             value = 23,
         }
     });
     return(Ok());
 }
Esempio n. 2
0
        public async Task <IActionResult> GetStatus()
        {
            TaskCompletionSource <string> tcs = new TaskCompletionSource <string>();

            GreeBlynkBridge.Gree.Controller.DeviceStatusChangedEventHandler s = (object sender, DeviceStatusChangedEventArgs e) =>
            {
                tcs.TrySetResult(String.Join(String.Empty, e.Parameters.Select(a => $"{a.Key} = {a.Value}")));
            };
            GreeBridge.GetControllerByName("bed").DeviceStatusChanged += s;

            GreeBridge.GetControllerByName("bed").UpdateDeviceStatus();


            var result = await tcs.Task;

            GreeBridge.GetControllerByName("bed").DeviceStatusChanged -= s;

            return(Ok(result));
        }