private void NotificationHandler()
        {
            Node node2 = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId());

            logging.AddToLog(" --- ", true);
            logging.AddToLog("Notification: " + m_notification.GetType().ToString() + " | Node: " + node2.ID.ToString(), true);
            switch (m_notification.GetType())
            {
                #region ValueAdded
                case ZWNotification.Type.ValueAdded:
                    {

                        Node node = GetNode(m_homeId, m_notification.GetNodeId());
                        logging.AddToLog("ValueAdded start: node:" + node.ID.ToString(), true);
                        Value value = new Value();
                        ZWValueID vid = m_notification.GetValueID();
                        value.ValueID = vid;
                        value.Label = m_manager.GetValueLabel(vid);
                        value.Genre = vid.GetGenre();
                        value.Index = vid.GetIndex().ToString();
                        value.Type = vid.GetType();
                        value.CommandClassID = vid.GetCommandClassId().ToString();
                        node.AddValue(value);

                        string objType = m_manager.GetNodeProductName(m_homeId, node.ID);
                        string propType;

                        if (!string.IsNullOrEmpty(objType))
                        {
                            if (m_manager.IsValueReadOnly(value.ValueID))
                            {
                                if (value.Genre == ZWValueID.ValueGenre.User)
                                {
                                    if (value.Label == "Sensor")
                                    {
                                        OSAEObjectTypeManager.ObjectTypeStateAdd("ON", "On", objType);
                                        OSAEObjectTypeManager.ObjectTypeStateAdd("OFF", "Off", objType);
                                        OSAEObjectTypeManager.ObjectTypeEventAdd("ON", "On", objType);
                                        OSAEObjectTypeManager.ObjectTypeEventAdd("OFF", "Off", objType);
                                        OSAEObjectTypeManager.ObjectTypeEventAdd("ALARM", "Alarm", objType);
                                    }
                                    else
                                    {

                                        if (value.Type == ZWValueID.ValueType.Bool)
                                            propType = "Boolean";
                                        else if (value.Type == ZWValueID.ValueType.Byte || value.Type == ZWValueID.ValueType.Int)
                                            propType = "Integer";
                                        else
                                            propType = "String";

                                        OSAEObjectTypeManager.ObjectTypePropertyAdd(value.Label, propType, "", objType, false);
                                        OSAEObjectTypeManager.ObjectTypeEventAdd(value.Label, value.Label, objType);
                                    }
                                }
                            }
                            else
                            {
                                if (value.Genre == ZWValueID.ValueGenre.User)
                                {
                                    if (value.Label == "Switch" || value.Label == "Level")
                                    {
                                        OSAEObjectTypeManager.ObjectTypeStateAdd("ON", "On", objType);
                                        OSAEObjectTypeManager.ObjectTypeStateAdd("OFF", "Off", objType);
                                        OSAEObjectTypeManager.ObjectTypeEventAdd("ON", "On", objType);
                                        OSAEObjectTypeManager.ObjectTypeEventAdd("OFF", "Off", objType);
                                        OSAEObjectTypeManager.ObjectTypeMethodAdd("ON", "On", objType, "", "", "", "");
                                        OSAEObjectTypeManager.ObjectTypeMethodAdd("OFF", "Off", objType, "", "", "", "");
                                        if(value.Label == "Level")
                                            OSAEObjectTypeManager.ObjectTypePropertyAdd("Level", "Integer", "", objType, false);
                                    }
                                    else
                                    {
                                        if (value.Type == ZWValueID.ValueType.Byte || value.Type == ZWValueID.ValueType.Decimal || value.Type == ZWValueID.ValueType.Int)
                                        {
                                            OSAEObjectTypeManager.ObjectTypeMethodAdd(value.Label, value.Label, objType, "Value", "", "", "");
                                        }
                                        else if (value.Type == ZWValueID.ValueType.Button)
                                        {
                                            OSAEObjectTypeManager.ObjectTypeMethodAdd(value.Label, value.Label, objType, "", "", "", "");
                                        }
                                    }
                                }
                            }
                        }

                        logging.AddToLog("ValueAdded: node:" + node.ID + " | type: " + value.Type
                            + " | genre: " + value.Genre + " | cmdClsID:" + value.CommandClassID
                            + " | index: " + value.Index + " | instance: " + vid.GetInstance().ToString()
                            + " | readOnly: " + m_manager.IsValueReadOnly(value.ValueID).ToString()
                            + " | value: " + value.Val + " | label: " + m_manager.GetValueLabel(vid), true);
                        break;
                    }
                #endregion

                #region ValueRemoved
                case ZWNotification.Type.ValueRemoved:
                    {
                        try
                        {
                            logging.AddToLog("ValueRemoved: ", true);
                            Node node = GetNode(m_homeId, m_notification.GetNodeId());
                            ZWValueID vid = m_notification.GetValueID();
                            Value val = node.GetValue(vid);
                            node.RemoveValue(val);
                        }
                        catch (Exception ex)
                        {
                            logging.AddToLog("ValueRemoved error: " + ex.Message, true);
                        }
                        break;
                    }
                #endregion

                #region ValueChanged
                case ZWNotification.Type.ValueChanged:
                    {
                        try
                        {
                            Node node = GetNode(m_homeId, m_notification.GetNodeId());
                            logging.AddToLog("ValueChanged start: node:" + node.ID.ToString(), false);
                            ZWValueID vid = m_notification.GetValueID();
                            Value value = node.GetValue(vid);
                            logging.AddToLog("value:" + value.Val, false);
                            OSAEObject nodeObject = OSAEObjectManager.GetObjectByAddress("Z" + m_notification.GetNodeId());
                            string v;
                            m_manager.GetValueAsString(vid, out v);
                            value.Val = v;

                            if (m_manager.IsValueReadOnly(value.ValueID))
                            {
                                if (value.Genre == ZWValueID.ValueGenre.User)
                                {
                                    if (value.Label == "Sensor")
                                    {
                                        if (value.Val == "False")
                                            OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "OFF", "ZWave");
                                        else
                                            OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "ON", "ZWave");
                                    }
                                    else if (value.Label == "Alarm Level")
                                    {
                                        if (value.Val == "255")
                                            logging.EventLogAdd(nodeObject.Name, "ALARM");
                                    }
                                    else
                                    {
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, value.Label, value.Val, "ZWave");
                                        logging.AddToLog("Set property " + value.Label + " of " + nodeObject.Name + " to: " + value.Val.ToString(), false);
                                    }
                                }
                            }
                            else
                            {
                                if (value.Genre == ZWValueID.ValueGenre.User)
                                {
                                    if (value.Label == "Switch")
                                    {
                                        if (value.Val == "False")
                                            OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "OFF", "ZWave");
                                        else
                                            OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "ON", "ZWave");
                                    }
                                    else if (value.Label == "Level")
                                    {
                                        if (value.Val == "0")
                                            OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "OFF", "ZWave");
                                        else
                                            OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "ON", "ZWave");
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, value.Label, value.Val, "ZWave");
                                        logging.AddToLog("Set property " + value.Label + " of " + nodeObject.Name + " to: " + value.Val.ToString(), false);
                                    }
                                    else
                                    {
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, value.Label, value.Val, "ZWave");
                                        logging.AddToLog("Set property " + value.Label + " of " + nodeObject.Name + " to: " + value.Val.ToString(), false);
                                    }
                                }
                            }

                            logging.AddToLog("ValueChanged: " + ((nodeObject != null) ? nodeObject.Name : "Object Not In OSA") + " | node:"
                                + node.ID + " | nodelabel: " + node.Label + " | type: " + value.Type
                                + " | genre: " + value.Genre + " | cmdClsID:" + value.CommandClassID
                                + " | readOnly: " + m_manager.IsValueReadOnly(value.ValueID) + " | value: " + value.Val + " | label: " + value.Label, false);

                        }
                        catch (Exception ex)
                        {
                            logging.AddToLog("ValueChanged error: " + ex.Message, true);
                        }
                        break;
                    }
                #endregion

                #region Group
                case ZWNotification.Type.Group:
                    {
                        Node node = GetNode(m_homeId, m_notification.GetNodeId());
                        logging.AddToLog("Group: " + node.ID, true);
                        break;
                    }
                #endregion

                #region NodeAdded
                case ZWNotification.Type.NodeAdded:
                    {
                        // Add the new node to our list
                        Node node = new Node();
                        node.ID = m_notification.GetNodeId();
                        node.HomeID = m_homeId;
                        node.Label = m_manager.GetNodeType(m_homeId, node.ID);
                        m_nodeList.Add(node);

                        logging.AddToLog("NodeAdded: " + node.ID.ToString(), true);
                        break;
                    }
                #endregion

                #region NodeRemoved
                case ZWNotification.Type.NodeRemoved:
                    {
                        foreach (Node node in m_nodeList)
                        {
                            if (node.ID == m_notification.GetNodeId())
                            {
                                m_nodeList.Remove(node);
                                break;
                            }
                        }
                        logging.AddToLog("NodeRemoved: " + m_notification.GetNodeId(), true);
                        break;
                    }
                #endregion

                #region NodeProtocolInfo
                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);
                        }

                        logging.AddToLog("NodeProtocolInfo: node: " + node.ID + " | " + node.Label, true);

                        break;
                    }
                #endregion

                #region NodeNaming
                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);

                            // Create object type dynamically
                            if (OSAEObjectManager.GetObjectByAddress("Z" + node.ID.ToString()) == null)
                            {
                                string baseType = "ZWAVE DEVICE";
                                switch (node.Label)
                                {
                                    case "Binary Switch":
                                    case "Binary Power Switch":
                                        {
                                            baseType = "BINARY SWITCH";
                                            break;
                                        }
                                    case "Multilevel Switch":
                                    case "Multilevel Scene Switch":
                                        {
                                            baseType = "MULTILEVEL SWITCH";
                                            break;
                                        }
                                    case "General Thermostat V2":
                                        {
                                            baseType = "THERMOSTAT";
                                            break;
                                        }
                                }

                                OSAEObjectTypeManager.ObjectTypeAdd(node.Product, node.Label, pName, baseType,  0, 0, 0, 1);
                                OSAEObjectTypeManager.ObjectTypeMethodAdd("NODE NEIGHBOR UPDATE", "Node Neighbor Update", node.Product, "", "", "", "");
                                OSAEObjectTypeManager.ObjectTypePropertyAdd("Home ID", "String", "", node.Product, false);
                                OSAEObjectTypeManager.ObjectTypePropertyAdd("Poll", "Boolean", "", node.Product, false);

                                string propType;
                                foreach (Value v in node.Values)
                                {
                                    if (m_manager.IsValueReadOnly(v.ValueID))
                                    {
                                        if (v.Type == ZWValueID.ValueType.Bool)
                                            propType = "Boolean";
                                        else if (v.Type == ZWValueID.ValueType.Byte || v.Type == ZWValueID.ValueType.Int)
                                            propType = "Integer";
                                        else
                                            propType = "String";

                                        OSAEObjectTypeManager.ObjectTypePropertyAdd(v.Label, propType, "", node.Product, false);
                                    }
                                    else
                                    {
                                        if (v.Genre == ZWValueID.ValueGenre.User)
                                        {
                                            if (v.Label == "Switch" || v.Label == "Level")
                                            {
                                                OSAEObjectTypeManager.ObjectTypeStateAdd("ON", "On", node.Product);
                                                OSAEObjectTypeManager.ObjectTypeStateAdd("OFF", "Off", node.Product);
                                                OSAEObjectTypeManager.ObjectTypeEventAdd("ON", "On", node.Product);
                                                OSAEObjectTypeManager.ObjectTypeEventAdd("OFF", "Off", node.Product);
                                                OSAEObjectTypeManager.ObjectTypeMethodAdd("ON", "On", node.Product, "", "", "", "");
                                                OSAEObjectTypeManager.ObjectTypeMethodAdd("OFF", "Off", node.Product, "", "", "", "");
                                            }
                                            else
                                            {
                                                if (v.Type == ZWValueID.ValueType.Byte || v.Type == ZWValueID.ValueType.Decimal || v.Type == ZWValueID.ValueType.Int)
                                                {
                                                    OSAEObjectTypeManager.ObjectTypeMethodAdd(v.Label, v.Label, node.Product, "Value", "", "", "");
                                                }
                                                else if (v.Type == ZWValueID.ValueType.Button)
                                                {
                                                    OSAEObjectTypeManager.ObjectTypeMethodAdd(v.Label, v.Label, node.Product, "", "", "", "");
                                                }
                                            }
                                        }
                                    }
                                }

                                OSAEObjectManager.ObjectAdd(node.Product + " - Z" + node.ID.ToString(), node.Product, node.Product, "Z" + node.ID.ToString(), "", true);
                                OSAEObjectPropertyManager.ObjectPropertySet(node.Product + " - Z" + node.ID.ToString(), "Home ID", m_homeId.ToString(), pName);
                            }

                        }

                        logging.AddToLog("NodeNaming: Manufacturer: " + node.Manufacturer + " | Product: " + node.Product, true);
                        break;
                    }
                #endregion

                #region NodeNew
                case ZWNotification.Type.NodeNew:
                    {
                        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);
                        }

                        logging.AddToLog("NodeNew: Manufacturer: " + node.Manufacturer + " | Product: " + node.Product, true);
                        break;
                    }
                #endregion

                #region NodeEvent
                case ZWNotification.Type.NodeEvent:
                    {
                        try
                        {
                            Node node = GetNode(m_homeId, m_notification.GetNodeId());
                            if (node != null)
                            {
                                node.Label = m_manager.GetNodeType(m_homeId, node.ID);
                            }
                            logging.AddToLog("GetEvent:" + m_notification.GetEvent().ToString(), false);
                            logging.AddToLog("node.Label:" + node.Label, false);

                            ZWValueID vid = m_notification.GetValueID();
                            Value value = node.GetValue(vid);
                            OSAEObject nodeObject = OSAEObjectManager.GetObjectByAddress("Z" + m_notification.GetNodeId());
                            string v;
                            m_manager.GetValueAsString(vid, out v);
                            value.Val = v;

                            if (m_notification.GetEvent() > 0)
                                OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "ON", "ZWave");
                            else
                                OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "OFF", "ZWave");

                            logging.AddToLog("NodeEvent: " + ((nodeObject != null) ? nodeObject.Name : "Object Not In OSA") + " | node:" + node.ID + " | type: " + value.Type
                            + " | genre: " + value.Genre + " | cmdClsID:" + value.CommandClassID
                            + " | value: " + value.Val + " | label: " + value.Label, false);
                        }
                        catch (Exception ex)
                        {
                            logging.AddToLog("Error in NodeEvent: " + ex.Message, true);
                        }

                        break;
                    }
                #endregion

                #region PollingDisabled
                case ZWNotification.Type.PollingDisabled:
                    {
                        break;
                    }
                #endregion

                #region PollingEnabled
                case ZWNotification.Type.PollingEnabled:
                    {
                        logging.AddToLog("Polling Enabled: " + OSAEObjectManager.GetObjectByAddress("Z" + m_notification.GetNodeId().ToString()).Name, true);
                        break;
                    }
                #endregion

                #region DriverReady
                case ZWNotification.Type.DriverReady:
                    {
                        m_homeId = m_notification.GetHomeId();
                        OSAEObjectPropertyManager.ObjectPropertySet(pName, "Home ID", m_homeId.ToString(), pName);
                        logging.AddToLog("Driver Ready.  Home ID: " + m_homeId.ToString(), true);
                        break;
                    }
                #endregion

                #region DriverReset
                case ZWNotification.Type.DriverReset:
                    {
                        m_homeId = m_notification.GetHomeId();
                        logging.AddToLog("Driver Reset.  Home ID: " + m_homeId.ToString(), true);
                        break;
                    }
                #endregion

                #region NodeQueriesComplete
                case ZWNotification.Type.NodeQueriesComplete:
                    {
                        Node node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId());

                        logging.AddToLog("Node Queries Complete | " + node.ID + " | " + m_manager.GetNodeProductName(m_homeId, node.ID), true);
                        break;
                    }
                #endregion

                #region EssentialNodeQueriesComplete
                case ZWNotification.Type.EssentialNodeQueriesComplete:
                    {
                        Node node = GetNode(m_homeId, m_notification.GetNodeId());
                        logging.AddToLog("Essential Node Queries Completee | " + node.ID + " | " + m_manager.GetNodeProductName(m_homeId, node.ID), true);
                        break;
                    }
                #endregion

                #region AllNodesQueried
                case ZWNotification.Type.AllNodesQueried:
                    {
                        logging.AddToLog("All nodes queried", true);
                        foreach (Node n in m_nodeList)
                        {
                            OSAEObject obj = OSAEObjectManager.GetObjectByAddress("Z" + n.ID.ToString());
                            if (obj != null)
                            {
                                if (OSAEObjectPropertyManager.GetObjectPropertyValue(OSAEObjectManager.GetObjectByAddress("Z" + n.ID.ToString()).Name, "Poll").Value == "TRUE")
                                    enablePolling(n.ID);
                            }
                        }
                        break;
                    }
                #endregion

                #region AwakeNodesQueried
                case ZWNotification.Type.AwakeNodesQueried:
                    {
                        logging.AddToLog("Awake nodes queried (but some sleeping nodes have not been queried)", true);
                        foreach (Node n in m_nodeList)
                        {
                            OSAEObject obj = OSAEObjectManager.GetObjectByAddress("Z" + n.ID.ToString());
                            if (obj != null)
                            {
                                if (OSAEObjectPropertyManager.GetObjectPropertyValue(OSAEObjectManager.GetObjectByAddress("Z" + n.ID.ToString()).Name, "Poll").Value == "TRUE")
                                {
                                    logging.AddToLog("Enabling polling for: " + obj.Name, true);
                                    enablePolling(n.ID);
                                }
                            }
                        }
                        break;
                    }
                #endregion
            }
            logging.AddToLog(" --- ", true);
        }
        private void NotificationHandler()
        {
            Node node2 = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId());

            logging.AddToLog("Notification: " + m_notification.GetType().ToString() + " | Node: " + node2.ID.ToString(), true);
            switch (m_notification.GetType())
            {
                #region ValueAdded
                case ZWNotification.Type.ValueAdded:
                    {

                        Node node = GetNode(m_homeId, m_notification.GetNodeId());
                        Value value = new Value();
                        //logging.AddToLog("ValueAdded start: node:" + node.ID.ToString(), true);
                        ZWValueID vid = m_notification.GetValueID();
                        value.ValueID = vid;
                        value.Label = m_manager.GetValueLabel(vid);
                        value.Genre = vid.GetGenre().ToString();
                        value.Index = vid.GetIndex().ToString();
                        value.Type = vid.GetType().ToString();
                        value.CommandClassID = vid.GetCommandClassId().ToString();
                        switch (node.Label)
                        {
                            case "Binary Switch":
                            case "Binary Power Switch":
                                if (value.Genre == "User")
                                {
                                    bool v;
                                    if (m_manager.GetValueAsBool(vid, out v))
                                        value.Val = v.ToString();
                                }
                                break;
                            case "Multilevel Switch":
                            case "Multilevel Power Switch":
                            case "Multilevel Scene Switch":
                                if (value.Genre == "User" && value.Label == "Level")
                                {
                                    byte v;
                                    if (m_manager.GetValueAsByte(vid, out v))
                                        value.Val = v.ToString();
                                }
                                else if (value.Label == "Power")
                                {
                                    decimal v;
                                    if (m_manager.GetValueAsDecimal(vid, out v))
                                        value.Val = v.ToString();
                                }
                                break;
                            case "General Thermostat V2":
                                if (value.Label == "Temperature")
                                {
                                    decimal v;
                                    if (m_manager.GetValueAsDecimal(vid, out v))
                                        value.Val = v.ToString();
                                }
                                break;
                            case "Routing Multilevel Sensor":
                                if (value.Label == "Temperature")
                                {
                                    decimal v;
                                    if (m_manager.GetValueAsDecimal(vid, out v))
                                        value.Val = v.ToString();
                                }
                                else if (value.Label == "Power")
                                {
                                    decimal v;
                                    if (m_manager.GetValueAsDecimal(vid, out v))
                                        value.Val = v.ToString();
                                }
                                break;
                            case "Routing Binary Sensor":
                                if (value.Label == "Sensor")
                                {
                                    bool v;
                                    if (m_manager.GetValueAsBool(vid, out v))
                                        value.Val = v.ToString();
                                }
                                break;

                        }

                        node.AddValue(value);

                        logging.AddToLog("ValueAdded: node:" + node.ID + " | type: " + value.Type
                            + " | genre: " + value.Genre + " | cmdClsID:" + value.CommandClassID
                            + " | index: " + value.Index + " | instance: " + vid.GetInstance().ToString()
                            + " | readOnly: " + m_manager.IsValueReadOnly(value.ValueID).ToString()
                            + " | value: " + value.Val + " | label: " + m_manager.GetValueLabel(vid), true);
                        break;
                    }
                #endregion

                #region ValueRemoved
                case ZWNotification.Type.ValueRemoved:
                    {
                        try
                        {
                            logging.AddToLog("ValueRemoved: ", true);
                            Node node = GetNode(m_homeId, m_notification.GetNodeId());
                            ZWValueID vid = m_notification.GetValueID();
                            Value val = node.GetValue(vid);
                            node.RemoveValue(val);
                        }
                        catch (Exception ex)
                        {
                            logging.AddToLog("ValueRemoved error: " + ex.Message, true);
                        }
                        break;
                    }
                #endregion

                #region ValueChanged
                case ZWNotification.Type.ValueChanged:
                    {
                        try
                        {
                            Node node = GetNode(m_homeId, m_notification.GetNodeId());
                            logging.AddToLog("ValueChanged start: node:" + node.ID.ToString(), false);
                            ZWValueID vid = m_notification.GetValueID();
                            Value value = node.GetValue(vid);
                            logging.AddToLog("value:" + value.Val, false);
                            OSAEObject nodeObject = OSAEObjectManager.GetObjectByAddress("Z" + m_notification.GetNodeId());
                            string v;
                            m_manager.GetValueAsString(vid, out v);
                            value.Val = v;
                            switch (node.Label)
                            {
                                case "Binary Switch":
                                case "Binary Power Switch":
                                    if (value.Label == "Switch")
                                    {
                                        if (value.Val == "True")
                                            OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "ON", pName);
                                        else
                                            OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "OFF", pName);
                                    }
                                    break;
                                case "Multilevel Switch":
                                case "Multilevel Power Switch":
                                case "Multilevel Scene Switch":
                                    if (value.Label == "Level" || value.Label == "Basic")
                                    {
                                        node.Level = value.Val;
                                        if (Int32.Parse(value.Val) > 0)
                                            OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "ON", pName);
                                        else
                                            OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "OFF", pName);
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, "Level", node.Level, pName);
                                    }
                                    else if (value.Label == "Power")
                                    {
                                        node.Level = value.Val;
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, "Power", node.Level, pName);
                                    }
                                    break;
                                case "General Thermostat V2":
                                    if (value.Label == "Temperature")
                                    {
                                        node.Level = value.Val;
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, "Temperature", node.Level, pName);
                                    }
                                    else if (value.Label == "Operating State")
                                    {
                                        node.Level = value.Val;
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, "Operating Mode", node.Level, pName);
                                    }
                                    else if (value.Label == "Fan State")
                                    {
                                        node.Level = value.Val;
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, "Fan State", node.Level, pName);
                                    }
                                    else if (value.Label == "Fan Mode")
                                    {
                                        node.Level = value.Val;
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, "Fan Mode", node.Level, pName);
                                    }
                                    else if (value.Label == "Heating 1")
                                    {
                                        node.Level = value.Val;
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, "Heat Setpoint", node.Level, pName);
                                    }
                                    else if (value.Label == "Cooling 1")
                                    {
                                        node.Level = value.Val;
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, "Cool Setpoint", node.Level, pName);
                                    }
                                    else if (value.Label == "Battery Level")
                                    {
                                        node.Level = value.Val;
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, "Battery Level", node.Level, pName);
                                    }
                                    else if (value.Label == "Override State")
                                    {
                                        node.Level = value.Val;
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, "Override State", node.Level, pName);
                                    }
                                    break;
                                case "Routing Multilevel Sensor":
                                    if (value.Label == "Temperature")
                                    {
                                        node.Level = value.Val;
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, "Temperature", node.Level, pName);
                                    }
                                    else if (value.Label == "Luminance")
                                    {
                                        node.Level = value.Val;
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, "Luminance", node.Level, pName);
                                    }
                                    else if (value.Label == "Battery Level")
                                    {
                                        node.Level = value.Val;
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, "Battery Level", node.Level, pName);
                                    }
                                    else if (value.Label == "Power")
                                    {
                                        node.Level = value.Val;
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, "Power", node.Level, pName);
                                    }
                                    else if (value.Label == "General")
                                    {
                                        node.Level = value.Val;
                                        if (Int32.Parse(node.Level) == 0)
                                            OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "OFF", pName);
                                        else
                                            OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "ON", pName);
                                    }
                                    break;
                                case "Routing Binary Sensor":
                                    if (value.Label == "Sensor")
                                    {
                                        if (value.Val == "True")
                                            OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "ON", pName);
                                        else
                                            OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "OFF", pName);
                                    }
                                    if (value.Label == "Battery Level")
                                    {
                                        node.Level = value.Val;
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, "Battery Level", node.Level, pName);
                                    }
                                    if (value.Label == "Alarm Level")
                                    {
                                        OSAEObjectPropertyManager.ObjectPropertySet(nodeObject.Name, "Alarm Level", value.Val, pName);
                                    }
                                    break;

                            }

                            logging.AddToLog("ValueChanged: " + ((nodeObject != null) ? nodeObject.Name : "Object Not In OSA") + " | node:"
                                + node.ID + " | nodelabel: " + node.Label + " | type: " + value.Type
                                + " | genre: " + value.Genre + " | cmdClsID:" + value.CommandClassID
                                + " | value: " + value.Val + " | label: " + value.Label, false);

                        }
                        catch (Exception ex)
                        {
                            logging.AddToLog("ValueChanged error: " + ex.Message, true);
                        }
                        break;
                    }
                #endregion

                #region Group
                case ZWNotification.Type.Group:
                    {
                        Node node = GetNode(m_homeId, m_notification.GetNodeId());
                        logging.AddToLog("Group: " + node.ID, true);
                        break;
                    }
                #endregion

                #region NodeAdded
                case ZWNotification.Type.NodeAdded:
                    {
                        // Add the new node to our list
                        Node node = new Node();
                        node.ID = m_notification.GetNodeId();
                        node.HomeID = m_homeId;
                        node.Label = m_manager.GetNodeType(m_homeId, node.ID);
                        m_nodeList.Add(node);

                        logging.AddToLog("NodeAdded: " + node.ID.ToString(), true);
                        break;
                    }
                #endregion

                #region NodeRemoved
                case ZWNotification.Type.NodeRemoved:
                    {
                        foreach (Node node in m_nodeList)
                        {
                            if (node.ID == m_notification.GetNodeId())
                            {
                                m_nodeList.Remove(node);
                                break;
                            }
                        }
                        logging.AddToLog("NodeRemoved: " + m_notification.GetNodeId(), true);
                        break;
                    }
                #endregion

                #region NodeProtocolInfo
                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);
                        }

                        if (OSAEObjectManager.GetObjectByAddress("Z" + node.ID.ToString()) == null)
                        {
                            switch (node.Label)
                            {
                                case "Binary Switch":
                                case "Binary Power Switch":
                                    if (m_manager.GetNodeProductName(m_homeId, node.ID) == "Smart Engery Switch")
                                        OSAEObjectManager.ObjectAdd(node.Label + " - Z" + node.ID.ToString(), node.Label, "ZWAVE SMART ENERGY SWITCH", "Z" + node.ID.ToString(), "", true);
                                    else
                                        OSAEObjectManager.ObjectAdd(node.Label + " - Z" + node.ID.ToString(), node.Label, "ZWAVE BINARY SWITCH", "Z" + node.ID.ToString(), "", true);
                                    OSAEObjectPropertyManager.ObjectPropertySet(node.Label + " - Z" + node.ID.ToString(), "Home ID", node.HomeID.ToString(), pName);
                                    OSAEObjectStateManager.ObjectStateSet(node.Label + " - Z" + node.ID.ToString(), "OFF", pName);
                                    break;
                                case "Multilevel Switch":
                                case "Multilevel Power Switch":
                                case "Multilevel Scene Switch":
                                    if (m_manager.GetNodeProductName(m_homeId, node.ID) == "Smart Energy Illuminator")
                                        OSAEObjectManager.ObjectAdd(node.Label + " - Z" + node.ID.ToString(), node.Label, "ZWAVE SMART ENERGY DIMMER", "Z" + node.ID.ToString(), "", true);
                                    else
                                        OSAEObjectManager.ObjectAdd(node.Label + " - Z" + node.ID.ToString(), node.Label, "ZWAVE DIMMER", "Z" + node.ID.ToString(), "", true);

                                    OSAEObjectPropertyManager.ObjectPropertySet(node.Label + " - Z" + node.ID.ToString(), "Home ID", node.HomeID.ToString(), pName);
                                    OSAEObjectStateManager.ObjectStateSet(node.Label + " - Z" + node.ID.ToString(), "OFF", pName);
                                    break;
                                case "General Thermostat V2":
                                    OSAEObjectManager.ObjectAdd(node.Label + " - Z" + node.ID.ToString(), node.Label, "ZWAVE THERMOSTAT", "Z" + node.ID.ToString(), "", true);
                                    OSAEObjectPropertyManager.ObjectPropertySet(node.Label + " - Z" + node.ID.ToString(), "Home ID", node.HomeID.ToString(), pName);
                                    OSAEObjectStateManager.ObjectStateSet(node.Label + " - Z" + node.ID.ToString(), "OFF", pName);
                                    break;
                                case "Portable Remote Controller":
                                    OSAEObjectManager.ObjectAdd(node.Label + " - Z" + node.ID.ToString(), node.Label, "ZWAVE REMOTE", "Z" + node.ID.ToString(), "", true);
                                    OSAEObjectPropertyManager.ObjectPropertySet(node.Label + " - Z" + node.ID.ToString(), "Home ID", node.HomeID.ToString(), pName);
                                    break;
                                case "Routing Multilevel Sensor":
                                    if (m_manager.GetNodeProductName(m_homeId, node.ID) == "Home Energy Meter")
                                        OSAEObjectManager.ObjectAdd(node.Label + " - Z" + node.ID.ToString(), node.Label, "ZWAVE HOME ENERGY METER", "Z" + node.ID.ToString(), "", true);
                                    else
                                        OSAEObjectManager.ObjectAdd(node.Label + " - Z" + node.ID.ToString(), node.Label, "ZWAVE MULTISENSOR", "Z" + node.ID.ToString(), "", true);

                                    OSAEObjectPropertyManager.ObjectPropertySet(node.Label + " - Z" + node.ID.ToString(), "Home ID", node.HomeID.ToString(), pName);
                                    m_manager.AddAssociation(m_homeId, node.ID, 1, m_manager.GetControllerNodeId(m_homeId));
                                    break;
                                case "Routing Binary Sensor":
                                    OSAEObjectManager.ObjectAdd(node.Label + " - Z" + node.ID.ToString(), node.Label, "ZWAVE BINARY SENSOR", "Z" + node.ID.ToString(), "", true);
                                    OSAEObjectPropertyManager.ObjectPropertySet(node.Label + " - Z" + node.ID.ToString(), "Home ID", node.HomeID.ToString(), pName);
                                    OSAEObjectStateManager.ObjectStateSet(node.Label + " - Z" + node.ID.ToString(), "OFF", pName);
                                    m_manager.AddAssociation(m_homeId, node.ID, 1, m_manager.GetControllerNodeId(m_homeId));
                                    break;
                            }
                        }
                        logging.AddToLog("NodeProtocolInfo: node: " + node.ID + " | " + m_manager.GetNodeType(m_homeId, node.ID), true);

                        break;
                    }
                #endregion

                #region NodeNameing
                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);
                        }

                        logging.AddToLog("NodeNaming: Manufacturer: " + node.Manufacturer + " | Product: " + node.Product, true);
                        break;
                    }
                #endregion

                #region NodeNew
                case ZWNotification.Type.NodeNew:
                    {
                        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);
                        }

                        logging.AddToLog("NodeNew: Manufacturer: " + node.Manufacturer + " | Product: " + node.Product, true);
                        break;
                    }
                #endregion

                #region NodeEvent
                case ZWNotification.Type.NodeEvent:
                    {
                        try
                        {
                            Node node = GetNode(m_homeId, m_notification.GetNodeId());
                            if (node != null)
                            {
                                node.Label = m_manager.GetNodeType(m_homeId, node.ID);
                            }
                            logging.AddToLog("---NodeEvent start: node:" + node.ID.ToString(), false);
                            logging.AddToLog("GetEvent:" + m_notification.GetEvent().ToString(), false);
                            logging.AddToLog("node.Label:" + node.Label, false);

                            ZWValueID vid = m_notification.GetValueID();
                            Value value = node.GetValue(vid);
                            OSAEObject nodeObject = OSAEObjectManager.GetObjectByAddress("Z" + m_notification.GetNodeId());
                            string v;
                            m_manager.GetValueAsString(vid, out v);
                            value.Val = v;

                            switch (node.Label)
                            {
                                case "Routing Binary Sensor":
                                    if (m_notification.GetEvent().ToString() == "255" || m_notification.GetEvent().ToString() == "99")
                                    {
                                        OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "ON", pName);
                                        logging.AddToLog("Sensor turned ON: " + nodeObject.Name, false);
                                    }
                                    else if (m_notification.GetEvent().ToString() == "0")
                                    {
                                        OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "OFF", pName);
                                        logging.AddToLog("Sensor turned OFF: " + nodeObject.Name, false);
                                    }

                                    //if (value.Label == "Sensor")
                                    //{
                                    //    if (value.Val == "True")
                                    //    {
                                    //        OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "ON");
                                    //        logging.AddToLog("Sensor turned ON: " + nodeObject.Name, false);
                                    //    }

                                    //    else
                                    //    {
                                    //        OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "OFF");
                                    //        logging.AddToLog("Sensor turned OFF: " + nodeObject.Name, false);
                                    //    }
                                    //}
                                    break;
                                case "Routing Multilevel Sensor":
                                    if (m_notification.GetEvent().ToString() == "255" || m_notification.GetEvent().ToString() == "99")
                                    {
                                        OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "ON", pName);
                                        logging.AddToLog("Sensor turned ON: " + nodeObject.Name, false);
                                    }
                                    else if (m_notification.GetEvent().ToString() == "0")
                                    {
                                        OSAEObjectStateManager.ObjectStateSet(nodeObject.Name, "OFF", pName);
                                        logging.AddToLog("Sensor turned OFF: " + nodeObject.Name, false);
                                    }
                                    break;
                            }
                            logging.AddToLog("NodeEvent: " + ((nodeObject != null) ? nodeObject.Name : "Object Not In OSA") + " | node:" + node.ID + " | type: " + value.Type
                            + " | genre: " + value.Genre + " | cmdClsID:" + value.CommandClassID
                            + " | value: " + value.Val + " | label: " + value.Label, false);
                        }
                        catch (Exception ex)
                        {
                            logging.AddToLog("Error in NodeEvent: " + ex.Message, true);
                        }

                        break;
                    }
                #endregion

                #region PollingDisabled
                case ZWNotification.Type.PollingDisabled:
                    {
                        break;
                    }
                #endregion

                #region PollingEnabled
                case ZWNotification.Type.PollingEnabled:
                    {
                        logging.AddToLog("Polling Enabled: " + OSAEObjectManager.GetObjectByAddress("Z" + m_notification.GetNodeId().ToString()).Name, true);
                        break;
                    }
                #endregion

                #region DriverReady
                case ZWNotification.Type.DriverReady:
                    {
                        m_homeId = m_notification.GetHomeId();
                        OSAEObjectPropertyManager.ObjectPropertySet(pName, "Home ID", m_homeId.ToString(), pName);
                        logging.AddToLog("Driver Ready.  Home ID: " + m_homeId.ToString(), true);
                        break;
                    }
                #endregion

                #region DriverReset
                case ZWNotification.Type.DriverReset:
                    {
                        m_homeId = m_notification.GetHomeId();
                        logging.AddToLog("Driver Reset.  Home ID: " + m_homeId.ToString(), true);
                        break;
                    }
                #endregion

                #region NodeQueriesComplete
                case ZWNotification.Type.NodeQueriesComplete:
                    {
                        Node node = GetNode(m_notification.GetHomeId(), m_notification.GetNodeId());

                        logging.AddToLog("Node Queries Complete | " + node.ID + " | " + m_manager.GetNodeProductName(m_homeId, node.ID), true);
                        break;
                    }
                #endregion

                #region EssentialNodeQueriesComplete
                case ZWNotification.Type.EssentialNodeQueriesComplete:
                    {
                        Node node = GetNode(m_homeId, m_notification.GetNodeId());
                        logging.AddToLog("Essential Node Queries Completee | " + node.ID + " | " + m_manager.GetNodeProductName(m_homeId, node.ID), true);
                        break;
                    }
                #endregion

                #region AllNodesQueried
                case ZWNotification.Type.AllNodesQueried:
                    {
                        logging.AddToLog("All nodes queried", true);
                        foreach (Node n in m_nodeList)
                        {
                            OSAEObject obj = OSAEObjectManager.GetObjectByAddress("Z" + n.ID.ToString());
                            if (obj != null)
                            {
                                if (OSAEObjectPropertyManager.GetObjectPropertyValue(OSAEObjectManager.GetObjectByAddress("Z" + n.ID.ToString()).Name, "Poll").Value == "TRUE")
                                    enablePolling(n.ID);
                            }
                        }
                        break;
                    }
                #endregion

                #region AwakeNodesQueried
                case ZWNotification.Type.AwakeNodesQueried:
                    {
                        logging.AddToLog("Awake nodes queried (but some sleeping nodes have not been queried)", true);
                        foreach (Node n in m_nodeList)
                        {
                            OSAEObject obj = OSAEObjectManager.GetObjectByAddress("Z" + n.ID.ToString());
                            if (obj != null)
                            {
                                if (OSAEObjectPropertyManager.GetObjectPropertyValue(OSAEObjectManager.GetObjectByAddress("Z" + n.ID.ToString()).Name, "Poll").Value == "TRUE")
                                {
                                    logging.AddToLog("Enabling polling for: " + obj.Name, true);
                                    enablePolling(n.ID);
                                }
                            }
                        }
                        break;
                    }
                #endregion
            }
        }