Esempio n. 1
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
Esempio n. 2
0
 def load_response(self):
     self.Response.delete(1.0, END) 
     self.reponseJson = self.get_response()
     self.Response.insert(1.0, json.dumps(self.reponseJson, indent=4, sort_keys=False))
     if self.session.statusCode == 200:
         ALAPI.deleteSessionV6(self.session)
     
     showinfo("Hive Test Automation","User & Kit details loaded")
 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 setScheduleViaAPI(self, nodeId, payload):
        ALAPI.createCredentials(self.serverName, self.client)
        session = ALAPI.sessionObject()

        ALAPI.setScheduleSP(session, nodeId, payload)
        '''if 'SLR' in deviceType.upper():
            nodeId = self.getChildNodeForBM(ALAPI.getNodesV6(session), nodeId)'''
        #elif 'SLP' in deviceType.upper() or ''
        '''if not 'WATER' in self.type.upper() and 'MANUAL' in setMode: 
            ALAPI.setTargTemperatureV6(session, nodeId, targetHeatTemperature)'''
        ALAPI.deleteSessionV6(session)
 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)
 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)
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 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. 9
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 setSPSchedulesAndValidateViaHub(context):

    ALAPI.createCredentials(utils.getAttribute('common', 'currentEnvironment'))
    session = ALAPI.sessionObject()
    #get node lists
    oDeviceNodeVersionList = getNodeAndDeviceVersionID()

    oDeviceDetails = {}
    intCntr = 1
    context.reporter.HTML_TC_BusFlowKeyword_Initialize(
        'Continuous Schedule Test Week: ' + str(intCntr))
    for oRow in context.table:
        SmartPlug = oRow['SmartPlug']
        intNoOfEvents = int(oRow['NoOfEvents'])

        oDeviceDetails[SmartPlug] = {}
        oDeviceDetails[SmartPlug]["id"] = SmartPlug
        oDeviceDetails[SmartPlug]["noOfEvents"] = intNoOfEvents
        oDeviceDetails[SmartPlug]["nodeId"] = oDeviceNodeVersionList[
            SmartPlug]["nodeID"]
        oDeviceDetails[SmartPlug]["syntheticID"] = getSyntheticDeviceID(
            oDeviceNodeVersionList[SmartPlug]["nodeID"])
        print('oDeviceNodeVersionList[SmartPlug]["nodeID"]',
              oDeviceNodeVersionList[SmartPlug]["nodeID"])
        print("syntheticID", oDeviceDetails[SmartPlug]["syntheticID"])

        payload, oSPSchedDict = SchUtils.createScheduleForSP(intNoOfEvents)
        print(oSPSchedDict, "\n")
        context.oSPSchedDict = oSPSchedDict
        context.SPNodeID = oDeviceDetails[SmartPlug]["nodeId"]
        r, success = ALAPI.setScheduleSP(
            session, oDeviceDetails[SmartPlug]["syntheticID"], payload)
        print(r, success)
    ALAPI.deleteSessionV6(session)

    SchUtils.runSPValidationForWeekSchedule(context)
    '''while True:
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. 13
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()
        
        
        
        '''
def pair_unpair_devices_via_hub(context, HubType):
    HubType = HubType.upper().strip()
    intModeListCntr = 0
    intCntr = 0
    intPassCntr = 0
    intFailCntr = 0
    while True:
        intCntr = intCntr + 1
        context.reporter.HTML_TC_BusFlowKeyword_Initialize(
            'Pair-Unpair Counter : ' + str(intCntr))
        for oRow in context.table:
            DeviceName = oRow['DeviceName']
            DeviceType = oRow['DeviceType']
            #HubType = oRow['HubType']
            #get node lists
            ALAPI.createCredentials(
                utils.getAttribute('common', 'currentEnvironment'))
            session = ALAPI.sessionObject()
            #nodeIdList = context.oThermostatEP.getNodeID(resp)
            nodeIdList = SP.getNodeAndDeviceVersionID()
            if DeviceType in nodeIdList:
                NodeID = nodeIdList[DeviceType]["nodeID"]
                print(DeviceName, DeviceType, NodeID, "\n")
                #Unpair the Device from Telegesis
                context.reporter.HTML_TC_BusFlowKeyword_Initialize(
                    'Unpair the Device ' + DeviceType + ' from HUb: ')

                context.reporter.ReportEvent("Test Validation",
                                             "NodeID : <B>" + NodeID + "</B>",
                                             "Done")

                print(utils.getTimeStamp(False),
                      "Sending Leave request for device")
                ALAPI.deleteDeviceV6(session, NodeID)
                print(utils.getTimeStamp(False), "Wait for 40 seconds")
                time.sleep(90)
            '''time.sleep(5)
            utils.setSPOnOff("DAF8", "OFF")
            time.sleep(2)
            utils.setSPOnOff("DAF8", "ON")
            time.sleep(5)'''

            #Pair the Device via Hub
            context.reporter.HTML_TC_BusFlowKeyword_Initialize(
                'Pair the Device ' + DeviceType + ' to Hub: ')
            print(utils.getTimeStamp(False), "Join Device to the network")
            ALAPI.setHubStateV6(session, nodeIdList[HubType]["nodeID"],
                                "DISCOVERING")
            intStartTime = time.time()
            intTCStartTime = time.monotonic()

            boolPairStatus = False
            sleepTime = 0
            while True:
                #Validate if node is added the network
                nodeIdList = SP.getNodeAndDeviceVersionID()
                if DeviceType in nodeIdList:
                    boolPairStatus = True
                    break
                elif sleepTime > 250:
                    break
                time.sleep(30)
                sleepTime = sleepTime + 30

            ALAPI.setHubStateV6(session, nodeIdList[HubType]["nodeID"], "UP")
            ALAPI.deleteSessionV6(session)

            print("boolPairStatus", boolPairStatus)
            if boolPairStatus:
                intPassCntr = intPassCntr + 1
                myNodeID = nodeIdList[DeviceType]["nodeID"]

                context.reporter.ReportEvent(
                    "Test Validation", "Device " + DeviceType +
                    " Joined the network with Node ID : <B>" + myNodeID +
                    "</B>", "PASS")
                print("Device Joined the network with Node ID : ", myNodeID)
            else:
                intFailCntr = intFailCntr + 1
                context.reporter.ReportEvent("Test Validation",
                                             "Join is unsuccessfull", "FAIL")
                print("join is unsuccessfull")
                return False
                '''print("Restarting the Smart Plug")
                utils.setSPOnOff(NodeID, 'OFF')
                time.sleep(5)
                utils.setSPOnOff(NodeID, 'ON')
                time.sleep(5)'''

            intTCEndTime = time.monotonic()
            strTCDuration = str(
                timedelta(seconds=intTCEndTime - intTCStartTime))
            strTCDuration = utils.getDuration(strTCDuration)
            intSeconds = int(strTCDuration.split(",")[1].strip().split(" ")[0])
            intMin = int(strTCDuration.split(",")[0].strip().split(" ")[0])
            intSeconds = intMin * 60 + intSeconds
            if intSeconds > 60: strStatus = "FAIL"
            else: strStatus = "PASS"
            context.reporter.ReportEvent("Test Validation",
                                         "Time taken: " + strTCDuration,
                                         strStatus)
            print("Time taken: ", strTCDuration)
            print('intCntr', intCntr, 'intPassCntr', intPassCntr,
                  'intFailCntr', intFailCntr)
            print(
                "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"
            )
            print()
            time.sleep(180)
            print(
                "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"
            )
 def load_response(self):
     self.updateGlobalVarJson()
     self.Response.delete(1.0, END)
     self.Response.insert(
         1.0, json.dumps(self.get_response(), indent=4, sort_keys=False))
     ALAPI.deleteSessionV6(self.session)
def validateActiveLightFunctionViaHub(context, ActiveLightDevice):

    oColorTempList = {
        0: "2700",
        20: "3460",
        40: "4220",
        60: "4980",
        80: "5740",
        100: "6500"
    }
    oColorTempList = {
        0: 2700,
        20: 3460,
        40: 4220,
        60: 4980,
        80: 5740,
        100: 6500
    }
    oColorTempPercentageList = list(oColorTempList.keys())

    #get node lists
    #nodeIdList = context.oThermostatEP.getNodeID(resp)
    nodeIdList = SP.getNodeAndDeviceVersionID()
    print(nodeIdList)
    print(ActiveLightDevice)
    if 'ActiveLight' in ActiveLightDevice:
        if 'FWBulb01_1' in nodeIdList:
            strLightNodeID = nodeIdList['FWBulb01_1']["nodeID"]
        elif 'LDS_DimmerLight_1' in nodeIdList:
            strLightNodeID = nodeIdList['LDS_DimmerLight_1']["nodeID"]
    elif ActiveLightDevice in nodeIdList:
        strLightNodeID = nodeIdList[ActiveLightDevice]["nodeID"]
    else:
        context.reporter.ReportEvent('Test Validation',
                                     "Active light Node is missing.", "FAIL")
        return False

    intCntr = 0

    #Open Text file to write the light parameters
    oFileWriter = open(context.reporter.strCurrentTXTFolder + "LUXvsTEMP.txt",
                       'w')
    oFileWriter.write("Iteration,ColorTemp,0_%,20_%,40_%,60_%,80_%,100_% \n")
    oFileWriter.close()
    del oFileWriter

    while True:
        ALAPI.createCredentials(
            utils.getAttribute('common', 'currentEnvironment'))
        session = ALAPI.sessionObject()

        strParameterValue = ""
        intCntr = intCntr + 1
        strParameterValue = str(intCntr)
        boolPass = True
        context.reporter.HTML_TC_BusFlowKeyword_Initialize(
            'Active Light Brightness validation Counter: ' + str(intCntr))

        if "TWBULB" in ActiveLightDevice.upper():
            intTempCntr = intCntr % 5
            print(intTempCntr)
            myColourTemp = oColorTempList[
                oColorTempPercentageList[intTempCntr]]

            ALAPI.setActiveLightColourTemperature(session, strLightNodeID,
                                                  myColourTemp)
            context.reporter.ReportEvent(
                'Test Validation',
                "Active light is set to Color Temperature : <B>" +
                str(myColourTemp) + "</B>", "Done")
            strParameterValue = strParameterValue + "," + myColourTemp

        #Set Light ON
        ALAPI.setActiveLightState(session, strLightNodeID, "ON")
        context.reporter.ReportEvent('Test Validation',
                                     "Active light is switched <B>ON</B>",
                                     "PASS")
        time.sleep(5)
        oBrightnessList = []
        #ChangeBrightness
        for oRow in context.table:
            intBrightness = int(oRow['BrightnessValue'])
            #print("intBrightness", intBrightness)
            ALAPI.setActiveLightBrightness(session, strLightNodeID,
                                           intBrightness)
            context.reporter.ReportEvent(
                'Test Validation', "Active light Brightness is set to : <B>" +
                str(intBrightness) + "</B>", "Done")
            time.sleep(5)
            if intBrightness in lightSensorCalibration:
                intLowLimit = lightSensorCalibration[intBrightness][0]
                intHighLimit = lightSensorCalibration[intBrightness][1]
                sensorValue, _, _ = utils.get_lux_value()
                if intLowLimit < sensorValue and intHighLimit > sensorValue:
                    context.reporter.ReportEvent(
                        'Test Validation',
                        "The measured LUX value for Active light Brightness is: <B>"
                        + str(sensorValue) +
                        "</B>. Which is within the calibration limit: " +
                        str(intLowLimit) + " - " + str(intHighLimit), "PASS")
                else:
                    context.reporter.ReportEvent(
                        'Test Validation',
                        "The measured LUX value for Active light Brightness is: <B>"
                        + str(sensorValue) +
                        "</B>. Which is <B>NOT</B> the calibration limit: " +
                        str(intLowLimit) + " - " + str(intHighLimit), "FAIL")
                    boolPass = False

                if not intBrightness in oBrightnessList:
                    oBrightnessList.append(intBrightness)
                    strParameterValue = str(intBrightness) + "," + str(
                        sensorValue)
            else:
                context.reporter.ReportEvent(
                    'Test Validation',
                    "The Brightness values should be in multiples of 20",
                    "FAIL")

        #Update Text file
        oFileWriter = open(
            context.reporter.strCurrentTXTFolder + "LUXvsTEMP.txt", 'a')
        oFileWriter.write(strParameterValue + "\n")
        oFileWriter.close()
        del oFileWriter

        #Update the Pass and Fail counters
        context.reporter.intIterationCntr = intCntr
        if boolPass:
            context.reporter.intIterationPassCntr = context.reporter.intIterationPassCntr + 1
        else:
            context.reporter.intIterationFailCntr = context.reporter.intIterationFailCntr + 1

        #Set Light OFF
        ALAPI.setActiveLightState(session, strLightNodeID, "OFF")
        context.reporter.ReportEvent('Test Validation',
                                     "Active Plug is switched <B>OFF</B>",
                                     "PASS")
        time.sleep(5)
        ALAPI.deleteSessionV6(session)
Esempio n. 17
0
def getNodeByID(nodeID):
    ALAPI.createCredentials(utils.getAttribute('common', 'currentEnvironment'))
    session = ALAPI.sessionObject()
    nodes = ALAPI.getNodesByIDV6(session, nodeID)
    ALAPI.deleteSessionV6(session)
    return nodes