Пример #1
0
        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);
        }
Пример #2
0
        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);
        }