@@ -105,7 +105,7 @@ def __init__(self, clientId=_CLIENT_ID,
105105 clientSecret = _CLIENT_SECRET ,
106106 username = _USERNAME ,
107107 password = _PASSWORD ,
108- scope = "read_station" ):
108+ scope = "read_station read_camera access_camera read_presence access_presence " ):
109109
110110 postParams = {
111111 "grant_type" : "password" ,
@@ -308,9 +308,9 @@ class DeviceList(WeatherStationData):
308308 DeprecationWarning )
309309 pass
310310
311- class WelcomeData :
311+ class HomeData :
312312 """
313- List the Netatmo Welcome cameras informations (Homes, cameras, events, persons)
313+ List the Netatmo home informations (Homes, cameras, events, persons)
314314
315315 Args:
316316 authData (ClientAuth): Authentication information with a working access Token
@@ -323,7 +323,7 @@ def __init__(self, authData):
323323 resp = postRequest (_GETHOMEDATA_REQ , postParams )
324324 self .rawData = resp ['body' ]
325325 self .homes = { d ['id' ] : d for d in self .rawData ['homes' ] }
326- if not self .homes : raise NoDevice ("No camera available" )
326+ if not self .homes : raise NoDevice ("No home available" )
327327 self .persons = dict ()
328328 self .events = dict ()
329329 self .cameras = dict ()
@@ -343,7 +343,7 @@ def __init__(self, authData):
343343 for camera in self .events :
344344 self .lastEvent [camera ]= self .events [camera ][sorted (self .events [camera ])[- 1 ]]
345345 self .default_home = list (self .homes .values ())[0 ]['name' ]
346- if not self .cameras [self .default_home ] : raise NoDevice ("No camera available" )
346+ if not self .cameras [self .default_home ] : raise NoDevice ("No camera available in default home " )
347347 self .default_camera = list (self .cameras [self .default_home ].values ())[0 ]
348348
349349 def homeById (self , hid ):
@@ -392,12 +392,11 @@ def cameraUrls(self, camera=None, home=None, cid=None):
392392 camera_data = self .cameraByName (camera = camera , home = home )
393393 if camera_data :
394394 vpn_url = camera_data ['vpn_url' ]
395- if camera_data ['is_local' ]:
396- resp = postRequest ('{0}/command/ping' .format (camera_data ['vpn_url' ]),dict ())
397- temp_local_url = resp ['local_url' ]
398- resp = postRequest ('{0}/command/ping' .format (temp_local_url ),dict ())
399- if temp_local_url == resp ['local_url' ]:
400- local_url = temp_local_url
395+ resp = postRequest ('{0}/command/ping' .format (camera_data ['vpn_url' ]),dict ())
396+ temp_local_url = resp ['local_url' ]
397+ resp = postRequest ('{0}/command/ping' .format (temp_local_url ),dict ())
398+ if temp_local_url == resp ['local_url' ]:
399+ local_url = temp_local_url
401400 return vpn_url , local_url
402401
403402 def personsAtHome (self , home = None ):
@@ -531,6 +530,15 @@ def motionDetected(self, home=None, camera=None):
531530 return True
532531 return False
533532
533+ class WelcomeData (HomeData ):
534+ """
535+ This class is now deprecated. Use HomeData instead
536+ Home can handle many devices, not only Welcome cameras
537+ """
538+ warnings .warn ("The 'WelcomeData' class was renamed 'HomeData' to handle new Netatmo Home capabilities" ,
539+ DeprecationWarning )
540+ pass
541+
534542# Utilities routines
535543
536544def postRequest (url , params , json_resp = True , body_size = 65535 ):
@@ -595,22 +603,22 @@ def getStationMinMaxTH(station=None, module=None):
595603 stderr .write ("Library source missing identification arguments to check lnetatmo.py (user/password/etc...)" )
596604 exit (1 )
597605
598- authorization = ClientAuth (scope = "read_station read_camera access_camera" ) # Test authentication method
606+ authorization = ClientAuth () # Test authentication method
599607
600608 try :
601- devList = DeviceList (authorization ) # Test DEVICELIST
609+ weatherStation = WeatherStationData (authorization ) # Test DEVICELIST
602610 except NoDevice :
603611 if stdout .isatty ():
604612 print ("lnetatmo.py : warning, no weather station available for testing" )
605613 else :
606- devList .MinMaxTH () # Test GETMEASUR
614+ weatherStation .MinMaxTH () # Test GETMEASUR
607615
608616
609617 try :
610- Camera = WelcomeData (authorization )
618+ Homes = HomeData (authorization )
611619 except NoDevice :
612620 if stdout .isatty ():
613- print ("lnetatmo.py : warning, no Welcome camera available for testing" )
621+ print ("lnetatmo.py : warning, no home available for testing" )
614622
615623 # If we reach this line, all is OK
616624
0 commit comments