Beispiel #1
0
 public Node GetNode(ZWaveNodeIdentity identity)
 {
     return(_nodes.SingleOrDefault(x => x.NodeIdentity.Equals(identity)));
 }
Beispiel #2
0
        public void Run()
        {
            var manager = new ZWaveManagerFactory(new ZWaveSettings(), _nodeList).GetManager();

            Console.ReadKey();
            Console.WriteLine("NODES:");
            Console.WriteLine("------");

            Console.WriteLine("------");
            var homeId = _nodeList.AllNodes[0].HomeId;
            ZWaveNodeIdentity activeNode    = new ZWaveNodeIdentity(homeId, 2);
            ulong             activeValueId = default(ulong);

            while (true)
            {
                Console.WriteLine("Waiting for input (Current node: {0})...", activeNode.NodeId);
                var input = ReadKey();
                if (input.Equals("q"))
                {
                    break;
                }
                if (input.Equals("h"))
                {
                    manager.HealNetwork(homeId, true);
                }
                else if (input.Equals("n"))
                {
                    Console.Write("Enter node number: ");
                    var  numberString = Console.ReadLine();
                    byte value;
                    if (Byte.TryParse(numberString, out value))
                    {
                        activeNode = new ZWaveNodeIdentity(homeId, value);
                    }
                }
                else if (input.Equals("v"))
                {
                    Console.Write("Enter value ID: ");
                    var   numberString = Console.ReadLine();
                    ulong value;
                    if (UInt64.TryParse(numberString, out value))
                    {
                        activeValueId = value;
                    }
                }
                else if (input.Equals("d"))
                {
                    var node = _nodeList.GetNode(activeNode);
                    if (node == null)
                    {
                        continue;
                    }
                    DumpNodeValues(node, manager);
                }
                else if (input.Equals("s"))
                {
                    var node = _nodeList.GetNode(activeNode);
                    if (node == null)
                    {
                        continue;
                    }
                    var switchZwValue = node.Values.FirstOrDefault(x => x.GetId().Equals(activeValueId));
                    if (switchZwValue == null)
                    {
                        Console.WriteLine("Could not locate switch with value ({0})", activeValueId);
                    }
                    else
                    {
                        bool value;
                        manager.GetValueAsBool(switchZwValue, out value);
                        var newValue = !value;
                        manager.SetValue(switchZwValue, newValue);
                    }
                }
            }
        }
 protected bool Equals(ZWaveNodeIdentity other)
 {
     return(HomeId == other.HomeId && NodeId == other.NodeId);
 }