public async Task <bool> HandleRequest(Device device, SetDeviceStateRequest request) { try { var nodeId = int.Parse(device.Id.Replace("node-", "")); var nodeDevice = await NodeDatabase.Shared.GetDevice(nodeId); var command = await nodeDevice.GetPerferedCommand(); var s = await nodeApi.SetState(command, request.On); return(s); } catch (Exception ex) { Console.WriteLine(ex); } return(false); }
public async Task <bool> HandleRequest(Device device, DeviceUpdate request) { try { var nodeId = int.Parse(device.ServiceDeviceId); var nodeDevice = await NodeDatabase.Shared.GetDevice(nodeId); if (!ZWaveCommands.RosieCommandsToZwaveDictionary.TryGetValue(request.PropertyKey, out var commandId)) { throw new NotSupportedException($"The following key is not supported in Zwave: {request.PropertyKey}"); } var command = await nodeDevice.GetCommand(request); var s = await nodeApi.SetState(command, command.GetValue(request)); return(s); } catch (Exception ex) { Console.WriteLine(ex); } return(false); }