def getInfo(cls, auth, aliType, duerType): host = 'https://iotdev.clz.me' url = '/api/v1/user/device/diy/auth?authKey=' + auth if aliType: url = url + aliType if duerType: url = url + duerType r = requests.get(host + url) data = r.json() cls().checkAuthData(data) # if cls().isDebugAll() is True: BLINKER_LOG_ALL('Device Auth Data: ', data) data = r.json() deviceName = data['detail']['deviceName'] iotId = data['detail']['iotId'] iotToken = data['detail']['iotToken'] productKey = data['detail']['productKey'] uuid = data['detail']['uuid'] broker = data['detail']['broker'] bmt = cls() BLINKER_LOG_ALL('deviceName: ', deviceName) BLINKER_LOG_ALL('iotId: ', iotId) BLINKER_LOG_ALL('iotToken: ', iotToken) BLINKER_LOG_ALL('productKey: ', productKey) BLINKER_LOG_ALL('uuid: ', uuid) BLINKER_LOG_ALL('broker: ', broker) BLINKER_LOG_ALL('host + url: ', host + url) if broker == 'aliyun': bmt.host = BLINKER_MQTT_ALIYUN_HOST bmt.port = BLINKER_MQTT_ALIYUN_PORT bmt.subtopic = '/' + productKey + '/' + deviceName + '/r' bmt.pubtopic = '/' + productKey + '/' + deviceName + '/s' bmt.clientID = deviceName bmt.userName = iotId bmt.deviceName = deviceName bmt.password = iotToken bmt.uuid = uuid # if bmt.isDebugAll() is True: BLINKER_LOG_ALL('clientID: ', bmt.clientID) BLINKER_LOG_ALL('userName: '******'password: '******'subtopic: ', bmt.subtopic) BLINKER_LOG_ALL('pubtopic: ', bmt.pubtopic) return bmt
def aqi(self, city): if self.bmqtt.checkAQI() is False: return host = 'https://iotdev.clz.me' url = '/api/v1/user/device/weather/now?deviceName=' + self.bmqtt.deviceName + '&key=' + self.auth + '&location=' + city r = requests.get(url=host + url) data = '' self.bmqtt.aqiTime = millis() # if r.status_code != 200: # BLINKER_ERR_LOG('Device Auth Error!') # return # else: data = r.json() return data['detail']