@@ -87,9 +87,9 @@ def getParameter(key, default):
87
87
_GETHOMEDATA_REQ = _BASE_URL + "api/gethomedata"
88
88
_GETCAMERAPICTURE_REQ = _BASE_URL + "api/getcamerapicture"
89
89
_GETEVENTSUNTIL_REQ = _BASE_URL + "api/geteventsuntil"
90
- _HOME_STATUS = _BASE_URL + "api/homestatus" # Used for Home+ Control Devices
90
+ _HOME_STATUS = _BASE_URL + "api/homestatus" # Used for Home+ Control Devices
91
91
_GETHOMES_DATA = _BASE_URL + "api/homesdata" # New API
92
-
92
+ _GETHOMECOACH = _BASE_URL + "api/gethomecoachsdata" #
93
93
94
94
#TODO# Undocumented (but would be very usefull) API : Access currently forbidden (403)
95
95
@@ -889,7 +889,54 @@ def __init__(self, authData, home=None):
889
889
# print (self.Homes_Data)
890
890
if not self .Homes_Data : raise NoDevice ("No Devices available" )
891
891
892
+ class HomeCoach :
893
+ """
894
+ List the HomeCoach modules
895
+
896
+ Args:
897
+ authData (clientAuth): Authentication information with a working access Token
898
+ home : Home name or id of the home who's HomeCoach belongs to
899
+ """
900
+ def __init__ (self , authData , home = None ):
901
+ # I don't own a HomeCoach thus I am not able to test the HomeCoach support
902
+
903
+ # warnings.warn("The HomeCoach code is not tested due to the lack of test environment.\n", RuntimeWarning )
904
+ # "As Netatmo is continuously breaking API compatibility, risk that current bindings are wrong is h$
905
+ # "Please report found issues (https://github.com/philippelt/netatmo-api-python/issues)"
892
906
907
+ self .getAuthToken = authData .accessToken
908
+ postParams = {
909
+ "access_token" : self .getAuthToken
910
+ }
911
+ resp = postRequest ("HomeCoach" , _GETHOMECOACH , postParams )
912
+ self .rawData = resp ['body' ]['devices' ]
913
+ # homecoach data
914
+ if not self .rawData : raise NoDevice ("No HomeCoach available" )
915
+
916
+ for i in range (len (self .rawData )):
917
+ #
918
+ self .HomecoachDevice = self .rawData [i ]
919
+ # print ('Homecoach = ', self.HomecoachDevice)
920
+ # print (' ')
921
+ # print ('Homecoach_data = ', self.rawData[i]['dashboard_data'])
922
+ # print (' ')
923
+
924
+ def lastData (self , _id = None , exclude = 0 ):
925
+ s = self .HomecoachDevice ['dashboard_data' ]['time_utc' ]
926
+ _id = self .HomecoachDevice ['_id' ]
927
+ return {'When' :s }, {'_id' :_id }
928
+
929
+ def checkNotUpdated (self , delay = 3600 ):
930
+ res = self .lastData ()
931
+ ret = []
932
+ if time .time ()- res ['When' ] > delay : ret .update ({_id ['_id' ]: 'Device Not Updated' )
933
+ return ret if ret else None
934
+
935
+ def checkUpdated (self , delay = 3600 ):
936
+ res = self .lastData ()
937
+ ret = []
938
+ if time .time ()- res ['When' ] < delay : rret .update ({_id ['_id' ]: 'Device up-to-date' )
939
+ return ret if ret else None
893
940
894
941
# Utilities routines
895
942
0 commit comments