Exemple #1
0
 public void LogEvent(int deviceId, string variableName, dynamic variableValue)
 {
     _lightSwitchesPersistenceService.LogUpdateOnLightswitch(new LightSwitchModel
     {
         Id    = deviceId,
         State = variableValue
     });
 }
Exemple #2
0
 /// <summary>
 /// Turns a lightswitch on or off and logs the state change in the
 /// persistence via the <see cref="ILightSwitchesPersistenceService"/>.
 /// </summary>
 /// <param name="id">The id of the device</param>
 /// <param name="state">True for turning on, False otherwise</param>
 public void UpdateDevice(LightSwitchModel lightSwitch)
 {
     try
     {
         Device device = GetDeviceForId(lightSwitch.Id);
         if (device.TypeID != (int)HomegearDeviceTypes.LightSwitch)
         {
             throw new KeyNotFoundException();
         }
         device.Channels[1].Variables["STATE"].BooleanValue = lightSwitch.State;
         _lightSiwtchPersistence.LogUpdateOnLightswitch(lightSwitch);
     }
     catch (KeyNotFoundException e)
     {
         throw e;
     }
 }