public static void Main(string[] args) { try { new ConsoleCommandWatcher().Run(); } finally { ZWaveManagerFactory.Destroy(); } }
public void Should_set_switch_state_on_device() { try { var container = IoC.Initialize(); var network = container.GetInstance <ZWaveNetwork>(); var result = network.SetSwitchState(new ZWaveValueIdentity(25479126, 2, 72057594076282880), SwitchState.Off); result.IsSuccessful.ShouldBeTrue(); } finally { ZWaveManagerFactory.Destroy(); } }
public void Should_dump_switch_information() { try { var container = IoC.Initialize(); var network = container.GetInstance <ZWaveNetwork>(); var switches = network.GetAllSwitches(); Console.WriteLine(JsonConvert.SerializeObject(switches, Formatting.Indented)); } finally { ZWaveManagerFactory.Destroy(); } }
protected void Application_End() { ZWaveManagerFactory.Destroy(); Log.Debug("Application ({0}) ending", ApplicationId); }
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); } } } }