Exemplo n.º 1
0
        public bool TryStartPairing(ZWaveNode nodeBeingPaired, IZWavePairingMonitor monitor)
        {
            if (_nodeBeingPaired != null ||
                _monitor != null)
            {
                return(false);
            }
            bool result = _zWaveManager.BeginControllerCommand(_homeId, ZWControllerCommand.AddDevice, false, 0);

            if (result)
            {
                _nodeBeingPaired    = nodeBeingPaired;
                _hasSeenButtonPress = false;
                _monitor            = monitor;
                IsInitialized       = false;
                _monitor.PairingStarted();
            }
            return(result);
        }
Exemplo n.º 2
0
        private void NotificationRecieved(Object sender, NotificationEventArgs args)
        {
            ZWaveNode node = _configManager.FindAllComponentsOfTypeEvenInvalid <ZWaveNode>().SingleOrDefault(n => n.NodeId == args.NodeId);

            switch (args.NotificationType)
            {
            case ZWNotification.Type.NodeAdded:
                if (node != null)
                {
                    node.IsConnected = true;
                }
                else if (_nodeBeingPaired != null)
                {
                    _nodeBeingPaired.NodeId      = args.NodeId;
                    _nodeBeingPaired.IsConnected = true;
                    _nodeBeingPaired             = null;
                }
                break;

            case ZWNotification.Type.NodeRemoved:
                if (node != null)
                {
                    node.IsConnected = false;
                }
                break;

            case ZWNotification.Type.AllNodesQueried:
            case ZWNotification.Type.AllNodesQueriedSomeDead:
                IsInitialized = true;
                break;

            case ZWNotification.Type.NodeQueriesComplete:
                if (_monitor != null)
                {
                    _monitor.PairingCompleted();
                    _monitor = null;
                }
                break;

            case ZWNotification.Type.ValueAdded:
                if (node != null)
                {
                    node.AddValueId(args.ValueId);
                }
                break;

            case ZWNotification.Type.ValueRemoved:
                if (node != null)
                {
                    node.RemoveValueId(args.ValueId);
                }
                if (_monitor != null && !_hasSeenButtonPress)
                {
                    _monitor.DeviceFound();
                    _hasSeenButtonPress = true;
                }
                break;

            case ZWNotification.Type.DriverReady:
                _homeId = args.HomeId;
                break;

            case ZWNotification.Type.ValueRefreshed:
            case ZWNotification.Type.ValueChanged:
            case ZWNotification.Type.AwakeNodesQueried:
            case ZWNotification.Type.ButtonOff:
            case ZWNotification.Type.ButtonOn:
            case ZWNotification.Type.CreateButton:
            case ZWNotification.Type.DeleteButton:
            case ZWNotification.Type.DriverFailed:
            case ZWNotification.Type.DriverReset:
            case ZWNotification.Type.EssentialNodeQueriesComplete:
            case ZWNotification.Type.Group:
            case ZWNotification.Type.Notification:
            case ZWNotification.Type.PollingDisabled:
            case ZWNotification.Type.PollingEnabled:
            case ZWNotification.Type.SceneEvent:
            case ZWNotification.Type.NodeEvent:
            case ZWNotification.Type.NodeNaming:
            case ZWNotification.Type.NodeNew:
            case ZWNotification.Type.NodeProtocolInfo:
            default:
                break;
            }
        }
Exemplo n.º 3
0
        public bool TryStartPairing(IZWavePairingMonitor monitor)
        {
            bool successful = _controller.TryStartPairing(this, monitor);

            return(successful);
        }