diff --git a/MIG.HomeAutomation/ZigBee.cs b/MIG.HomeAutomation/ZigBee.cs index 7fcd726..14ad6ed 100644 --- a/MIG.HomeAutomation/ZigBee.cs +++ b/MIG.HomeAutomation/ZigBee.cs @@ -177,7 +177,6 @@ public object InterfaceControl(MigInterfaceCommand request) { break; } - Thread.Sleep(DelayBetweenAttempts); } coord.PermitJoin(false); @@ -417,6 +416,11 @@ public void RouteEvent(ZigBeeNode node, string eventDescription, string property { OnInterfacePropertyChanged(this.GetDomain(), node.IeeeAddress.ToString(), eventDescription, propertyPath, propertyValue); } + + public void ControllerEvent(string eventPath, string eventPayload) + { + OnInterfacePropertyChanged(this.GetDomain(), "0", "ZigBee Controller", eventPath, eventPayload); + } public ZigBeeNode GetNode(ushort nodeId) { @@ -441,11 +445,11 @@ public void AddNode(ZigBeeNode node) }); if (initialized) { - lastAddedNode = node.IeeeAddress.ToString(); - OnInterfacePropertyChanged(this.GetDomain(), "0", "ZigBee Controller", "Controller.Status", "Added node " + node.IeeeAddress); + ControllerEvent("Controller.Status", "Added node " + node.IeeeAddress); // get manufacturer name and model identifier ReadClusterData(node).Wait(); OnInterfaceModulesChanged(this.GetDomain()); + lastAddedNode = node.IeeeAddress.ToString(); } } } @@ -455,7 +459,7 @@ public void RemoveNode(ZigBeeNode node) int removed = modules.RemoveAll((m) => m.Address == node.IeeeAddress.ToString()); if (removed > 0) { - OnInterfacePropertyChanged(this.GetDomain(), "0", "ZigBee Controller", "Controller.Status", "Removed node " + node.IeeeAddress); + ControllerEvent("Controller.Status", "Removed node " + node.IeeeAddress); OnInterfaceModulesChanged(this.GetDomain()); } } @@ -719,7 +723,7 @@ public void CommandReceived(ZigBeeCommand command) var node = _zigBee.GetNode(nodeId); if (command is DeviceAnnounce) { -// Console.WriteLine("DEVICE ANNOUNCE"); + _zigBee.ControllerEvent("Controller.Status", "Announce node " + node.IeeeAddress); } else if (command is ReportAttributesCommand) {