コード例 #1
0
    def __init__(self):
        """
        Initialises the Client Id and Client key and obtains the Access
        token of the netatmo device

        Args as Data:
                clientid: #netatmo id of the user
                clientsecret: #netatmo secret key of the user
                username: #username used in netatmo login
                password: #password used in netatmo login
        """
        netatmo_cred = Setting("netatmo")
        self.clientId = netatmo_cred.setting['client_auth']['_CLIENT_ID']
        self.clientSecret = netatmo_cred.setting['client_auth'][
            '_CLIENT_SECRET']
        self.username = netatmo_cred.setting['client_auth']['_USERNAME']
        self.password = netatmo_cred.setting['client_auth']['_PASSWORD']
        postparams = {
            "grant_type": "password",
            "client_id": self.clientId,
            "client_secret": self.clientSecret,
            "username": self.username,
            "password": self.password,
            "scope": "read_station"
        }
        self._AUTH_REQ = netatmo_cred.get("url")["_AUTH_REQ"]
        response = get_request(self._AUTH_REQ, postparams)
        self._clientId = self.clientId
        self._clientSecret = self.clientSecret
        self._accessToken = response['access_token']
        self.refreshToken = response['refresh_token']
        self._scope = response['scope']
        self.expiration = int(response['expire_in'] + time.time())
コード例 #2
0
 def __init__(self):
     """Initialises the Client token and obtains the raw_data
         of the devices
     """
     lifx_cred = Setting("lifx")
     self.getclienttoken = lifx_cred.setting["client_auth"]["_CLIENT_TOKEN"]
     self.rawData = self.get_request(lifx_cred.get("url")["_DEVICELIST_REQ"])
コード例 #3
0
ファイル: sens_mother.py プロジェクト: xtrmwyz/Connectors
 def __init__(self):
     mother_cred = Setting("mother")
     self.username = mother_cred.setting['client_auth']['_USERNAME']
     self.password = mother_cred.setting['client_auth']['_PASSWORD']
     self.mac_id = mother_cred.setting['mac_id']
     params = {
         'username': str(self.username),
         'password': str(self.password)
     }
     self._AUTH_REQ = mother_cred.get("url")["_AUTH_REQ"]
     self._NODE_REQ = mother_cred.get("url")["_NODE_REQ"]
     response = requests.post(self._AUTH_REQ, params).json()
     if 'token' in response:
         self.api_token = response["token"]
     else:
         print self.api_token, "Error"
         exit(1)
コード例 #4
0
 def __init__(self, authdata):
     """
         Initilize the auth token and obtain the device modules data
         of Netatmo
         Args as data:
                         "authdata": class object of ClientAuth provides
                                     access token.
                                     
     """
     self.getAuthToken = authdata.access_token
     postparams = {
         "access_token": self.getAuthToken,
         "app_type": "app_station"
     }
     url_cred = Setting("netatmo")
     _DEVICELIST_REQ = url_cred.get("url")["_DEVICELIST_REQ"]
     response = get_request(_DEVICELIST_REQ, postparams)
     # print "\nDeviceList: ",resp
     self.rawData = response['body']
     self.stations = {d['_id']: d for d in self.rawData['devices']}
     # print  "\nStations: ",self.stations
     self.modules = {m['_id']: m for m in self.rawData['modules']}
     # print  "\nModules: ",self.modules
     self.default_station = list(self.stations.values())[0]['station_name']
コード例 #5
0
 def __init__(self, identity):
     """Initialises the Client token and obtains the raw_data
         of the devices"""
     lifx_cred = Setting("lifx")
     self.getclienttoken = lifx_cred.setting["client_auth"]["_CLIENT_TOKEN"]
     self._DEVICE_REQ = lifx_cred.get("url")["_DEVICE_REQ"]