GetNodes() public method

public GetNodes ( ) : Task
return Task
Beispiel #1
0
        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();
        }
Beispiel #2
0
        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();
        }
Beispiel #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseMvc();

            // Register the Controller event handlers (see methods example below)
            var controller = new ZWaveController("COM5");

            controller.Open();
            var nodesTask = controller.GetNodes();

            nodesTask.Wait();
            var nodes = nodesTask.Result;

            foreach (var node in nodes)
            {
                Subscribe(node);
            }
            while (true)
            {
                Thread.Sleep(1000);
            }
        }
Beispiel #4
0
        public async Task SensorAlarm()
        {
            // the nodeID of the motion sensor
            byte motionSensorID = 5;

            // create the controller
            var controller = new ZWaveController("COM1");

            // open the controller
            controller.Open();

            // get the included nodes
            var nodes = await controller.GetNodes();

            // get the motionSensor
            var motionSensor = nodes[motionSensorID];

            // get the SensorAlarm commandclass
            var sensorAlarm = motionSensor.GetCommandClass<SensorAlarm>();

            // subscribe to alarm event
            sensorAlarm.Changed += (s, e) => Console.WriteLine("Alarm");

            // wait
            Console.ReadLine();

            // close the controller
            controller.Close();
        }
Beispiel #5
0
        public async Task TurnWallPlugOn()
        {
            // the nodeID of the wallplug
            byte wallPlugNodeID = 3;

            // create the controller
            var controller = new ZWaveController("COM1");
            
            // open the controller
            controller.Open();

            // get the included nodes
            var nodes = await controller.GetNodes();
            
            // get the wallplug
            var wallPlug = nodes[wallPlugNodeID];
            
            // get the SwitchBinary commandclass
            var switchBinary = wallPlug.GetCommandClass<SwitchBinary>();

            // turn wallplug on
            await switchBinary.Set(true);

            // close the controller
            controller.Close();
        }
Beispiel #6
0
        public async Task <Node[]> GetNeighbours()
        {
            var nodes = await Controller.GetNodes();

            var results = new List <Node>();

            var response = await Channel.Send(Function.GetRoutingTableLine, NodeID);

            var bits = new BitArray(response);

            for (byte i = 0; i < bits.Length; i++)
            {
                if (bits[i])
                {
                    results.Add(nodes[(byte)(i + 1)]);
                }
            }
            return(results.ToArray());
        }
Beispiel #7
0
        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();
        }