static void Main(string[] args) { var portName = System.IO.Ports.SerialPort.GetPortNames().Where(element => element != "COM1").First(); var controller = new ZWaveController(portName); //controller.Channel.Log = Console.Out; controller.Open(); try { Run(controller).Wait(); } catch (AggregateException ex) { foreach (var inner in ex.InnerExceptions) { LogMessage($"{inner}"); } } catch (Exception ex) { LogMessage($"{ex}"); } finally { Console.ReadLine(); controller.Close(); } }
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(); }
public static async Task Main(string[] args) { Logging.Factory.Subscribe((message) => WriteConsole(message)); var port = new SerialPort(SerialPort.GetPortNames().Where(element => element != "COM1").First()); var controller = new ZWaveController(port); try { await controller.Open(); WriteInfo($"Controller Version: {controller.Version}"); WriteInfo($"Controller ChipType: {controller.ChipType}"); WriteInfo($"Controller HomeID: {controller.HomeID:X}"); WriteInfo($"Controller NodeID: {controller.NodeID}"); WriteLine(); } catch (Exception ex) { WriteError(ex); } finally { await controller.Close(); } Console.ReadLine(); }
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(); }
public void TestMethod1() { var controller = new ZWaveController("COM3"); controller.Open(); var version = controller.GetVersion().Result; controller.Close(); }
/// <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 void Main(string[] args) { var portName = System.IO.Ports.SerialPort.GetPortNames().Where(element => element != "COM1").First(); var controller = new ZWaveController(portName); // netsh http add urlacl url=http://+:80/ user=Everyone // http://localhost:80/api/v1.0/controller/nodes/19/basic/get/ var server = new ZWave.Net.ZWaveRestServer(controller); server.Log = Console.Out; //controller.Channel.Log = Console.Out; controller.Open(); server.Open(); try { Run(controller).Wait(); } catch (AggregateException ex) { foreach (var inner in ex.InnerExceptions) { LogMessage($"{inner}"); } } catch (Exception ex) { LogMessage($"{ex}"); } finally { Console.ReadLine(); server.Close(); controller.Close(); } }
static async Task Main(string[] args) { Logging.Factory.Subscribe((message) => { if (message.Level >= LogLevel.Info) { WriteLogRecord(message); } }); var controller = new ZWaveController(UsbStick.AeotecZStick); try { await controller.Open(); await Dump(controller); WriteLine(); foreach (var node in controller.Nodes) { await Dump(node); WriteLine(); } } catch (Exception ex) { WriteError(ex); } finally { Console.ReadLine(); await controller.Close(); } }
public void Dispose() { _controller.ChannelClosed -= LogChannelClosed; _controller.Error -= LogError; _controller.Close(); }
public void Dispose() { controller.Close(); }