public static void registerLock(AlexaLock device) { lock (devices) { devices.Add(device.applianceId, device); } }
public static AlexaLock GetLock(string applianceId) { AlexaLock device = DeviceList.GetDevice(applianceId) as AlexaLock; if (device == null) { throw new Exception(String.Format( "Device {0} is not a lock", applianceId )); } return(device); }
private Object HandleGetLockStateRequest(AlexaLock device) { return(new Response() { Header = new Header() { Namespace = "Alexa.ConnectedHome.Query", Name = DirectiveName.GetLockStateResponse, PayloadVersion = "2", MessageID = Guid.NewGuid(), }, Payload = new GetLockStateResponsePayload() { LockState = device.isLocked == 1 ? "LOCKED" : "UNLOCKED" }, }); }
private Object HandleSetLockStateRequest(AlexaLock device, bool shouldLock) { if (shouldLock) { device.Lock(); } return(new Response() { Header = new Header() { Namespace = "Alexa.ConnectedHome.Control", Name = DirectiveName.SetLockStateConfirmation, PayloadVersion = "2", MessageID = Guid.NewGuid(), }, Payload = new SetLockStateResponsePayload() { LockState = "LOCKED" }, }); }