Exemple #1
0
 private bool SetDimmableLevel(DeviceRequest request)
 {
     VeraNet.Objects.Devices.DimmableLight dimmableDevice = vera.Devices.FirstOrDefault(s => s.Id == request.DeviceID) as VeraNet.Objects.Devices.DimmableLight;
     if (dimmableDevice != null)
     {
         PackageHost.WriteInfo("Set level {0}% to {1} ({2})", request.Level, dimmableDevice.Name, dimmableDevice.Id);
         return(dimmableDevice.SetLevel(request.Level));
     }
     else
     {
         PackageHost.WriteError("The device #'{0}' not found !", request.DeviceID);
         return(false);
     }
 }
Exemple #2
0
 private bool SetSwitchState(DeviceRequest request)
 {
     VeraNet.Objects.Devices.Switch switchDevice = vera.Devices.FirstOrDefault(s => s.Id == request.DeviceID) as VeraNet.Objects.Devices.Switch;
     if (switchDevice != null)
     {
         PackageHost.WriteInfo("Switch '{0}' {1} ({2})", request.State ? "On" : "Off", switchDevice.Name, switchDevice.Id);
         if (request.State)
         {
             return(switchDevice.SwitchOn());
         }
         else
         {
             return(switchDevice.SwitchOff());
         }
     }
     else
     {
         PackageHost.WriteError("The device #'{0}' not found !", request.DeviceID);
         return(false);
     }
 }