public void HandleNotification(ZWNotification notification) { var notificationType = notification.GetType(); switch (notificationType) { case ZWNotification.Type.ValueAdded: var addedValue = notification.GetValueID(); Log.Debug("Node {0} Value Added: {1} - {2} - {3}", notification.GetNodeId(), _manager.GetValueLabel(addedValue), GetValue(addedValue, _manager), _manager.GetValueUnits(addedValue)); var vaNode = GetNode(notification.GetHomeId(), notification.GetNodeId()); if (vaNode != null) { vaNode.Values.Add(addedValue); } break; case ZWNotification.Type.NodeAdded: var homeId = notification.GetHomeId(); var nodeId = notification.GetNodeId(); if (GetNode(homeId, nodeId) == null) { var node = AddNode(homeId, nodeId); Log.Debug("Node Added: {0}, Home: {1}", node.NodeId, node.HomeId); } break; default: Log.Trace("Unhandled ZWave Notification: {0}", notificationType.ToString()); break; } }
protected AbstractZWaveNotification(ZWNotification notification) { Notification = notification; HomeId = Notification.GetHomeId(); NodeId = Notification.GetNodeId(); }
private static void NotificationHandler(ZWNotification notification, ZWaveManager facade) { if (facade.OnNotification != null) { facade.OnNotification(facade, new NotificationEventArgs(facade, notification)); } }
/// <summary> /// The notifications handler. /// </summary> /// <param name="notification">The notification.</param> public void NotificationHandler(ZWManager manager, NotificationReceivedEventArgs e) { // Handle the notification on a thread that can safely // modify the form controls without throwing an exception. m_notification = e.Notification; Invoke(new MethodInvoker(NotificationHandler)); m_notification = null; }
public NotificationEventArgs(IZWaveManager manager, ZWNotification notification) { Manager = manager; NodeId = notification.GetNodeId(); NotificationType = notification.GetType(); ValueId = notification.GetValueID(); HomeId = notification.GetHomeId(); }
public void NotificationHandler(ZWNotification notification) { // Handle the notification on a thread that can safely // modify the form controls without throwing an exception. m_notification = notification; Invoke(new MethodInvoker(NotificationHandler)); m_notification = null; }
/// <summary> /// The notifications handler. /// </summary> /// <param name="notification">The notification.</param> public void NotificationHandler(ZWNotification notification) { // Handle the notification on a thread that can safely // modify the form controls without throwing an exception. m_notification = notification; Invoke(new MethodInvoker(NotificationHandler)); m_notification = null; }
private void CheckAllNodesQueried(ZWNotification notification) { var type = notification.GetType(); if (type.Equals(ZWNotification.Type.AllNodesQueriedSomeDead) || type.Equals(ZWNotification.Type.AllNodesQueried)) { _allNodesQueried = true; } }
private void OnNotification(ZWNotification notification) { var notification2 = new OpenZWaveNotification(_network, notification); if (_log) { _network.Log("controller notification: " + notification2.Type + ", " + notification2.NodeId); } EnqueueNotification(notification2); }
/// <summary> /// Handles Notifications. /// </summary> /// <param name="notification">The notification.</param> public static void NotificationHandler(ZWNotification notification) { switch (notification.GetType()) { case ZWNotification.Type.ControllerCommand: { MyControllerStateChangedHandler(((ZWControllerState)notification.GetEvent())); break; } } }
private ZwaveDevice GetDevice(ZWNotification notification) { lock (_lock) { var devices = _devices.Cast <ZwaveDevice>().ToDictionary(d => d.NodeId); ZwaveDevice device; if (devices.TryGetValue(notification.NodeId, out device)) { return(device); } device = new ZwaveDevice(notification.NodeId, notification.HomeId); _devices.Add(device); return(device); } }
/// <summary> /// The notifications handler. /// </summary> /// <param name="notification">The notification.</param> public void OnNodeNotification(ZWNotification notification) { // Handle the notification on a thread that can safely // modify the controls without throwing an exception. #if NETFX_CORE var _ = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => #else Dispatcher.BeginInvoke(new Action(() => #endif { NotificationHandler(notification); } #if !NETFX_CORE ) #endif ); }
/// <summary> /// Called by the <see cref="Watcher"/> when events specific to this instance occur /// </summary> /// <param name="notification"></param> internal bool HandleControllerEvent(ZWNotification notification) { var homeID = notification.HomeId; var nodeId = notification.NodeId; var type = notification.Type; switch (type) { case ZWNotificationType.DriverReady: { Debug.WriteLine("DriverReady"); UpdateHomeId(homeID); return(true); } case ZWNotificationType.AllNodesQueried: { Debug.WriteLine("All nodes queried"); ZWManager.Instance.WriteConfig(homeID); UpdateDriverStatus(DriverStatus.AllNodesQueried); return(true); } case ZWNotificationType.AllNodesQueriedSomeDead: { Debug.WriteLine("All nodes queried (some dead)"); ZWManager.Instance.WriteConfig(homeID); UpdateDriverStatus(DriverStatus.AllNodesQueriedSomeDead); return(true); } case ZWNotificationType.AwakeNodesQueried: { Debug.WriteLine("Awake nodes queried"); ZWManager.Instance.WriteConfig(homeID); UpdateDriverStatus(DriverStatus.AwakeNodesQueried); return(true); } default: return(false); } }
public ZWaveAllNodesQueriedSomeDead(ZWNotification notification) : base(notification) { }
public ZWaveNodeNaming(ZWNotification notification) : base(notification) { }
public static void NotificationHandler(ZWNotification notification) { switch (notification.GetType()) { case ZWNotification.Type.ControllerCommand: { MyControllerStateChangedHandler(((ZWControllerState)notification.GetEvent())); break; } } }
/// <summary> /// The notification handler. /// </summary> private void NotificationHandler(ZWNotification notification) { var homeID = notification.HomeId; var nodeId = notification.NodeId; var type = notification.Type; Action <ZWValueID> debugWriteValueID = (v) => { // Debug.WriteLine(" Node : " + nodeId.ToString()); // Debug.WriteLine(" CC : " + v.CommandClassId.ToString()); // Debug.WriteLine(" Type : " + type.ToString()); // Debug.WriteLine(" Index: " + v.Index.ToString()); // Debug.WriteLine(" Inst : " + v.Instance.ToString()); // Debug.WriteLine(" Value: " + GetValue(v).ToString()); // Debug.WriteLine(" Label: " + m_manager.GetValueLabel(v)); // Debug.WriteLine(" Help : " + m_manager.GetValueHelp(v)); // Debug.WriteLine(" Units: " + m_manager.GetValueUnits(v)); }; foreach (var item in PendingRequests.ToArray()) { if (item.HomeID == homeID && (item.NodeID == nodeId || item.NodeID < 0) && item.Type == type) { item.TCS.SetResult(notification); PendingRequests.Remove(item); } else if (item.Age > item.Timeout) { item.TCS.SetException(new TimeoutException()); PendingRequests.Remove(item); } } // NodeQueriesComplete : When all nodes has reported back // NodeAdded : Node now exists in the system. Very little useful info // NodeProtocolInfo: We now know what type of node it is // Debug.WriteLine($"Notification Received: {homeID}:{nodeId} = {type}"); switch (notification.Type) { case NotificationType.ValueAdded: { Node node = GetNode(homeID, nodeId); if (node != null) { var value = notification.ValueID; node.AddValue(value); debugWriteValueID(value); } break; } case NotificationType.ValueRemoved: { Node node = GetNode(homeID, nodeId); if (node != null) { node.RemoveValue(notification.ValueID); } break; } case NotificationType.ValueChanged: { ZWValueID value = notification.ValueID; Debug.WriteLine($"Value Changed. Node {nodeId}: {ZWManager.Instance.GetValueLabel(value)} = {GetValue(value)} {ZWManager.Instance.GetValueUnits(value)}"); debugWriteValueID(value); Node node = GetNode(homeID, nodeId); if (node != null) { node.AddValue(value); } break; } case NotificationType.Group: { break; } case NotificationType.NodeAdded: { // if this node was in zwcfg*.xml, this is the first node notification // if not, the NodeNew notification should already have been received if (GetNode(homeID, nodeId) == null) { m_nodeList.Add(new Node(nodeId, homeID)); } break; } case NotificationType.NodeNew: { // Add the new node to our list (and flag as uninitialized) m_nodeList.Add(new Node(nodeId, homeID)); break; } case NotificationType.NodeRemoved: { foreach (Node node in m_nodeList) { if (node.ID == nodeId) { m_nodeList.Remove(node); break; } } break; } case NotificationType.NodeProtocolInfo: { Node node = GetNode(homeID, nodeId); if (node != null) { node.Label = ZWManager.Instance.GetNodeType(homeID, node.ID); node.IsLoading = false; } break; } case NotificationType.NodeNaming: { Node node = GetNode(homeID, nodeId); if (node != null) { node.Manufacturer = ZWManager.Instance.GetNodeManufacturerName(homeID, node.ID); node.Product = ZWManager.Instance.GetNodeProductName(homeID, node.ID); node.Location = ZWManager.Instance.GetNodeLocation(homeID, node.ID); node.Name = ZWManager.Instance.GetNodeName(homeID, node.ID); } break; } case NotificationType.NodeEvent: { break; } case NotificationType.PollingDisabled: { Debug.WriteLine("Polling disabled notification"); break; } case NotificationType.PollingEnabled: { Debug.WriteLine("Polling enabled notification"); break; } case NotificationType.DriverReady: { CurrentStatus = $"Initializing...driver with Home ID 0x{notification.HomeId.ToString("X8")} is ready."; break; } case NotificationType.DriverFailed: { Debug.WriteLine("Driver failed for HomeID " + homeID.ToString()); break; } case NotificationType.DriverRemoved: { var nodes = GetNodes(homeID).ToArray(); foreach (var node in nodes) { m_nodeList.Remove(node); } break; } case NotificationType.NodeQueriesComplete: { // as an example, enable query of BASIC info (CommandClass = 0x20) Node node = GetNode(homeID, nodeId); //if (node != null) //{ // foreach (ZWValueID vid in node.Values) // { // if (vid.GetCommandClassId() == 0x84) // remove this "if" to poll all values // m_manager.EnablePoll(vid); // } //} CurrentStatus = $"Initializing...node {node.ID} query complete."; break; } case NotificationType.EssentialNodeQueriesComplete: { Node node = GetNode(homeID, nodeId); CurrentStatus = $"Initializing...node {node.ID} essential queries complete."; break; } case NotificationType.AllNodesQueried: { CurrentStatus = "Ready: All nodes queried."; ZWManager.Instance.WriteConfig(homeID); break; } case NotificationType.AllNodesQueriedSomeDead: { CurrentStatus = "Ready: All nodes queried but some are dead."; ZWManager.Instance.WriteConfig(homeID); break; } case NotificationType.AwakeNodesQueried: { CurrentStatus = "Ready: Awake nodes queried (but not some sleeping nodes)."; ZWManager.Instance.WriteConfig(homeID); break; } default: { Debug.WriteLine($"******Notification '{type}' not Handled @ ID: {nodeId}"); break; } } //NodeGridView.Refresh(); //NodeGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None; //NodeGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells; }
public ZWaveControllerCommand(ZWNotification notification) : base(notification) { }
public OpenZWaveNotification(OpenZWaveNetwork network, ZWNotification notification) { _network = network; _notification = notification; }
public ZWaveSceneEvent(ZWNotification notification) : base(notification) { }
/// <summary> /// Method which handles the events raised by the ZWave network /// </summary> /// <param name="m_notification"></param> static private void NotificationHandler(ZWNotification m_notification) { if (m_notification == null) { return; } switch (m_notification.GetType()) { case ZWNotification.Type.ValueAdded: { Node node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId()); if (node != null) { node.AddValue(m_notification.GetValueID()); } break; } case ZWNotification.Type.ValueRemoved: { Node node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId()); if (node != null) { node.RemoveValue(m_notification.GetValueID()); } break; } case ZWNotification.Type.ValueChanged: { Node node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId()); if (node != null) { node.SetValue(m_notification.GetValueID()); } break; } case ZWNotification.Type.NodeAdded: { Node node = new Node(); node.ID = m_notification.GetNodeId(); node.HomeID = m_notification.GetHomeId(); m_nodeList.Add(node); break; } case ZWNotification.Type.NodeRemoved: { foreach (Node node in m_nodeList) { if (node.ID == m_notification.GetNodeId()) { m_nodeList.Remove(node); break; } } break; } case ZWNotification.Type.NodeProtocolInfo: { Node node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId()); if (node != null) { node.Label = m_manager.GetNodeType(m_homeId, node.ID); } break; } case ZWNotification.Type.NodeNaming: { Node node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId()); if (node != null) { node.Manufacturer = m_manager.GetNodeManufacturerName(m_homeId, node.ID); node.Product = m_manager.GetNodeProductName(m_homeId, node.ID); node.Location = m_manager.GetNodeLocation(m_homeId, node.ID); node.Name = m_manager.GetNodeName(m_homeId, node.ID); } break; } case ZWNotification.Type.DriverReady: { m_homeId = m_notification.GetHomeId(); break; } case ZWNotification.Type.AllNodesQueried: { m_nodesReady = true; break; } default: break; } }
public ZWaveDeleteButton(ZWNotification notification) : base(notification) { }
public ZWaveAwakeNodesQueried(ZWNotification notification) : base(notification) { }
public ZWaveDriverReset(ZWNotification notification) : base(notification) { }
/// <summary> /// Called by the <see cref="Watcher"/> when events specific to this instance occur /// </summary> /// <param name="notification"></param> internal void HandleNodeEvent(ZWNotification notification) { switch (notification.Type) { // NodeProtocolInfo: We now know what type of node it is case ZWNotificationType.NodeProtocolInfo: { // Basic node information has been received, such as whether the node is a listening // device, a routing device and its baud rate and basic, generic and specific types. // It is after this notification that you can call get the Label containing the device description. OnPropertyChanged(nameof(Label)); // DB에 쓰기 Debug.WriteLine("NodeId =[" + ID + "]"); Debug.WriteLine("HomeId =[" + HomeID + "]"); Debug.WriteLine("Label =[" + Label + "]"); Debug.WriteLine("Name =[" + Name + "]"); Debug.WriteLine("Manufacturer =[" + Manufacturer + "]"); Debug.WriteLine("Product =[" + Product + "]"); Debug.WriteLine("Location =[" + Location + "]"); //// 1. 모델객체 세팅 //CommaxIot.Model.ZWave.ZWaveNode zWaveNode = new //// 2. DB 쿼리 using (var db = new IOTOI.Model.Db.Context()) { try { IOTOI.Model.ZWave.ZWaveNode nodeModel = null; nodeModel = db.ZWaveNode.Find(Convert.ToInt32(ID)); if (nodeModel == null) { nodeModel = new IOTOI.Model.ZWave.ZWaveNode(); nodeModel.Id = Convert.ToInt32(ID); nodeModel.HomeId = HomeID; nodeModel.Label = Label; nodeModel.Name = Name; nodeModel.Manufacturer = Manufacturer; nodeModel.Product = Product; nodeModel.Location = Location; db.ZWaveNode.Add(nodeModel); } else { db.ZWaveNode.Update(nodeModel); } db.SaveChanges(); } catch (Exception e) { Debug.WriteLine(e); } } //// 3. upsert gogo Debug.WriteLine($"ZWNotificationType.NodeProtocolInfo OnPropertyChanged :: {nameof(Label)}"); break; } case ZWNotificationType.NodeNaming: { // One of the node names has changed (name, manufacturer, product) OnPropertyChanged(nameof(Name)); OnPropertyChanged(nameof(Manufacturer)); OnPropertyChanged(nameof(Product)); OnPropertyChanged(nameof(ManufacturerAndProduct)); OnPropertyChanged(nameof(Location)); break; } case ZWNotificationType.EssentialNodeQueriesComplete: { // The queries on a node that are essential to its operation have been completed. // The node can now handle incoming messages. EssentialNodeQueriesComplete = true; OnPropertyChanged(nameof(EssentialNodeQueriesComplete)); Debug.WriteLine($"ZWNotificationType.EssentialNodeQueriesComplete OnPropertyChanged :: {nameof(EssentialNodeQueriesComplete)}"); break; } case ZWNotificationType.NodeQueriesComplete: { // All the initialization queries on a node have been completed. NodeQueriesComplete = true; OnPropertyChanged(nameof(NodeQueriesComplete)); Debug.WriteLine($"ZWNotificationType.NodeQueriesComplete OnPropertyChanged :: {nameof(NodeQueriesComplete)}"); break; } case ZWNotificationType.ValueAdded: case ZWNotificationType.ValueChanged: { // Added: A new node value has been added to OpenZWave's list. These notifications occur // after a node has been discovered, and details of its command classes have been // received. Each command class may generate one or more values depending on the // complexity of the item being represented. // Changed: A node value has been updated from the Z-Wave network and it is different from // the previous value. var value = notification.ValueId; //Debug.WriteLine($"ZWNotificationType.ValueChanged notification.ValueId :: AddValue {value}"); AddValue(value); Debug.WriteLine($"{notification.Type}. Node {ID}: {ZWManager.Instance.GetValueLabel(value)} = {GetValue(value)} {ZWManager.Instance.GetValueUnits(value)}"); break; } case ZWNotificationType.ValueRemoved: { // A node value has been removed from OpenZWave's list. This only occurs when a // node is removed. // Note to self: We probably don't need to handle this, since the node would have been // removed at this point RemoveValue(notification.ValueId); Debug.WriteLine($"ZWNotificationType.ValueRemoved RemoveValue :: {notification.ValueId}"); break; } case ZWNotificationType.Group: { // The associations for the node have changed.The application should rebuild any // group information it holds about the node. break; } case ZWNotificationType.Notification: //An error has occurred that we need to report. { Debug.WriteLine($"******Node error '{notification.Code}' @ ID: {ID}"); var code = notification.Code; var v = GetValue(notification.ValueId); Debug.WriteLine($"code '{notification.Code}' @ ID: {notification.ValueId}' value = {v}"); break; } case ZWNotificationType.NodeEvent: // A node has triggered an event. This is commonly caused when a node sends a Basic_Set command to the controller. The event value is stored in the notification. { var value = GetValue(notification.ValueId); Debug.WriteLine($"******Node Event @ ID: Value = {value}"); break; } default: { Debug.WriteLine($"******Notification '{notification.Type}' not Handled @ ID: {ID}"); break; } } }
/// <summary> /// Method which handles the events raised by the ZWave network /// </summary> /// <param name="m_notification"></param> private void NotificationHandler(ZWNotification m_notification) { if (m_notification == null) { return; } switch (m_notification.GetType()) { case ZWNotification.Type.ValueAdded: { ZWaveNode node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId()); if (node != null) { node.AddValue(m_notification.GetValueID()); Log("Event", "Node ValueAdded, " + m_manager.GetValueLabel(m_notification.GetValueID())); } break; } case ZWNotification.Type.ValueRemoved: { ZWaveNode node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId()); if (node != null) { node.RemoveValue(m_notification.GetValueID()); Log("Event", "Node ValueRemoved, " + m_manager.GetValueLabel(m_notification.GetValueID())); } break; } case ZWNotification.Type.ValueChanged: { ZWaveNode node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId()); if (node != null) { node.SetValue(m_notification.GetValueID()); Log("Event", "Node ValueChanged, " + m_manager.GetValueLabel(m_notification.GetValueID()).ToString()); } break; } case ZWNotification.Type.Group: { break; } case ZWNotification.Type.NodeAdded: { // Add the new node to our list ZWaveNode node = new ZWaveNode(); node.ID = m_notification.GetNodeId(); node.HomeID = m_notification.GetHomeId(); m_nodeList.Add(node); Log("Event", "Node added, " + m_notification.GetNodeId().ToString()); break; } case ZWNotification.Type.NodeRemoved: { foreach (ZWaveNode node in m_nodeList) { if (node.ID == m_notification.GetNodeId()) { Log("Event", "Node removed, " + m_notification.GetNodeId().ToString()); m_nodeList.Remove(node); break; } } break; } case ZWNotification.Type.NodeProtocolInfo: { ZWaveNode node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId()); if (node != null) { node.Label = m_manager.GetNodeType(m_homeId, node.ID); Log("Event", "Node protocol info, " + node.Label.ToString()); } break; } case ZWNotification.Type.NodeNaming: { ZWaveNode node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId()); if (node != null) { node.Manufacturer = m_manager.GetNodeManufacturerName(m_homeId, node.ID); node.Product = m_manager.GetNodeProductName(m_homeId, node.ID); node.Location = m_manager.GetNodeLocation(m_homeId, node.ID); node.Name = m_manager.GetNodeName(m_homeId, node.ID); } break; } case ZWNotification.Type.NodeEvent: { Log("Event", "Node event"); break; } case ZWNotification.Type.PollingDisabled: { Log("Event", "Polling disabled notification"); break; } case ZWNotification.Type.PollingEnabled: { Log("Event", "Polling disabled notification"); break; } case ZWNotification.Type.DriverReady: { m_homeId = m_notification.GetHomeId(); Log("Event", "Driver ready, with homeId " + m_homeId.ToString()); break; } case ZWNotification.Type.NodeQueriesComplete: { break; } case ZWNotification.Type.AllNodesQueried: { Log("Event", "All nodes queried"); m_nodesReady = true; break; } case ZWNotification.Type.AwakeNodesQueried: { Log("Event", "Awake nodes queried (but some sleeping nodes have not been queried)"); break; } } }
public ZWaveDriverFailed(ZWNotification notification) : base(notification) { }
public ZWavePollingEnabled(ZWNotification notification) : base(notification) { }
private void OnZwaveNotification(ZWNotification notification) { try { if (notification.Code != NotificationCode.MsgComplete) { return; } switch (notification.Type) { case NotificationType.ValueAdded: case NotificationType.ValueChanged: case NotificationType.ValueRefreshed: { var device = GetDevice(notification); HandleNodeValueNotification(device, notification.ValueID); break; } case NotificationType.NodeNew: case NotificationType.NodeAdded: GetDevice(notification); break; case NotificationType.NodeProtocolInfo: { var device = GetDevice(notification); var label = _manager.GetNodeType(notification.HomeId, notification.NodeId); if (!string.IsNullOrEmpty(label) && string.IsNullOrEmpty(device.Name)) { device.Name = label; } break; } case NotificationType.NodeNaming: { var device = GetDevice(notification); var manufacturer = _manager.GetNodeManufacturerName(notification.HomeId, notification.NodeId); var product = _manager.GetNodeProductName(notification.HomeId, notification.NodeId); var name = _manager.GetNodeName(notification.HomeId, notification.NodeId); if (!string.IsNullOrEmpty(name)) { device.Name = name; } else if (!string.IsNullOrEmpty(manufacturer) && !string.IsNullOrEmpty(product)) { device.Name = $"{manufacturer} {product}"; } break; } case NotificationType.Group: case NotificationType.NodeRemoved: case NotificationType.ValueRemoved: case NotificationType.NodeEvent: case NotificationType.PollingDisabled: case NotificationType.PollingEnabled: case NotificationType.SceneEvent: case NotificationType.CreateButton: case NotificationType.DeleteButton: case NotificationType.ButtonOn: case NotificationType.ButtonOff: case NotificationType.DriverReady: case NotificationType.DriverFailed: case NotificationType.DriverReset: case NotificationType.EssentialNodeQueriesComplete: case NotificationType.NodeQueriesComplete: case NotificationType.AwakeNodesQueried: case NotificationType.AllNodesQueriedSomeDead: case NotificationType.AllNodesQueried: case NotificationType.Notification: case NotificationType.DriverRemoved: case NotificationType.ControllerCommand: case NotificationType.NodeReset: case NotificationType.UserAlerts: case NotificationType.ManufacturerSpecificDBReady: break; default: throw new ArgumentOutOfRangeException(); } } catch (Exception e) { _log.Error(e.Message, e); } }
public static void NotificationHandler(ZWNotification notification) { // Console.WriteLine("Notification! " + notification.GetType() + ": NodeID:" + notification.GetNodeId() + ", HomeId:" + notification.GetHomeId()); var node = FindNode(notification.GetHomeId(), notification.GetNodeId()); switch (notification.GetType()) { case ZWNotification.Type.AllNodesQueried: { Console.WriteLine("***** AllNodesQueried"); _manager.WriteConfig(notification.GetHomeId()); _mre.Set(); break; } case ZWNotification.Type.AllNodesQueriedSomeDead: { Console.WriteLine("Ready: All nodes queried but some are dead."); _manager.WriteConfig(notification.GetHomeId()); break; } case ZWNotification.Type.AwakeNodesQueried: { Console.WriteLine("Ready: Awake nodes queried (but not some sleeping nodes)."); _manager.WriteConfig(notification.GetHomeId()); _mre.Set(); break; } case (ZWNotification.Type.NodeAdded): { node.Id = notification.GetNodeId(); node.HomeId = notification.GetHomeId(); //FillInfo(node); break; } case (ZWNotification.Type.NodeNaming): { Console.WriteLine("Node naming event!"); node.ManufacturerName = _manager.GetNodeManufacturerName(node.HomeId, node.Id); node.Product = _manager.GetNodeProductName(node.HomeId, node.Id); node.Location = _manager.GetNodeLocation(node.HomeId, node.Id); node.Name = _manager.GetNodeName(node.HomeId, node.Id); Console.WriteLine("Product: " + node.Product + ", Location:" + node.Location + ", Name:" + node.Name); break; } case ZWNotification.Type.NodeProtocolInfo: { node.Label = _manager.GetNodeType(node.HomeId, node.Id); Console.WriteLine("***********************"); Console.WriteLine("NodeProtocolInfo: label is " + node.Label); Console.WriteLine("***********************"); break; } case ZWNotification.Type.PollingDisabled: { Console.WriteLine("Polling disabled notification"); break; } case ZWNotification.Type.PollingEnabled: { Console.WriteLine("Polling enabled notification"); break; } case ZWNotification.Type.DriverReady: { _homeId = notification.GetHomeId(); // Console.WriteLine("Home Id is :" + _homeId); break; } case ZWNotification.Type.NodeQueriesComplete: { Console.WriteLine(node.Label + ": node queries complete"); break; } case ZWNotification.Type.EssentialNodeQueriesComplete: { Console.WriteLine(node.Label + ": essential node queries complete"); break; } case ZWNotification.Type.ValueAdded: { node.ValueIds.Add(notification.GetValueID()); break; } case ZWNotification.Type.ValueChanged: { Console.WriteLine(""); string s; bool b; Console.WriteLine(node.Name + ": " + node.Location); Console.WriteLine("Notification type is " + notification.GetType()); var valueId = notification.GetValueID(); var valueType = notification.GetValueID().GetType(); _manager.GetValueAsString(valueId, out s); _manager.GetValueAsBool(valueId, out b); byte bt; _manager.GetValueAsByte(valueId, out bt); Console.WriteLine("Value Type: " + valueType); Console.WriteLine(System.DateTime.Now + "** VALUE CHANGED ** <<" + node.Label + ">> <<" + notification.GetValueID().GetId().ToString() + ">> string:" + s + ",bool:" + b + ",byte=" + bt); Console.WriteLine("Genre: " + valueId.GetGenre().ToString()); Console.WriteLine(""); break; } } }
public ZWaveButtonOff(ZWNotification notification) : base(notification) { }
private void OnNotification(ZWNotification notification) { var notification2 = new OpenZWaveNotification(this, notification); _notificationProcessor.Process(notification2); }
public ZWaveNotification(ZWNotification notification) : base(notification) { }
public ZWaveGroup(ZWNotification notification) : base(notification) { }
internal static void NotificationHandler(ZWNotification notification) { Console.WriteLine("NOTIFICATION RECEIVED: " + notification.GetType().ToString()); ZWValueID v = notification.GetValueID(); Console.WriteLine(" Node : " + v.GetNodeId().ToString()); Console.WriteLine(" CC : " + v.GetCommandClassId().ToString()); Console.WriteLine(" Type : " + v.GetType().ToString()); Console.WriteLine(" Index: " + v.GetIndex().ToString()); Console.WriteLine(" Inst : " + v.GetInstance().ToString()); Console.WriteLine(" Value: " + GetValue(v).ToString()); Console.WriteLine(" Byte : " + notification.GetByte().ToString()); Console.WriteLine(" Label: " + MainForm.Manager.GetValueLabel(v)); Console.WriteLine(" Help : " + MainForm.Manager.GetValueHelp(v)); Console.WriteLine(" Units: " + MainForm.Manager.GetValueUnits(v)); #region Switch Ready switch (m_ready) { #region Ready case true: { Console.WriteLine(notification.GetType().ToString()); string result; switch (notification.GetType()) { case ZWNotification.Type.ValueAdded: { foreach (Node n in _nodes) { if (n.ID == notification.GetNodeId()) { n.AddValue(notification.GetValueID()); } } break; } case ZWNotification.Type.ValueChanged: { foreach (Node n in _nodes) { if (n.ID == notification.GetNodeId()) { if (MainForm.Manager.GetValueLabel(notification.GetValueID()) == "Basic") { try { foreach (ZWValueID vid in n.Values) { if (MainForm.Manager.GetValueLabel(vid) == "Basic") { Console.WriteLine("Removing Basic Value"); n.RemoveValue(vid); } } } catch { } Console.WriteLine("Adding Basic Value"); n.AddValue(notification.GetValueID()); MainForm.Manager.GetValueAsString(notification.GetValueID(), out result); Console.WriteLine(" Result: " + result); Console.WriteLine(Environment.NewLine); //Thread t = new Thread(new ThreadStart(Program._MainForm.engineeringScreen1.subSystemControls1.SetButtonStatuses)); //t.Start(); Program._MainForm.engineeringScreen1.subSystemControls1.SetButtonStatuses(); break; } } } Console.WriteLine("ValueID: " + notification.GetValueID().ToString()); break; } case ZWNotification.Type.ValueRemoved: { foreach (Node n in _nodes) { if (n.ID == notification.GetNodeId()) { n.RemoveValue(notification.GetValueID()); } } break; } case ZWNotification.Type.NodeEvent: { foreach (Node n in _nodes) { if (n.ID == notification.GetNodeId()) { switch (notification.GetByte()) { case 255: { n.Triggered = true; break; } case 0: { n.Triggered = false; break; } } } } BusinessLogic.SensorStatusChange(notification.GetNodeId(), notification.GetByte()); Program._MainForm.engineeringScreen1.SetButtonStatuses(); Program._MainForm.engineeringScreen1.subSystemControls1.SetButtonStatuses(); break; } default: { Console.WriteLine(Environment.NewLine); break; } } break; } #endregion #region Not Ready default: { Console.WriteLine(notification.GetType().ToString() + ":"); switch (notification.GetType()) { case ZWNotification.Type.AwakeNodesQueried: { Console.WriteLine(Environment.NewLine + notification.GetType().ToString() + Environment.NewLine); m_ready = true; //Thread t = new Thread(new ThreadStart(Program._MainForm.engineeringScreen1.SetButtonStatuses)); //t.Start(); Program._MainForm.engineeringScreen1.SetButtonStatuses(); //Thread t2 = new Thread(new ThreadStart(Program._MainForm.engineeringScreen1.subSystemControls1.SetButtonStatuses)); //t2.Start(); Program._MainForm.engineeringScreen1.subSystemControls1.SetButtonStatuses(); StringBuilder message = new StringBuilder(); message.Append("Awake Nodes Query Complete"); MainForm.Speak(message.ToString()); break; } case ZWNotification.Type.NodeQueriesComplete: { StringBuilder message = new StringBuilder(); message.Append("Node "); message.Append(v.GetNodeId().ToString()); message.Append(" Query Complete."); MainForm.Speak(message.ToString()); break; } case ZWNotification.Type.NodeNew: { Node n = new Node(); n.HomeID = notification.GetHomeId(); n.ID = notification.GetNodeId(); _nodes.Add(n); break; } case ZWNotification.Type.ValueAdded: { Node node = new Node(); node.HomeID = notification.GetHomeId(); node.ID = notification.GetNodeId(); if(!_nodes.Contains(_nodes.Find(item => item.ID == node.ID))) { _nodes.Add(node); } foreach (Node n in _nodes) { if (n.ID == notification.GetNodeId()) { n.AddValue(notification.GetValueID()); } } break; } } break; } #endregion } #endregion }
public ZWaveNodeAdded(ZWNotification notification) : base(notification) { }
public void NotificationHandler(ZWNotification notification) { m_notification = notification; NotificationHandler(); m_notification = null; }
public void Publish(ZWNotification zwNotification) { Contract.Requires<ArgumentNullException>(zwNotification != null); var type = zwNotification.GetType(); switch (type) { case ZWNotification.Type.DriverReady: _eventPublisher.Publish(new ZWaveDriverReady(zwNotification)); break; case ZWNotification.Type.AllNodesQueried: _eventPublisher.Publish(new ZWaveAllNodesQueried(zwNotification)); break; case ZWNotification.Type.AllNodesQueriedSomeDead: _eventPublisher.Publish(new ZWaveAllNodesQueriedSomeDead(zwNotification)); break; case ZWNotification.Type.ValueAdded: _eventPublisher.Publish(new ZWaveValueAdded(zwNotification)); break; case ZWNotification.Type.ValueRemoved: _eventPublisher.Publish(new ZWaveValueRemoved(zwNotification)); break; case ZWNotification.Type.ValueChanged: _eventPublisher.Publish(new ZWaveValueChanged(zwNotification)); break; case ZWNotification.Type.ValueRefreshed: _eventPublisher.Publish(new ZWaveValueRefreshed(zwNotification)); break; case ZWNotification.Type.Group: _eventPublisher.Publish(new ZWaveGroup(zwNotification)); break; case ZWNotification.Type.NodeNew: _eventPublisher.Publish(new ZWaveNodeNew(zwNotification)); break; case ZWNotification.Type.NodeAdded: _eventPublisher.Publish(new ZWaveNodeAdded(zwNotification)); break; case ZWNotification.Type.NodeRemoved: _eventPublisher.Publish(new ZWaveNodeRemoved(zwNotification)); break; case ZWNotification.Type.NodeProtocolInfo: _eventPublisher.Publish(new ZWaveNodeProtocolInfo(zwNotification)); break; case ZWNotification.Type.NodeNaming: _eventPublisher.Publish(new ZWaveNodeNaming(zwNotification)); break; case ZWNotification.Type.NodeEvent: _eventPublisher.Publish(new ZWaveNodeEvent(zwNotification)); break; case ZWNotification.Type.PollingDisabled: _eventPublisher.Publish(new ZWavePollingDisabled(zwNotification)); break; case ZWNotification.Type.PollingEnabled: _eventPublisher.Publish(new ZWavePollingEnabled(zwNotification)); break; case ZWNotification.Type.SceneEvent: _eventPublisher.Publish(new ZWaveSceneEvent(zwNotification)); break; case ZWNotification.Type.CreateButton: _eventPublisher.Publish(new ZWaveCreateButton(zwNotification)); break; case ZWNotification.Type.DeleteButton: _eventPublisher.Publish(new ZWaveDeleteButton(zwNotification)); break; case ZWNotification.Type.ButtonOn: _eventPublisher.Publish(new ZWaveButtonOn(zwNotification)); break; case ZWNotification.Type.ButtonOff: _eventPublisher.Publish(new ZWaveButtonOff(zwNotification)); break; case ZWNotification.Type.DriverFailed: _eventPublisher.Publish(new ZWaveDriverFailed(zwNotification)); break; case ZWNotification.Type.DriverReset: _eventPublisher.Publish(new ZWaveDriverReset(zwNotification)); break; case ZWNotification.Type.EssentialNodeQueriesComplete: _eventPublisher.Publish(new ZWaveEssentialNodeQueriesComplete(zwNotification)); break; case ZWNotification.Type.NodeQueriesComplete: _eventPublisher.Publish(new ZWaveNodeQueriesComplete(zwNotification)); break; case ZWNotification.Type.AwakeNodesQueried: _eventPublisher.Publish(new ZWaveAwakeNodesQueried(zwNotification)); break; case ZWNotification.Type.Notification: _eventPublisher.Publish(new ZWaveNotification(zwNotification)); break; case ZWNotification.Type.DriverRemoved: _eventPublisher.Publish(new ZWaveDriverRemoved(zwNotification)); break; case ZWNotification.Type.ControllerCommand: _eventPublisher.Publish(new ZWaveControllerCommand(zwNotification)); break; default: throw new InvalidOperationException($"Unknown notification: {zwNotification}"); } }
public ZWaveCreateButton(ZWNotification notification) : base(notification) { }
public ZWaveValueAdded(ZWNotification notification) : base(notification) { }
public ZWaveNodeProtocolInfo(ZWNotification notification) : base(notification) { }
/// <summary> /// Method which handles the events raised by the ZWave network /// </summary> /// <param name="m_notification"></param> private static void NotificationHandler(ZWNotification m_notification) { if (m_notification == null) { return; } switch (m_notification.GetType()) { case ZWNotification.Type.ValueAdded: { Node node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId()); if (node != null) node.AddValue(m_notification.GetValueID()); break; } case ZWNotification.Type.ValueRemoved: { Node node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId()); if (node != null) node.RemoveValue(m_notification.GetValueID()); break; } case ZWNotification.Type.ValueChanged: { Node node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId()); if (node != null) node.SetValue(m_notification.GetValueID()); break; } case ZWNotification.Type.NodeAdded: { Node node = new Node(); node.ID = m_notification.GetNodeId(); node.HomeID = m_notification.GetHomeId(); m_nodeList.Add(node); break; } case ZWNotification.Type.NodeRemoved: { foreach (Node node in m_nodeList) { if (node.ID == m_notification.GetNodeId()) { m_nodeList.Remove(node); break; } } break; } case ZWNotification.Type.NodeProtocolInfo: { Node node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId()); if (node != null) node.Label = m_manager.GetNodeType(m_homeId, node.ID); break; } case ZWNotification.Type.NodeNaming: { Node node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId()); if (node != null) { node.Manufacturer = m_manager.GetNodeManufacturerName(m_homeId, node.ID); node.Product = m_manager.GetNodeProductName(m_homeId, node.ID); node.Location = m_manager.GetNodeLocation(m_homeId, node.ID); node.Name = m_manager.GetNodeName(m_homeId, node.ID); } break; } case ZWNotification.Type.DriverReady: { m_homeId = m_notification.GetHomeId(); break; } case ZWNotification.Type.AllNodesQueried: { m_nodesReady = true; break; } default: break; } }
public ZWaveEssentialNodeQueriesComplete(ZWNotification notification) : base(notification) { }
public ZWaveValueChanged(ZWNotification notification) : base(notification) { }
/// <summary> /// The notification handler. This is called by the ZWave library every time /// an event occurs on the ZWave network, a device is found/lost, etc /// </summary> private void NotificationHandler(ZWNotification notification) { var value = notification.ValueId; var homeID = notification.HomeId; var nodeId = notification.NodeId; var type = notification.Type; Action <ZWValueId> debugWriteValueID = (v) => { //Debug.WriteLine(" Node : " + nodeId.ToString()); //Debug.WriteLine(" CC : " + v.CommandClassId.ToString()); //Debug.WriteLine(" Type : " + type.ToString()); //Debug.WriteLine(" Index: " + v.Index.ToString()); //Debug.WriteLine(" Inst : " + v.Instance.ToString()); //Debug.WriteLine(" Value: " + GetValue(v).ToString()); //Debug.WriteLine(" Label: " + m_manager.GetValueLabel(v)); //Debug.WriteLine(" Help : " + m_manager.GetValueHelp(v)); //Debug.WriteLine(" Units: " + m_manager.GetValueUnits(v)); }; foreach (var item in m_pendingRequests.ToArray()) { if (item.HomeID == homeID && (item.NodeID == nodeId || item.NodeID < 0) && item.Type == type) { item.CompletionSource.SetResult(notification); m_pendingRequests.Remove(item); } else if (item.Age > item.Timeout) { item.CompletionSource.SetException(new TimeoutException()); m_pendingRequests.Remove(item); } } switch (notification.Type) { // NodeAdded : Node now exists in the system. Very little useful info case ZWNotificationType.NodeAdded: { // if this node was in zwcfg*.xml, this is the first node notification // if not, the NodeNew notification should already have been received if (GetNode(homeID, nodeId) == null) { m_nodeList.Add(new Node(nodeId, homeID)); Debug.WriteLine("Node Added. nodeId = [" + nodeId + "] , homeId = [" + homeID + "]"); } break; } case ZWNotificationType.NodeNew: { // Add the new node to our list (and flag as uninitialized) m_nodeList.Add(new Node(nodeId, homeID)); break; } case ZWNotificationType.NodeRemoved: { foreach (Node node in m_nodeList) { if (node.ID == nodeId) { m_nodeList.Remove(node); node.RaiseNodeRemoved(); break; } } break; } case ZWNotificationType.NodeProtocolInfo: case ZWNotificationType.NodeEvent: case ZWNotificationType.NodeNaming: case ZWNotificationType.EssentialNodeQueriesComplete: case ZWNotificationType.NodeQueriesComplete: case ZWNotificationType.ValueRemoved: case ZWNotificationType.ValueChanged: case ZWNotificationType.Group: { Node node = GetNode(homeID, nodeId); if (node != null) { node.HandleNodeEvent(notification); } break; } case ZWNotificationType.PollingDisabled: { Debug.WriteLine("Polling disabled notification"); break; } case ZWNotificationType.PollingEnabled: { Debug.WriteLine("Polling enabled notification"); break; } case ZWNotificationType.DriverReady: { var p = ZWManager.Instance.GetControllerPath(homeID); var ctrl = Controllers.Where(c => c.ControllerPath == p).FirstOrDefault(); if (ctrl != null) { ctrl.HandleControllerEvent(notification); } else { m_controllerList.Add(new Controller(p, p, homeID)); } break; } case ZWNotificationType.DriverFailed: { // TODO: if HomeID is 0 we don't really know anything about which one failed Debug.WriteLine("Driver failed for HomeID " + homeID.ToString()); var d = Controllers.Where(t => t.HomeId == homeID).FirstOrDefault(); if (d != null) { d.UpdateDriverStatus(DriverStatus.Failed); } break; } case ZWNotificationType.DriverRemoved: { var d = Controllers.Where(t => t.HomeId == homeID).FirstOrDefault(); var nodes = GetNodes(homeID).ToArray(); foreach (var node in nodes) { m_nodeList.Remove(node); } if (d != null) { m_controllerList.Remove(d); } break; } case ZWNotificationType.AllNodesQueried: case ZWNotificationType.AllNodesQueriedSomeDead: case ZWNotificationType.AwakeNodesQueried: { var d = Controllers.Where(t => t.HomeId == homeID).FirstOrDefault(); d?.HandleControllerEvent(notification); break; } default: { if (nodeId > 0) { Node node = GetNode(homeID, nodeId); if (node != null) { node.HandleNodeEvent(notification); } } else { //var v = GetValue(notification.ValueID); Debug.WriteLine($"******Controller error '{notification.Code}'"); //Debug.WriteLine($"******Notification '{type}' not Handled @ ID: {nodeId}"); } break; } } }
public static void Execute(ZWave zWave, ZWNotification notification, Action<ZWManager, ZWaveEventArgs> zWaveEvent) { var nodeId = notification.GetNodeId(); var homeId = notification.GetHomeId(); var node = zWave.Nodes.SingleOrDefault(x => x.ID == nodeId); if (zWave.HomeId == null) zWave.HomeId = homeId; var notificationType = notification.GetType(); switch (notificationType) { case ZWNotification.Type.ValueChanged: { bool errorWhileLoading = false; if (node.Failed) { zWave.Manager.RequestAllConfigParams(homeId, nodeId); var sum = 0; while (!node.Loaded) { Thread.Sleep(ZWGlobal.Constants.IterationWaitingInterval); sum += ZWGlobal.Constants.IterationWaitingInterval; if (sum >= ZWGlobal.Constants.MaxWaitingInterval) { errorWhileLoading = true; break; } } node.Failed = false; } if (!errorWhileLoading) { var valueId = notification.GetValueID(); zWaveEvent(zWave.Manager, new ZWaveEventArgs( zWave, zWave.Nodes.Single(x => x.ID == nodeId), valueId, valueId.GetValue<object>(zWave.Manager) )); } break; } case ZWNotification.Type.NodeAdded: { if (!zWave.Nodes.Any(x => x.HomeID == homeId && x.ID == notification.GetNodeId())) { node = new Node(); node.ID = notification.GetNodeId(); node.HomeID = homeId; zWave.Manager.RequestAllConfigParams(homeId, node.ID); node.RequestingValuesBegan = true; zWave.Nodes.Add(node); } break; } case ZWNotification.Type.NodeNew: { node = new Node(); node.ID = notification.GetNodeId(); node.HomeID = homeId; zWave.Nodes.Add(node); zWave.Manager.RequestAllConfigParams(homeId, node.ID); node.RequestingValuesBegan = true; break; } case ZWNotification.Type.NodeRemoved: { zWave.Nodes .Remove( zWave.Nodes.SingleOrDefault(x => x.ID == notification.GetNodeId()) ); break; } case ZWNotification.Type.ValueAdded: { node.AddValue(notification.GetValueID()); break; } case ZWNotification.Type.ValueRemoved: { node.RemoveValue(notification.GetValueID()); break; } case ZWNotification.Type.NodeProtocolInfo: { node.Label = zWave.Manager.GetNodeType(homeId, node.ID); break; } case ZWNotification.Type.NodeQueriesComplete: { node.Loaded = true; if (!zWave.Nodes.Where(x => !x.Loaded).Any() || !zWave.Nodes.Any()) { zWave.NodesLoaded = true; if (!ZWGlobal.GetAllZWaveControllersNames().Where(x => !x.NodesLoaded).Any()) ZWGlobal.ControllersLoaded = true; } break; } case ZWNotification.Type.AllNodesQueried: { zWave.NodesLoaded = true; zWave.Failed = false; if (!ZWGlobal.GetAllZWaveControllersNames().Where(x => !x.NodesLoaded || x.Failed == null).Any()) ZWGlobal.ControllersLoaded = true; break; } case ZWNotification.Type.DriverFailed: { zWave.Failed = true; break; } //case ZWNotification.Type.NodeNaming: // { // break; // } //case ZWNotification.Type.Group: // { // break; // } //case ZWNotification.Type.NodeEvent: // { // break; // } //case ZWNotification.Type.PollingDisabled: // { // break; // } //case ZWNotification.Type.PollingEnabled: // { // break; // } //case ZWNotification.Type.DriverReady: // { // break; // } //case ZWNotification.Type.EssentialNodeQueriesComplete: // { // break; // } } if (notificationType == ZWNotification.Type.AllNodesQueriedSomeDead || notificationType == ZWNotification.Type.AwakeNodesQueried) { zWave.NodesLoaded = true; zWave.Nodes.Where(x => !x.Loaded).Select(x => x.Failed = true); if (!ZWGlobal.GetAllZWaveControllersNames().Where(x => !x.NodesLoaded).Any()) ZWGlobal.ControllersLoaded = true; } //normal naming event not works if (node != null) //crutch { node.Manufacturer = zWave.Manager.GetNodeManufacturerName(homeId, node.ID); node.Product = zWave.Manager.GetNodeProductName(homeId, node.ID); node.Location = zWave.Manager.GetNodeLocation(homeId, node.ID); node.Name = zWave.Manager.GetNodeName(homeId, node.ID); } }
/// <summary> /// Called by the <see cref="Watcher"/> when events specific to this instance occur /// </summary> /// <param name="notification"></param> internal void HandleNodeEvent(ZWNotification notification) { switch (notification.Type) { // NodeProtocolInfo: We now know what type of node it is case ZWNotificationType.NodeProtocolInfo: { // Basic node information has been received, such as whether the node is a listening // device, a routing device and its baud rate and basic, generic and specific types. // It is after this notification that you can call get the Label containing the device description. OnPropertyChanged(nameof(Label)); break; } case ZWNotificationType.NodeNaming: { // One of the node names has changed (name, manufacturer, product) OnPropertyChanged(nameof(Name)); OnPropertyChanged(nameof(Manufacturer)); OnPropertyChanged(nameof(Product)); OnPropertyChanged(nameof(ManufacturerAndProduct)); OnPropertyChanged(nameof(Location)); break; } case ZWNotificationType.EssentialNodeQueriesComplete: { // The queries on a node that are essential to its operation have been completed. // The node can now handle incoming messages. EssentialNodeQueriesComplete = true; OnPropertyChanged(nameof(EssentialNodeQueriesComplete)); break; } case ZWNotificationType.NodeQueriesComplete: { // All the initialization queries on a node have been completed. NodeQueriesComplete = true; OnPropertyChanged(nameof(NodeQueriesComplete)); break; } case ZWNotificationType.ValueAdded: case ZWNotificationType.ValueChanged: { // Added: A new node value has been added to OpenZWave's list. These notifications occur // after a node has been discovered, and details of its command classes have been // received. Each command class may generate one or more values depending on the // complexity of the item being represented. // Changed: A node value has been updated from the Z-Wave network and it is different from // the previous value. var value = notification.ValueId; AddValue(value); Debug.WriteLine($"{notification.Type}. Node {ID}: {ZWManager.Instance.GetValueLabel(value)} = {GetValue(value)} {ZWManager.Instance.GetValueUnits(value)}"); break; } case ZWNotificationType.ValueRemoved: { // A node value has been removed from OpenZWave's list. This only occurs when a // node is removed. // Note to self: We probably don't need to handle this, since the node would have been // removed at this point RemoveValue(notification.ValueId); break; } case ZWNotificationType.Group: { // The associations for the node have changed.The application should rebuild any // group information it holds about the node. break; } case ZWNotificationType.Notification: //An error has occurred that we need to report. { Debug.WriteLine($"******Node error '{notification.Code}' @ ID: {ID}"); // var code = notification.Code; // var v = GetValue(notification.ValueID); break; } case ZWNotificationType.NodeEvent: // A node has triggered an event. This is commonly caused when a node sends a Basic_Set command to the controller. The event value is stored in the notification. { var value = GetValue(notification.ValueId); Debug.WriteLine($"******Node Event @ ID: Value = {value}"); break; } default: { Debug.WriteLine($"******Notification '{notification.Type}' not Handled @ ID: {ID}"); break; } } }