static private async Task Run(ZWaveController controller) { LogMessage($"Version: {await controller.GetVersion()}"); LogMessage($"HomeID: {await controller.GetHomeID():X}"); var controllerNodeID = await controller.GetNodeID(); LogMessage($"ControllerID: {controllerNodeID:D3}"); var nodes = await controller.GetNodes(); unknownDevices = new List<byte>(); unknownDevices.AddRange(nodes.Select(el => el.NodeID)); foreach (var node in nodes.Where(el => el.NodeID != controllerNodeID)) { try { await RequestNodeType(node); } catch { LogMessage($"Node: {node} not found, waiting for wake up event"); // subcribe to changes Subscribe(node); } } LogMessage($"Waiting for wake up events from {unknownDevices.Count} unknown nodes"); Console.ReadLine(); }
public void TestMethod1() { var controller = new ZWaveController("COM3"); controller.Open(); var version = controller.GetVersion().Result; controller.Close(); }
static private async Task Run(ZWaveController controller) { LogMessage($"Version: {await controller.GetVersion()}"); LogMessage($"HomeID: {await controller.GetHomeID():X}"); var controllerNodeID = await controller.GetNodeID(); LogMessage($"ControllerID: {controllerNodeID:D3}"); var nodes = await controller.GetNodes(); foreach (var node in nodes) { var protocolInfo = await node.GetProtocolInfo(); LogMessage($"Node: {node}, Generic = {protocolInfo.GenericType}, Basic = {protocolInfo.BasicType}, Listening = {protocolInfo.IsListening} "); var neighbours = await node.GetNeighbours(); LogMessage($"Node: {node}, Neighbours = {string.Join(", ", neighbours.Cast<object>().ToArray())}"); // subcribe to changes Subscribe(node); } //await InitializeWallPlug(nodes[2]); //await InitializeWallPlug(nodes[3]); //await InitializeShockSensor(nodes[4]); //await InitializeGarageDoorSensor(nodes[5]); //await InitializeThermostat(nodes[6]); //await InitializeMultiSensor(nodes[7]); await InitializeDoorSensor(nodes[10]); Console.ReadLine(); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { Task.Run(() => { var controller = new ZWaveController(0x0658, 0x0200); controller.Open(); var version = controller.GetVersion().Result; controller.Close(); }); }
static private async Task Run(ZWaveController controller) { LogMessage($"Version: {await controller.GetVersion()}"); LogMessage($"HomeID: {await controller.GetHomeID():X}"); var controllerNodeID = await controller.GetNodeID(); LogMessage($"ControllerID: {controllerNodeID:D3}"); await controller.DiscoverNodes(); var nodes = await controller.GetNodes(); await Task.Delay(2000); foreach (var node in nodes) { var protocolInfo = await node.GetProtocolInfo(); LogMessage($"Node: {node}, Generic = {protocolInfo.GenericType}, Basic = {protocolInfo.BasicType}, Listening = {protocolInfo.IsListening} "); var neighbours = await node.GetNeighbours(); LogMessage($"Node: {node}, Neighbours = {string.Join(", ", neighbours.Cast<object>().ToArray())}"); // subcribe to changes Subscribe(node); } //var command =nodes[2].GetCommandClass<SwitchBinary>(); var command = nodes[5].GetCommandClass <MultiChannel>(); //await Task.Delay(2000); await Task.Delay(1000); await command.BinarySwitchSet(1, true); await Task.Delay(1000); await command.BinarySwitchSet(2, true); await Task.Delay(1000); await command.BinarySwitchSet(1, false); await Task.Delay(1000); await command.BinarySwitchSet(2, false); await Task.Delay(1000); await command.BinarySwitchSet(2, true); await Task.Delay(1000); await command.BinarySwitchSet(1, false); await Task.Delay(1000); await command.BinarySwitchSet(2, false); //await InitializeWallPlug(nodes[2]); //await InitializeWallPlug(nodes[3]); //await InitializeShockSensor(nodes[4]); //await InitializeGarageDoorSensor(nodes[5]); //await InitializeThermostat(nodes[6]); //await InitializeMultiSensor(nodes[18]); //await InitializeDoorSensor(nodes[10]); //await InitializePowerSwitch(nodes[19]); //await InitializePowerSwitch(nodes[20]); //await InitializePowerSwitch(nodes[24]); //await InitializePowerSwitch(nodes[25]); //await InitializePowerSwitch(nodes[2]); //var neighborUpdateStatus = await nodes[19].RequestNeighborUpdate((status) => LogMessage($"RequestNeighborUpdate: {status} ")); Console.ReadLine(); }