Esempio n. 1
0
def getTHENValueAndDurationForRecipe(nodeID):
    finalDuration = ""
    strValue = ""
    syntheticNodeID = getSyntheticDeviceIDForRecipe(nodeID)
    print(syntheticNodeID)
    ALAPI.createCredentials(utils.getAttribute('common', 'currentEnvironment'))
    session = ALAPI.sessionObject()
    resp = ALAPI.getNodesV6(session)
    for oNode in resp['nodes']:
        if oNode["id"] in syntheticNodeID:
            tempDuration = oNode["attributes"]["syntheticDeviceConfiguration"][
                "reportedValue"]
            if isinstance(tempDuration, str):
                tempDuration = json.loads(tempDuration)
                print(tempDuration, "\n")
                finalDuration = tempDuration["action"]["duration"]

            oAction = tempDuration["action"]["action"]
            print(oAction, "\n")
            if isinstance(oAction, str):
                print("oAction is string")
            changeList = oAction["changes"]
            for newDict in changeList:
                strValue = newDict["value"]
            return finalDuration, strValue
Esempio n. 2
0
def getDeviceVersions():
    oDeviceVersionDict = {}
    strModel = "'"
    if 'PLATFORM' in utils.getAttribute('common', 'apiValidationType').upper():
        serverName = utils.getAttribute('common', 'currentEnvironment')
        strPlatformVersion = ALAPI.createCredentials(serverName)
        session  = ALAPI.sessionObject()
        if strPlatformVersion == 'V6':
            resp = ALAPI.getNodesV6(session)
            for oNode in resp['nodes']:
                if not 'supportsHotWater'  in oNode['attributes']:
                    if 'hardwareVersion' in oNode['attributes']: 
                        intHardwareVersion = oNode['attributes']['hardwareVersion']['reportedValue']
                        intSoftwareVersion = oNode['attributes']['softwareVersion']['reportedValue']
                        if intHardwareVersion == '00': 
                            if "reportedValue" in oNode['attributes']['model']:
                                strModel =  oNode['attributes']['model']['reportedValue']
                                oDeviceVersionDict['Thermostat'] = strModel + '$$' + intSoftwareVersion
                        elif intHardwareVersion == '01': 
                            if 'reportedValue' in oNode['attributes']['model']: strModel =  oNode['attributes']['model']['reportedValue']
                            oDeviceVersionDict['Boiler Module'] = strModel + '$$' + intSoftwareVersion
                        elif 'NANO' in  intHardwareVersion:
                            oDeviceVersionDict['HUB'] = intHardwareVersion + '$$' + intSoftwareVersion
            ALAPI.deleteSessionV6(session)
            
    return oDeviceVersionDict
 def getFWversion(self):
     ALAPI.createCredentials(self.serverName, self.client)
     session = ALAPI.sessionObject()
     resp = ALAPI.getNodesV6(session)
     oDeviceVersion = {}
     for oNode in resp['nodes']:
         if not 'supportsHotWater' in oNode['attributes']:
             if 'nodeType' in oNode.keys():
                 if 'thermostatui.json' in oNode["nodeType"]:
                     strModel = oNode["attributes"]["model"][
                         "reportedValue"]
                     oDeviceVersion[strModel] = oNode["attributes"][
                         "softwareVersion"]["reportedValue"]
                 elif 'thermostat.json' in oNode["nodeType"]:
                     if 'reportedValue' not in oNode["attributes"]["model"]:
                         strModel = 'SLR2'
                     else:
                         strModel = oNode["attributes"]["model"][
                             "reportedValue"]
                     oDeviceVersion[strModel] = oNode["attributes"][
                         "softwareVersion"]["reportedValue"]
                 elif 'hub.json' in oNode["nodeType"]:
                     strModel = oNode["attributes"]["hardwareVersion"][
                         "reportedValue"]
                     oDeviceVersion[strModel] = oNode["attributes"][
                         "softwareVersion"]["reportedValue"]
                 elif 'smartplug.json' in oNode["nodeType"]:
                     strModel = oNode["attributes"]["model"][
                         "reportedValue"]
                     oDeviceVersion[strModel] = oNode["attributes"][
                         "softwareVersion"]["reportedValue"]
                 elif 'extender.json' in oNode["nodeType"]:
                     strModel = oNode["attributes"]["model"][
                         "reportedValue"]
                     oDeviceVersion[strModel] = oNode["attributes"][
                         "softwareVersion"]["reportedValue"]
                 elif 'light.json' in oNode["nodeType"]:  #LDS_DimmerLight
                     strModel = oNode["attributes"]["model"][
                         "reportedValue"]
                     oDeviceVersion[strModel] = oNode["attributes"][
                         "softwareVersion"]["reportedValue"]
                 elif 'contact.sensor.json' in oNode["nodeType"]:
                     strModel = oNode["attributes"]["model"][
                         "reportedValue"]
                     oDeviceVersion[strModel] = oNode["attributes"][
                         "softwareVersion"]["reportedValue"]
                 elif 'motion.sensor.json' in oNode["nodeType"]:
                     strModel = oNode["attributes"]["model"][
                         "reportedValue"]
                     oDeviceVersion[strModel] = oNode["attributes"][
                         "softwareVersion"]["reportedValue"]
                 elif 'connected.boiler.json' in oNode["nodeType"]:
                     strModel = oNode["attributes"]["model"][
                         "reportedValue"]
                     oDeviceVersion[strModel] = oNode["attributes"][
                         "softwareVersion"]["reportedValue"]
     ALAPI.deleteSessionV6(session)
     return oDeviceVersion
 def upgradeFirware(self, DeviceType, fwTargetVersion):
     ALAPI.createCredentials(self.serverName, self.client)
     session = ALAPI.sessionObject()
     resp = ALAPI.getNodesV6(session)
     nodeIdList = self.getNodeID(resp)
     if DeviceType in nodeIdList:
         nodeId = nodeIdList[DeviceType]
         ALAPI.firmwareUpgrade(session, nodeId, fwTargetVersion)
     else:
         print("Unable to Fetch Node ID for the Given Device Type: " +
               DeviceType)
     ALAPI.deleteSessionV6(session)
Esempio n. 5
0
def getColourBulbValues(nodeID, attributeVerify, attributeName):

    ALAPI.createCredentials(utils.getAttribute('common', 'currentEnvironment'))
    session = ALAPI.sessionObject()
    resp = ALAPI.getNodesV6(session)
    attributeValue = ""
    for oNode in resp['nodes']:
        if nodeID in oNode["id"]:
            attributeValue = oNode["attributes"][attributeVerify][
                attributeName]
            return (attributeValue)
        else:
            continue
 def setModeViaAPI(self,
                   nodeId,
                   setMode,
                   targetHeatTemperature=None,
                   scheduleLockDuration=60):
     ALAPI.createCredentials(self.serverName, self.client)
     session = ALAPI.sessionObject()
     nodeId = self.getChildNodeForBM(ALAPI.getNodesV6(session), nodeId)
     ALAPI.setModeV6(session, nodeId, setMode, targetHeatTemperature,
                     scheduleLockDuration)
     if not 'WATER' in self.type.upper() and 'MANUAL' in setMode:
         ALAPI.setTargTemperatureV6(session, nodeId, targetHeatTemperature)
     ALAPI.deleteSessionV6(session)
Esempio n. 7
0
def getLightBulbAttributes(nodeID):
    ALAPI.createCredentials(utils.getAttribute('common', 'currentEnvironment'))
    session = ALAPI.sessionObject()
    resp = ALAPI.getNodesV6(session)
    lightBulbBrigtness = ""

    for oNode in resp['nodes']:
        if nodeID in oNode["id"]:
            lightBulbBrigtness = getAttribute(oNode["attributes"],
                                              "brightness")
            print(lightBulbBrigtness, "\n")
        else:
            print("Light bulb brightness value is missing")
    return lightBulbBrigtness
Esempio n. 8
0
    def get_device_details(self):
        env = utils.getAttribute('common', 'currentEnvironment')
        username = utils.getAttribute('common', 'userName')
        password = utils.getAttribute('common', 'password')
        ALAPI.createCredentials(env, username=username, password=password)
        self.session = ALAPI.sessionObject()
        resp = ALAPI.getNodesV6(self.session)
        oDeviceVersionDict = {}
        strSLTMacID = ""
        strSLRMacID = ""
        for oNode in resp['nodes']:
            if not 'supportsHotWater' in oNode['attributes']:
                if 'hardwareVersion' in oNode['attributes']:
                    intHardwareVersion = oNode['attributes'][
                        'hardwareVersion']['reportedValue']
                    intSoftwareVersion = oNode['attributes'][
                        'softwareVersion']['reportedValue']
                    if 'NANO' in intHardwareVersion:
                        oDeviceVersionDict['HUB'] = {
                            "model": intHardwareVersion,
                            "version": intSoftwareVersion
                        }
                if 'zigBeeNeighbourTable' in oNode['attributes']:
                    for oDevice in oNode['attributes']['zigBeeNeighbourTable'][
                            'reportedValue']:
                        if 'relationship' in oDevice:
                            if oDevice['relationship'] == 'CHILD':
                                strSLTMacID = oDevice['neighbourAddress']
                            elif oDevice['relationship'] == 'NONE':
                                strSLRMacID = oDevice['neighbourAddress']

        for oNode in resp['nodes']:
            if not 'supportsHotWater' in oNode['attributes']:
                if 'model' in oNode['attributes']:
                    strModel = oNode['attributes']['model']['reportedValue']
                    intSoftwareVersion = oNode['attributes'][
                        'softwareVersion']['reportedValue']
                    if 'SLT' in strModel:
                        oDeviceVersionDict['Thermostat'] = {
                            "model": strModel,
                            "version": intSoftwareVersion,
                            'mac_id': strSLTMacID
                        }
                    elif 'SLR' in strModel:
                        oDeviceVersionDict['Boiler Module'] = {
                            "model": strModel,
                            "version": intSoftwareVersion,
                            'mac_id': strSLRMacID
                        }
        return oDeviceVersionDict
Esempio n. 9
0
 def get_response(self):
     ALAPI.createCredentials(self.Environment.get(), username = self.UserName.get(), password = self.Password.get())
     self.session = ALAPI.sessionObject()
     if self.session.statusCode != 200:
         resp =self.session.response
         if isinstance(resp, str): resp = json.loads(resp)
         return resp
     if self.session.latestSupportedApiVersion != '6':
         self.platformVersion = 'V5'
         print("hello")
         self.Response.insert(1.0, 'User is V5. Retry with V6 User')
         return False
     else:
         self.platformVersion = 'V6'
         
         resp = ALAPI.getNodesV6(self.session)
        
         oDeviceVersionDict = {}
         strSLTMacID = ""
         strSLRMacID = ""
         for oNode in resp['nodes']:
             if not 'supportsHotWater'  in oNode['attributes']:
                 if 'hardwareVersion' in oNode['attributes']: 
                     intHardwareVersion = oNode['attributes']['hardwareVersion']['reportedValue']
                     intSoftwareVersion = oNode['attributes']['softwareVersion']['reportedValue']
                     if 'NANO' in  intHardwareVersion:
                         #oDeviceVersionDict['HUB'] = intHardwareVersion + '$$' + intSoftwareVersion
                         oDeviceVersionDict['HUB'] = {"model" : intHardwareVersion, "version" : intSoftwareVersion}
                 if 'zigBeeNeighbourTable' in oNode['attributes']:
                     for oDevice in oNode['attributes']['zigBeeNeighbourTable']['reportedValue']:
                         if oDevice['relationship'] == 'CHILD':
                             strSLTMacID = oDevice['neighbourAddress']
                         elif oDevice['relationship'] == 'NONE':
                             strSLRMacID = oDevice['neighbourAddress']
                                 
         for oNode in resp['nodes']:
             if not 'supportsHotWater'  in oNode['attributes']:
                 if 'model' in oNode['attributes']: 
                     strModel = oNode['attributes']['model']['reportedValue']
                     intSoftwareVersion = oNode['attributes']['softwareVersion']['reportedValue']                            
                     if 'SLT' in strModel: 
                         #oDeviceVersionDict['Thermostat'] = strModel + '$$' + intSoftwareVersion
                         oDeviceVersionDict['Thermostat'] = {"model" : strModel, "version" : intSoftwareVersion, 'mac_id': strSLTMacID}
                     elif'SLR' in strModel: 
                         #oDeviceVersionDict['Boiler Module'] = strModel + '$$' + intSoftwareVersion
                         oDeviceVersionDict['Boiler Module'] = {"model" : strModel, "version" : intSoftwareVersion, 'mac_id': strSLRMacID}
         oDeviceVersionDict['credentials'] = {"username": self.UserName.get(), "password":self.Password.get()}
         return oDeviceVersionDict
def getSyntheticDeviceID(nodeID):
    ALAPI.createCredentials(utils.getAttribute('common', 'currentEnvironment'))
    session = ALAPI.sessionObject()
    resp = ALAPI.getNodesV6(session)
    strSyntheticDeviceID = ""
    for oNode in resp['nodes']:
        if "nodeType" in oNode:
            if '.json' in oNode["nodeType"] and "consumers" in oNode[
                    "attributes"]:
                strConsumersID = oNode["attributes"]["consumers"][
                    "reportedValue"]
                print("strConsumersID", strConsumersID)
                if nodeID in strConsumersID:
                    strSyntheticDeviceID = oNode["id"]
                    break
    ALAPI.deleteSessionV6(session)
    return strSyntheticDeviceID
def getSPAttributes(nodeID):
    strMode = ""
    strState = ""
    syntheticNodeID = getSyntheticDeviceID(nodeID)
    ALAPI.createCredentials(utils.getAttribute('common', 'currentEnvironment'))
    session = ALAPI.sessionObject()
    resp = ALAPI.getNodesV6(session)
    for oNode in resp['nodes']:
        if nodeID in oNode["id"]:
            strState = getAttribute(oNode["attributes"], "state")
        elif oNode["id"] in syntheticNodeID:
            if getAttribute(
                    oNode["attributes"]["syntheticDeviceConfiguration"],
                    "enabled").upper() == "TRUE":
                strMode = "AUTO"
                strMode = "MANUAL"

    return strMode, strState
Esempio n. 12
0
def getCSAttributes(nodeID):
    finalCSState = ""
    #syntheticNodeID = getSyntheticDeviceID(nodeID)
    ALAPI.createCredentials(utils.getAttribute('common', 'currentEnvironment'))
    session = ALAPI.sessionObject()
    resp = ALAPI.getNodesV6(session)
    for oNode in resp['nodes']:
        #if "nodeType" in oNode:
        #if '.json' in oNode["nodeType"]:
        if nodeID in oNode["id"]:
            finalCSState = getAttribute(oNode["attributes"], "state")
            #if nodeID in oNode["id"]:
            #finalState = getAttribute(oNode["attributes"], "state")
            print('Reported state for contact sensor is' + finalCSState)
        else:
            print('Reported state for contact sensor is missing')

    return finalCSState
Esempio n. 13
0
def getColourTemprature(nodeID):
    ALAPI.createCredentials(utils.getAttribute('common', 'currentEnvironment'))
    session = ALAPI.sessionObject()
    resp = ALAPI.getNodesV6(session)
    reportedValue = ""
    targetValue = ""

    for oNode in resp['nodes']:
        if nodeID in oNode["id"]:
            reportedValue = getAttribute(oNode["attributes"],
                                         "colourTemperature")
            targetValue = getAttribute(oNode["attributes"],
                                       "colourTemperature")
            print(reportedValue, "\n")
            print(targetValue, "\n")
        else:
            print("Light bulb brightness value is missing")
    return reportedValue, targetValue
 def getFWversion(self, resp):
     ALAPI.createCredentials(self.Environment.get())
     session = ALAPI.sessionObject()
     resp = ALAPI.getNodesV6(session)
     oDeviceVersion = {}
     for oNode in resp['nodes']:
         if not 'supportsHotWater' in oNode['attributes']:
             if 'thermostatui.json' in oNode["nodeType"]:
                 strModel = oNode["attributes"]["model"]["reportedValue"]
                 oDeviceVersion[strModel] = oNode["attributes"][
                     "softwareVersion"]["reportedValue"]
             elif 'thermostat.json' in oNode["nodeType"]:
                 strModel = oNode["attributes"]["model"]["reportedValue"]
                 oDeviceVersion[strModel] = oNode["attributes"][
                     "softwareVersion"]["reportedValue"]
             elif 'hub.json' in oNode["nodeType"]:
                 strModel = oNode["attributes"]["hardwareVersion"][
                     "reportedValue"]
                 oDeviceVersion[strModel] = oNode["attributes"][
                     "softwareVersion"]["reportedValue"]
             elif 'smartplug.json' in oNode["nodeType"]:
                 strModel = oNode["attributes"]["model"]["reportedValue"]
                 oDeviceVersion[strModel] = oNode["attributes"][
                     "softwareVersion"]["reportedValue"]
             elif 'extender.json' in oNode["nodeType"]:
                 strModel = oNode["attributes"]["model"]["reportedValue"]
                 oDeviceVersion[strModel] = oNode["attributes"][
                     "softwareVersion"]["reportedValue"]
             elif 'contact.sensor.json' in oNode["nodeType"]:
                 strModel = oNode["attributes"]["model"]["reportedValue"]
                 oDeviceVersion[strModel] = oNode["attributes"][
                     "softwareVersion"]["reportedValue"]
             elif 'motion.sensor.json' in oNode["nodeType"]:
                 strModel = oNode["attributes"]["model"]["reportedValue"]
                 oDeviceVersion[strModel] = oNode["attributes"][
                     "softwareVersion"]["reportedValue"]
             elif 'connected.boiler.json' in oNode["nodeType"]:
                 strModel = oNode["attributes"]["model"]["reportedValue"]
                 oDeviceVersion[strModel] = oNode["attributes"][
                     "softwareVersion"]["reportedValue"]
     ALAPI.deleteSessionV6(session)
     return oDeviceVersion
Esempio n. 15
0
def getNodeAndDeviceVersionID():
    ALAPI.createCredentials(utils.getAttribute('common', 'currentEnvironment'))
    session = ALAPI.sessionObject()
    resp = ALAPI.getNodesV6(session)
    oDeviceDetails = {}
    for oNode in resp['nodes']:
        if ('supportsHotWater'
                not in oNode['attributes']) and "nodeType" in oNode:
            if '.json' in oNode["nodeType"] and "model" in oNode["attributes"]:
                if "reportedValue" in oNode["attributes"]["model"]:
                    strModel = oNode["attributes"]["model"]["reportedValue"]
                    strModelTemp = strModel
                    intDeviceCntr = 0
                    while True:
                        intDeviceCntr = intDeviceCntr + 1
                        strModel = strModelTemp + "_" + str(intDeviceCntr)
                        if strModel in oDeviceDetails: continue
                        else: break

                    oDeviceDetails[strModel] = {}
                    strName = ""
                    oDeviceDetails[strModel]["nodeID"] = oNode["id"]
                    if "name" in oNode: strName = oNode["name"]
                    oDeviceDetails[strModel]["name"] = strName
                    oDeviceDetails[strModel]["version"] = oNode["attributes"][
                        "softwareVersion"]["reportedValue"]
                    oDeviceDetails[strModel]["presence"] = oNode["attributes"][
                        "presence"]["reportedValue"]
            elif "hardwareVersion" in oNode["attributes"]:
                strHubModel = oNode["attributes"]["hardwareVersion"][
                    "reportedValue"]
                if "NANO" in strHubModel:
                    oDeviceDetails[strHubModel] = {}
                    oDeviceDetails[strHubModel]["nodeID"] = oNode["id"]
                    oDeviceDetails[strHubModel]["version"] = oNode[
                        "attributes"]["softwareVersion"]["reportedValue"]
                    oDeviceDetails[strHubModel]["presence"] = oNode[
                        "attributes"]["presence"]["reportedValue"]
    ALAPI.deleteSessionV6(session)
    return oDeviceDetails
def upgrade_downgrade_firmware_forallViaHUB(context):
    print("ViaHub\n")

    oHeatScheduleDict = {
        'sat': [('07:00', 28.5), ('09:00', 10.5), ('16:30', 23.5),
                ('22:00', 15), ('22:00', 15), ('22:00', 15)],
        'sun': [('01:00', 27.5), ('02:00', 1), ('03:00', 12), ('04:00', 1),
                ('05:00', 28.5), ('23:45', 1)],
        'fri': [('17:30', 1), ('18:00', 11), ('18:30', 28), ('19:00', 1),
                ('19:30', 29), ('20:00', 1)],
        'wed': [('06:30', 29.5), ('08:30', 13), ('12:00', 19), ('16:30', 22.5),
                ('22:00', 31), ('22:00', 31)],
        'mon': [('11:30', 27.5), ('11:45', 1), ('12:00', 12), ('12:15', 1),
                ('12:30', 28.5), ('12:45', 1)],
        'tue': [('06:30', 20), ('08:30', 10), ('16:30', 20), ('22:00', 10),
                ('22:00', 10), ('22:00', 10)],
        'thu': [('06:30', 20), ('08:30', 18.5), ('16:30', 27), ('22:00', 21),
                ('22:00', 21), ('22:00', 21)]
    }

    oAtributeDict = {
        'HeatMode': '',
        'WaterMode': '',
        'HeatTemperature': '',
        'HeatRunningState': '',
        'WaterRuningState': '',
        'HeatSchedule': '',
        'WaterSchedule': ''
    }

    oModeList = ['MANUAL', 'AUTO', 'OFF', 'BOOST']

    #get node lists
    ALAPI.createCredentials(utils.getAttribute('common', 'currentEnvironment'))
    session = ALAPI.sessionObject()
    resp = ALAPI.getNodesV6(session)
    nodeIdList = context.oThermostatEP.getNodeID(resp)
    ALAPI.deleteSessionV6(session)

    #Get the existing API details
    context.heatEP = context.oThermostatClass.heatEP
    context.waterEP = context.oThermostatClass.waterEP

    intModeListCntr = 0
    intCntr = 0
    while True:
        intCntr = intCntr + 1
        context.reporter.HTML_TC_BusFlowKeyword_Initialize(
            'Upgrade-Downgrade Counter : ' + str(intCntr))
        for oRow in context.table:
            DeviceName = oRow['DeviceName']
            DeviceType = oRow['DeviceType']
            DeviceVersion1 = oRow['DeviceVersion1']
            DeviceVersion2 = oRow['DeviceVersion2']
            print(DeviceName, DeviceType, DeviceVersion1, DeviceVersion2, "\n")

            strModeToSet = ""
            targetHeatTemperature = 0.0
            scheduleLockDuration = 0
            oSchedule = {}
            if 'SLR' in DeviceType.upper():
                strModeToSet = oModeList[intModeListCntr]
                targetHeatTemperature = 1.0
                scheduleLockDuration = 0
                if 'BOOST' in strModeToSet:
                    targetHeatTemperature = 22.0
                    scheduleLockDuration = 60
                if 'MANUAL' in strModeToSet:
                    targetHeatTemperature = 20.0

                context.heatEP.setModeViaAPI(nodeIdList[DeviceType],
                                             strModeToSet,
                                             targetHeatTemperature,
                                             scheduleLockDuration)
                heatWeeklyScheduleBefore = context.heatEP.getSchedule()
                if 'SLR2' in DeviceType.upper():
                    context.waterEP.setModeViaAPI(
                        nodeIdList[DeviceType],
                        strModeToSet,
                        targetHeatTemperature=None,
                        scheduleLockDuration=scheduleLockDuration)
                    waterWeeklyScheduleBefore = context.waterEP.getSchedule()

                intModeListCntr = intModeListCntr + 1
                if intModeListCntr == 4: intModeListCntr = 0

            if not os.path.exists(context.networkBasePath):
                print("Network drive is not mounted")

            #Downgrade device
            if not 'NA' in DeviceVersion1.upper():
                context.rFM.upgrade_or_downgrade_firmwareViaHUB(
                    context.oThermostatEP, context.reporter, "Downgrade",
                    DeviceType, DeviceVersion1)
                if 'SLT3' in DeviceType.upper():
                    #time.sleep(6000)
                    #power_cycle_hub()
                    print(strModeToSet)
                else:
                    if 'CL01' in DeviceType.upper():
                        if context.rFM.verifyfirmwareVersionsViaHUB(
                                context.oThermostatEP, context.reporter,
                                "Downgrade", DeviceType,
                                DeviceVersion1) == True:
                            #time.sleep(12000)
                            print()
                    else:
                        if context.rFM.verifyfirmwareVersionsViaHUB(
                                context.oThermostatEP, context.reporter,
                                "Downgrade", DeviceType,
                                DeviceVersion1) == True:
                            #time.sleep(2500)
                            print(strModeToSet)
                context.rFM.validate_firmware_versionViaHUB(
                    context.oThermostatEP, context.reporter, "Downgrade",
                    DeviceType, DeviceVersion1)

                if 'SLR' in DeviceType.upper():
                    if 'AUTO' in strModeToSet:
                        targetHeatTemperature = oSchdUt.getCurrentTempFromSchedule(
                            context.heatEP.getSchedule())[0]
                    heatWeeklyScheduleAfter = context.heatEP.getSchedule()
                    context.rFM.validateAndUpdateLog(context.reporter,
                                                     context.heatEP, 'Test',
                                                     strModeToSet,
                                                     targetHeatTemperature)

                    oSchdUt.validateSchedulesOfOtherWeekdays(
                        context.reporter, oSchedule, heatWeeklyScheduleBefore,
                        heatWeeklyScheduleAfter)
                    if 'SLR2' in DeviceType.upper():
                        if 'AUTO' in strModeToSet:
                            targetHeatTemperature = oSchdUt.getCurrentTempFromSchedule(
                                context.waterEP.getSchedule())[0]
                        context.rFM.validateAndUpdateLog(
                            context.reporter, context.waterEP, 'Test',
                            strModeToSet, targetHeatTemperature)
                        waterWeeklyScheduleAfter = context.waterEP.getSchedule(
                        )

                        waterWeeklyScheduleBefore = oSchdUt.converWaterStateForSchedule(
                            waterWeeklyScheduleBefore)
                        waterWeeklyScheduleAfter = oSchdUt.converWaterStateForSchedule(
                            waterWeeklyScheduleAfter)
                        oSchdUt.validateSchedulesOfOtherWeekdays(
                            context.reporter, oSchedule,
                            waterWeeklyScheduleBefore,
                            waterWeeklyScheduleAfter)
                time.sleep(30)

            #Upgrade Device
            if not 'NA' in DeviceVersion2.upper():
                context.rFM.upgrade_or_downgrade_firmwareViaHUB(
                    context.oThermostatEP, context.reporter, "Upgrade",
                    DeviceType, DeviceVersion2)
                if 'SLT3' in DeviceType.upper():
                    #time.sleep(6000)
                    #power_cycle_hub()
                    print()
                else:
                    if 'CL01' in DeviceType.upper():
                        if context.rFM.verifyfirmwareVersionsViaHUB(
                                context.oThermostatEP, context.reporter,
                                "Upgrade", DeviceType, DeviceVersion1) == True:
                            #time.sleep(12000)
                            print()
                    else:
                        if context.rFM.verifyfirmwareVersionsViaHUB(
                                context.oThermostatEP, context.reporter,
                                "Upgrade", DeviceType, DeviceVersion2) == True:
                            #time.sleep(2500)
                            print()
                context.rFM.validate_firmware_versionViaHUB(
                    context.oThermostatEP, context.reporter, "Upgrade",
                    DeviceType, DeviceVersion2)
                if 'SLR' in DeviceType.upper():
                    if 'AUTO' in strModeToSet:
                        targetHeatTemperature = oSchdUt.getCurrentTempFromSchedule(
                            context.heatEP.getSchedule())[0]
                    heatWeeklyScheduleAfter = context.heatEP.getSchedule()
                    context.rFM.validateAndUpdateLog(context.reporter,
                                                     context.heatEP, 'Test',
                                                     strModeToSet,
                                                     targetHeatTemperature)

                    oSchdUt.validateSchedulesOfOtherWeekdays(
                        context.reporter, oSchedule, heatWeeklyScheduleBefore,
                        heatWeeklyScheduleAfter)
                    if 'SLR2' in DeviceType.upper():
                        if 'AUTO' in strModeToSet:
                            targetHeatTemperature = oSchdUt.getCurrentTempFromSchedule(
                                context.waterEP.getSchedule())[0]
                        context.rFM.validateAndUpdateLog(
                            context.reporter, context.waterEP, 'Test',
                            strModeToSet, targetHeatTemperature)
                        waterWeeklyScheduleAfter = context.waterEP.getSchedule(
                        )

                        waterWeeklyScheduleBefore = oSchdUt.converWaterStateForSchedule(
                            waterWeeklyScheduleBefore)
                        waterWeeklyScheduleAfter = oSchdUt.converWaterStateForSchedule(
                            waterWeeklyScheduleAfter)
                        oSchdUt.validateSchedulesOfOtherWeekdays(
                            context.reporter, oSchedule,
                            waterWeeklyScheduleBefore,
                            waterWeeklyScheduleAfter)

        context.reporter.intIterationCntr = context.reporter.intIterationCntr + 1
    def _updateV6(self, nodeID=None):
        #Updating attributes for Light
        print("self.deviceType.upper()", self.deviceType.upper())
        if "FWBULB" in self.deviceType.upper():
            self.currentDeviceNodeId = pUtils.getDeviceNodeID(self.deviceType)
            self.mode, self.CurrentDeviceState, self.activeLightBrightness = pUtils.getLightAttributes(
                self.currentDeviceNodeId)
            self._weeklySchedule = pUtils.getDeviceScheduleInStandardFormat(
                self.deviceType)
            print(self._weeklySchedule)
            return True

        ALAPI.createCredentials(self.serverName, self.client)
        session = ALAPI.sessionObject()
        if session.latestSupportedApiVersion != '6':
            self.platformVersion = 'V5'
            print("V5")
            return False
        else:
            self.platformVersion = 'V6'

            resp = ALAPI.getNodesV6(session)
            if self.type == 'HEAT':
                boolWater = False
            else:
                boolWater = True
            for oNode in resp['nodes']:
                if not nodeID is None:
                    if not oNode['parentNodeId'] == nodeID: continue
                if 'supportsHotWater' in oNode['attributes']:
                    if oNode['attributes']['supportsHotWater'][
                            'reportedValue'] == True and 'stateHotWaterRelay' in oNode[
                                'attributes']:
                        if boolWater:
                            print("water")
                            oAttributeList = oNode['attributes']
                            #oJson = oAttributeList['schedule']['reportedValue']
                            oJson = self.getAttribute(oAttributeList,
                                                      'schedule')
                            if isinstance(oJson, str):
                                oJson = json.loads(oJson)
                            self._weeklySchedule = self._formatScheduleV6(
                                oJson)
                            #print('%%%%%%%%%%%^^^^^^^^^^^^^^^^^', oJson)
                            strRunningState = self.getAttribute(
                                oAttributeList, 'stateHotWaterRelay')
                            if strRunningState == 'OFF':
                                self.thermostatRunningState = '0000'
                            else:
                                self.thermostatRunningState = '0001'

                            strActiveHeatCoolMode = self.getAttribute(
                                oAttributeList, 'activeHeatCoolMode')
                            boolActiveScheduleLock = self.getAttribute(
                                oAttributeList, 'activeScheduleLock')
                            lstActiveOverrides = self.getAttribute(
                                oAttributeList, 'activeOverrides')

                            if strActiveHeatCoolMode == 'OFF':
                                self.mode = 'OFF'
                            elif strActiveHeatCoolMode == 'HEAT' and boolActiveScheduleLock:
                                self.mode = 'MANUAL'
                            elif strActiveHeatCoolMode == 'HEAT' and not boolActiveScheduleLock:
                                self.mode = 'AUTO'
                            elif strActiveHeatCoolMode == 'BOOST':
                                self.mode = 'BOOST'
                            elif len(lstActiveOverrides
                                     ) > 0 and lstActiveOverrides[
                                         0] == "TARGET_HEAT_TEMPERATURE":
                                self.mode = 'OVERRIDE'
                            '''    
                            print(self._weeklySchedule)
                            print(self.mode)
                            print(self.thermostatRunningState)
                            '''
                    else:
                        if not boolWater and 'stateHeatingRelay' in oNode[
                                'attributes']:
                            print('Heat')
                            oAttributeList = oNode['attributes']
                            #oJson = oAttributeList['schedule']['reportedValue']
                            oJson = self.getAttribute(oAttributeList,
                                                      'schedule')
                            if isinstance(oJson, str):
                                oJson = json.loads(oJson)
                            self._weeklySchedule = self._formatScheduleV6(
                                oJson)
                            strRunningState = self.getAttribute(
                                oAttributeList, 'stateHeatingRelay')
                            if strRunningState == 'OFF':
                                self.thermostatRunningState = '0000'
                            else:
                                self.thermostatRunningState = '0001'
                            if self.occupiedHeatingSetpointChanged:
                                occupiedHeatingSetpoint = self.getAttribute(
                                    oAttributeList, 'targetHeatTemperature')
                            self.occupiedHeatingSetpoint = float(
                                '{:.1f}'.format(
                                    oAttributeList['targetHeatTemperature']
                                    ['reportedValue']))

                            self.localTemperature = self.getAttribute(
                                oAttributeList, 'temperature')

                            strActiveHeatCoolMode = self.getAttribute(
                                oAttributeList, 'activeHeatCoolMode')
                            boolActiveScheduleLock = self.getAttribute(
                                oAttributeList, 'activeScheduleLock')
                            lstActiveOverrides = self.getAttribute(
                                oAttributeList, 'activeOverrides')

                            if strActiveHeatCoolMode == 'OFF':
                                self.mode = 'OFF'
                            elif strActiveHeatCoolMode == 'HEAT' and boolActiveScheduleLock:
                                self.mode = 'MANUAL'
                            elif strActiveHeatCoolMode == 'HEAT' and not boolActiveScheduleLock:
                                self.mode = 'AUTO'
                            elif strActiveHeatCoolMode == 'BOOST':
                                self.mode = 'BOOST'
                            elif len(lstActiveOverrides
                                     ) > 0 and lstActiveOverrides[
                                         0] == "TARGET_HEAT_TEMPERATURE":
                                self.mode = 'OVERRIDE'
                            '''
                            print(self._weeklySchedule)
                            print(self.mode)
                            print(self.occupiedHeatingSetpoint)
                            print(self.thermostatRunningState)
                            print(self.localTemperature)
                            '''
            ALAPI.deleteSessionV6(session)
            return True
Esempio n. 18
0
def getNodes():
    ALAPI.createCredentials(utils.getAttribute('common', 'currentEnvironment'))
    session = ALAPI.sessionObject()
    nodes = ALAPI.getNodesV6(session)
    ALAPI.deleteSessionV6(session)
    return nodes
    def get_response(self):
        ALAPI.createCredentials(self.Environment.get())
        self.session = ALAPI.sessionObject()
        if self.session.latestSupportedApiVersion != '6':
            self.platformVersion = 'V5'
            print("hello")
            self.Response.insert(1.0, 'User is V5. Retry with V6 User')
            return False
        else:
            self.platformVersion = 'V6'

            if self.Node.get() == 'Notifications':
                respRules = ALAPI.getRulesV6(self.session)
                return respRules

            resp = ALAPI.getNodesV6(self.session)
            if 'HEAT' in self.EndPoint.get().upper():
                boolWater = False
            else:
                boolWater = True

            if self.Node.get() == 'Holiday Mode':
                oHolDict = {}
                for oNode in resp['nodes']:
                    if 'holidayMode' in oNode['attributes']:
                        oHolDict['holidayMode'] = oNode['attributes'][
                            'holidayMode']
                    if 'holidayModeEnabled' in oNode['attributes']:
                        oHolDict['holidayModeEnabled'] = oNode['attributes'][
                            'holidayModeEnabled']
                    if 'holidayModeActive' in oNode['attributes']:
                        oHolDict['holidayModeActive'] = oNode['attributes'][
                            'holidayModeActive']
                return oHolDict

            if self.Node.get() == 'All':
                return resp

            if self.Node.get() == 'Kit Versions':
                print(self.getNodeID(resp))
                print(self.getFWversion(resp))
                oDeviceVersionDict = {}
                strSLTMacID = ""
                strSLRMacID = ""
                for oNode in resp['nodes']:
                    if not 'supportsHotWater' in oNode['attributes']:
                        if 'hardwareVersion' in oNode['attributes']:
                            intHardwareVersion = oNode['attributes'][
                                'hardwareVersion']['reportedValue']
                            intSoftwareVersion = oNode['attributes'][
                                'softwareVersion']['reportedValue']
                            if 'NANO' in intHardwareVersion:
                                #oDeviceVersionDict['HUB'] = intHardwareVersion + '$$' + intSoftwareVersion
                                #strHubMacId = oNode['attributes']['zigBeeNeighbourTable']['reportedValue'][0]['neighbourAddress']
                                oDeviceVersionDict['HUB'] = {
                                    "model": intHardwareVersion,
                                    "version": intSoftwareVersion
                                }  #,  'mac_id': strHubMacId}
                        if 'zigBeeNeighbourTable' in oNode['attributes']:
                            for oDevice in json.loads(
                                    oNode['attributes']['zigBeeNeighbourTable']
                                ['reportedValue']):
                                if oDevice['relationship'] == 'CHILD':
                                    strSLTMacID = oDevice['neighbourAddress']
                                elif oDevice['relationship'] == 'NONE':
                                    strSLRMacID = oDevice['neighbourAddress']

                for oNode in resp['nodes']:
                    if not 'supportsHotWater' in oNode['attributes']:
                        if 'model' in oNode['attributes']:
                            strModel = oNode['attributes']['model'][
                                'reportedValue']
                            intSoftwareVersion = oNode['attributes'][
                                'softwareVersion']['reportedValue']
                            if 'SLT' in strModel:
                                #oDeviceVersionDict['Thermostat'] = strModel + '$$' + intSoftwareVersion
                                oDeviceVersionDict['Thermostat'] = {
                                    "model": strModel,
                                    "version": intSoftwareVersion,
                                    'mac_id': strSLTMacID
                                }
                            elif 'SLR' in strModel:
                                #oDeviceVersionDict['Boiler Module'] = strModel + '$$' + intSoftwareVersion
                                oDeviceVersionDict['Boiler Module'] = {
                                    "model": strModel,
                                    "version": intSoftwareVersion,
                                    'mac_id': strSLRMacID
                                }
                return oDeviceVersionDict

            for oNode in resp['nodes']:
                if 'supportsHotWater' in oNode['attributes']:
                    if oNode['attributes']['supportsHotWater'][
                            'reportedValue'] == True and 'stateHotWaterRelay' in oNode[
                                'attributes']:
                        if boolWater:
                            print("water")
                            oAttributeList = oNode['attributes']

                            if self.Node.get() == 'Schedule':
                                oSchedDict = {}
                                oJsonAll = oAttributeList['schedule']
                                for oKey in oJsonAll:
                                    oJson = oJsonAll[oKey]
                                    if oKey == 'targetValue' or oKey == 'reportedValue':
                                        if isinstance(oJson, str):
                                            oJson = json.loads(oJson)
                                    oSchedDict[oKey] = oJson
                                return {"schedule": oSchedDict}

                            elif self.Node.get() == 'Running State':
                                return {
                                    "stateHotWaterRelay":
                                    oAttributeList['stateHotWaterRelay']
                                }
                            elif self.Node.get() == 'Mode':
                                strActiveHeatCoolMode = self.getAttribute(
                                    oAttributeList, 'activeHeatCoolMode')
                                boolActiveScheduleLock = self.getAttribute(
                                    oAttributeList, 'activeScheduleLock')
                                print(boolActiveScheduleLock,
                                      'boolActiveScheduleLock')
                                lstActiveOverrides = self.getAttribute(
                                    oAttributeList, 'activeOverrides')

                                if strActiveHeatCoolMode == 'OFF':
                                    self.mode = 'OFF'
                                elif strActiveHeatCoolMode == 'HEAT' and boolActiveScheduleLock:
                                    self.mode = 'MANUAL'
                                elif len(lstActiveOverrides
                                         ) > 0 and lstActiveOverrides[
                                             0] == "TARGET_HEAT_TEMPERATURE":
                                    self.mode = 'OVERRIDE'
                                elif strActiveHeatCoolMode == 'HEAT' and not boolActiveScheduleLock:
                                    self.mode = 'AUTO'
                                elif strActiveHeatCoolMode == 'BOOST':
                                    self.mode = 'BOOST'

                                return {
                                    "currentMode":
                                    self.mode,
                                    "activeHeatCoolMode":
                                    oAttributeList['activeHeatCoolMode'],
                                    "activeScheduleLock":
                                    oAttributeList['activeScheduleLock'],
                                    "activeOverrides":
                                    oAttributeList['activeOverrides'],
                                    "scheduleLockDuration":
                                    oAttributeList["scheduleLockDuration"],
                                    "stateHotWaterRelay":
                                    oAttributeList['stateHotWaterRelay']
                                }

                    else:
                        if not boolWater and 'stateHeatingRelay' in oNode[
                                'attributes']:
                            print('Heat')
                            oAttributeList = oNode['attributes']

                            if self.Node.get() == 'Schedule':
                                oSchedDict = {}
                                oJsonAll = oAttributeList['schedule']
                                for oKey in oJsonAll:
                                    oJson = oJsonAll[oKey]
                                    if oKey == 'targetValue' or oKey == 'reportedValue':
                                        if isinstance(oJson, str):
                                            oJson = json.loads(oJson)
                                    oSchedDict[oKey] = oJson
                                return {"schedule": oSchedDict}

                            elif self.Node.get() == 'Running State':
                                return {
                                    "stateHeatingRelay":
                                    oAttributeList['stateHeatingRelay']
                                }

                            elif self.Node.get() == 'Target Temperature':
                                return {
                                    "targetHeatTemperature":
                                    oAttributeList['targetHeatTemperature']
                                }

                            elif self.Node.get() == 'Local Temperature':
                                return {
                                    "temperature":
                                    oAttributeList['temperature']
                                }

                            elif self.Node.get() == 'Mode':
                                strActiveHeatCoolMode = self.getAttribute(
                                    oAttributeList, 'activeHeatCoolMode')
                                boolActiveScheduleLock = self.getAttribute(
                                    oAttributeList, 'activeScheduleLock')
                                lstActiveOverrides = self.getAttribute(
                                    oAttributeList, 'activeOverrides')

                                if strActiveHeatCoolMode == 'OFF':
                                    self.mode = 'OFF'
                                elif strActiveHeatCoolMode == 'HEAT' and boolActiveScheduleLock:
                                    self.mode = 'MANUAL'
                                elif strActiveHeatCoolMode == 'HEAT' and not boolActiveScheduleLock:
                                    self.mode = 'AUTO'
                                elif strActiveHeatCoolMode == 'BOOST':
                                    self.mode = 'BOOST'
                                elif len(lstActiveOverrides
                                         ) > 0 and lstActiveOverrides[
                                             0] == "TARGET_HEAT_TEMPERATURE":
                                    self.mode = 'OVERRIDE'

                                return {
                                    "currentMode":
                                    self.mode,
                                    "activeHeatCoolMode":
                                    oAttributeList['activeHeatCoolMode'],
                                    "activeScheduleLock":
                                    oAttributeList['activeScheduleLock'],
                                    "activeOverrides":
                                    oAttributeList['activeOverrides'],
                                    "scheduleLockDuration":
                                    oAttributeList["scheduleLockDuration"],
                                    "stateHeatingRelay":
                                    oAttributeList['stateHeatingRelay']
                                }
Esempio n. 20
0
def instaliOSAPP(context):
    
    intIterCntr = 1
    while True:
        context.reporter.HTML_TC_BusFlowKeyword_Initialize('App Installation Verification counter: ' + str(intIterCntr))        
        print('App Installation Verification counter: ' + str(intIterCntr))
        intIterCntr = intIterCntr + 1
        
        
        strNewAppFilePath = os.path.abspath(__file__ + "/../../../../") + "/02_Manager_Tier/EnviromentFile/Apps/iOS/isopBeta/Hive_new.ipa"
        strOldAppFilePath = os.path.abspath(__file__ + "/../../../../") + "/02_Manager_Tier/EnviromentFile/Apps/iOS/isopBeta/Hive_old.ipa"
        '''print(striOSAppiumConnectionString)
        subprocess.call('killall node', shell=True)               
        subprocess.Popen(striOSAppiumConnectionString, shell=True)'''
        
        for strAppPath in [strOldAppFilePath, strNewAppFilePath]:
            print('Uninstalling the APP')
            context.reporter.ReportEvent('Test Validation', 'Uninstalling the APP', "PASS")
            strCmd = "ideviceinstaller -U uk.co.britishgas.hive"
            getShellCommandOutput(strCmd, 'Uninstall APP', boolPrintOutput = True)
            time.sleep(5)
            print('Installing the APP')
            context.reporter.ReportEvent('Test Validation', 'Installing the APP', "PASS")
            strCmd = "ideviceinstaller -i " + strAppPath
            getShellCommandOutput(strCmd, 'Install APP', boolPrintOutput = True)
            
            
            context.reporter.ReportEvent('Test Validation', 'Launching the APP', "PASS")
            strDeviceName = utils.getAttribute('iOS', 'deviceName')
            oBasePage = paygeiOS.BasePage(None, context.reporter)
            iOSDriver  = oBasePage.setup_ios_driver(strDeviceName, strAppPath)
            oHomePage = paygeiOS.HomePage(iOSDriver, context.reporter)
            time.sleep(5)
            context.reporter.ReportEvent('Test Validation', 'Swipe the APP to go to Heating Control Page', "PASS")
            iOSDriver.swipe(50, 500, 300, 500, 500)
            time.sleep(5)
            fltCurrentTargTemp = 0.0
            try:
                oScrolElement = iOSDriver.find_element(*HeatingControlPageLocators.TARGET_TEMPERATURE_SCROLL)
                oScrolElementVAlue = oScrolElement.get_attribute('value')
                if 'point' in oScrolElementVAlue: fltCurrentTargTemp = float(oScrolElementVAlue.split(' ')[0] + '.' + oScrolElementVAlue.split(' ')[2])
                else: fltCurrentTargTemp = float(oScrolElementVAlue.split(' ')[0])
            except:
                context.reporter.ReportEvent('Test Validation','IOS App : NoSuchElementException: in navigate_to_change_password_screen\n {0}'.format(traceback.format_exc().replace('File', '$~File')), "FAIL")
            
            fltAPITargetTemp = 0.0
            ALAPI.createCredentials(utils.getAttribute('common', 'currentEnvironment'))
            session  = ALAPI.sessionObject()
            resp = ALAPI.getNodesV6(session)
            for oNode in resp['nodes']:
                if 'supportsHotWater'  in oNode['attributes']:
                    if 'stateHeatingRelay' in oNode['attributes']:
                        oAttributeList = oNode['attributes']    
                        fltAPITargetTemp = float('{:.1f}'.format(oAttributeList['targetHeatTemperature']['reportedValue']))
                        if fltAPITargetTemp ==1.0: fltAPITargetTemp = 7.0
            ALAPI.deleteSessionV6(session)
            
            if fltAPITargetTemp == 32.0 or fltAPITargetTemp != fltCurrentTargTemp:
                context.reporter.ReportEvent('Test Validation', 'App Display Target Temperature: ' + str(fltCurrentTargTemp) + '\nReported API Target Temperature: ' + str(fltAPITargetTemp), "FAIL", driver = iOSDriver)
            else:
                context.reporter.ReportEvent('Test Validation', 'App Display Target Temperature: ' + str(fltCurrentTargTemp) + '\nReported API Target Temperature: ' + str(fltAPITargetTemp), "PASS", driver = iOSDriver)
            
            iOSDriver.quit()
        
        
        
        '''