Beispiel #1
0
 public async Task ToggleAsync(DeviceControlDto device)
 {
     if (device.DeviceStatus == DeviceStatus.On)
     {
         await OffAsync(device);
     }
     else
     {
         await OnAsync(device);
     }
 }
Beispiel #2
0
        public async Task ReadAndUpdateStatus(DeviceControlDto device)
        {
            if (device.DeviceType == HubDeviceType.InsteonDevice)
            {
                var status = await _hubClientService.SendStatusRequestAsync(device.Identifier);

                if (status.Ok)
                {
                    device.DeviceStatus = (status.Level == 0) ? DeviceStatus.Off : DeviceStatus.On;
                    device.Level        = status.Level;
                }
            }
        }
Beispiel #3
0
        public async Task <bool> OffAsync(DeviceControlDto device)
        {
            try
            {
                var response = await _hubClientService.SendCommnadRequestAsync(device.Identifier, "20");

                device.DeviceStatus = DeviceStatus.Off;
                if (response.ok)
                {
                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }