@@ -87,9 +87,9 @@ def getParameter(key, default):
8787_GETHOMEDATA_REQ = _BASE_URL + "api/gethomedata"
8888_GETCAMERAPICTURE_REQ = _BASE_URL + "api/getcamerapicture"
8989_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
9191_GETHOMES_DATA = _BASE_URL + "api/homesdata" # New API
92-
92+ _GETHOMECOACH = _BASE_URL + "api/gethomecoachsdata" #
9393
9494#TODO# Undocumented (but would be very usefull) API : Access currently forbidden (403)
9595
@@ -889,7 +889,54 @@ def __init__(self, authData, home=None):
889889# print (self.Homes_Data)
890890 if not self .Homes_Data : raise NoDevice ("No Devices available" )
891891
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)"
892906
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
893940
894941# Utilities routines
895942
0 commit comments