@@ -88,6 +88,7 @@ def getParameter(key, default):
8888_GETCAMERAPICTURE_REQ = _BASE_URL + "api/getcamerapicture"
8989_GETEVENTSUNTIL_REQ = _BASE_URL + "api/geteventsuntil"
9090_HOME_STATUS = _BASE_URL + "api/homestatus" # Used for Home+ Control Devices
91+ _GETHOMES_DATA = _BASE_URL + "api/homesdata" # New API
9192
9293
9394#TODO# Undocumented (but would be very usefull) API : Access currently forbidden (403)
@@ -121,6 +122,59 @@ def getParameter(key, default):
121122# Not working yet
122123#_CAM_FTP_ACTIVE = "/command/ftp_set_config?config=on_off:%s" # "on"|"off"
123124
125+ #Known TYPE used by Netatmo services + API, there can be more types possible
126+ TYPES = {
127+ 'BFII' : ["Bticino IP Indoor unit" , 'Home + Security' ],
128+ 'BFIC' : ["Bticino IP Guard station" , 'Home + Security' ],
129+ 'BFIO' : ["Bticino IP Entrance panel" , 'Home + Security' ],
130+ 'BFIS' : ["Bticino Server DES" , 'Home + Security' ],
131+ 'BNS' : ["Smarther with Netatmo Thermostat" , 'Home+Control' ],
132+ 'BNCU' : ["Bticino Bticino Alarm Central Unit" , 'Home + Security' ],
133+ 'BNCS' : ["Bticino module Controlled Socket" , 'Home+Control' ],
134+ 'BNCX' : ["Bticino Class 300 EOS" , 'Home + Security' ],
135+ 'BNDL' : ["Bticino Doorlock" , 'Home + Security' ],
136+ 'BNEU' : ["Bticino external unit" , 'Home + Security' ],
137+ 'BNFC' : ["Bticino Thermostat" , 'Home+Control' ],
138+ 'BNMH' : ["Bticino My Home Server 1" , 'Home + Security' ], # also API Home+Control GATEWAY
139+ 'BNSE' : ["Bticino Alarm Sensor" , 'Home + Security' ],
140+ 'BNSL' : ["Bticino Staircase Light" , 'Home + Security' ],
141+ 'BNTH' : ["Bticino Thermostat" , 'Home+Control' ],
142+ 'BNTR' : ["Bticino module towel rail" , 'Home+Control' ],
143+ 'BNXM' : ["Bticino X meter" , 'Home+Control' ],
144+
145+ 'NACamera' : ["indoor camera" , 'Home + Security' ],
146+ 'NACamDoorTag' : ["door tag" , 'Home + Security' ],
147+ 'NAMain' : ["weather station" , 'Weather' ],
148+ 'NAModule1' : ["outdoor unit" , 'Weather' ],
149+ 'NAModule2' : ["wind unit" , 'Weather' ],
150+ 'NAModule3' : ["rain unit" , 'Weather' ],
151+ 'NAModule4' : ["indoor unit" , 'Weather' ],
152+ 'NAPlug' : ["thermostat relais station" , 'Energy' ], # A smart thermostat exist of a thermostat$
153+ # The relais module is also the bridge bet$
154+ 'NATherm1' : ["thermostat" , 'Energy' ],
155+ 'NCO' : ["co2 sensor" , 'Home + Security' ], # The same API as smoke sensor
156+ 'NDB' : ["doorbell" , 'Home + Security' ],
157+ 'NOC' : ["outdoor camera" , 'Home + Security' ],
158+ 'NRV' : ["thermostat valves" , 'Energy' ], # also API Home+Control
159+ 'NSD' : ["smoke sensor" , 'Home + Security' ],
160+ 'NHC' : ["home coach" , 'Aircare' ],
161+ 'NIS' : ["indoor sirene" , 'Home + Security' ],
162+
163+ 'NLC' : ["Cable Outlet" , 'Home+Control' ],
164+ 'NLE' : ["Ecometer" , 'Home+Control' ],
165+ 'NLG' : ["Gateway" , 'Home+Control' ],
166+ 'NLGS' : ["Standard DIN Gateway" , 'Home+Control' ],
167+ 'NLP' : ["Power Outlet" , 'Home+Control' ],
168+ 'NLPC' : ["DIN Energy meter" , 'Home+Control' ],
169+ 'NLPD' : ["Dry contact" , 'Home+Control' ],
170+ 'NLPM' : ["Mobile Socket" , 'Home+Control' ],
171+ 'NLPO' : ["Contactor" , 'Home+Control' ],
172+ 'NLPT' : ["Teleruptor" , 'Home+Control' ],
173+
174+ 'OTH' : ["Opentherm Thermostat Relay" , 'Home+Control' ],
175+ 'OTM' : ["Smart modulating Thermostat" , 'Home+Control' ]
176+ }
177+
124178# UNITS used by Netatmo services
125179UNITS = {
126180 "unit" : {
@@ -138,6 +192,18 @@ def getParameter(key, default):
138192 0 : "mbar" ,
139193 1 : "inHg" ,
140194 2 : "mmHg"
195+ },
196+ "Health index" : { # Homecoach
197+ 0 : "Healthy" ,
198+ 1 : "Fine" ,
199+ 2 : "Fair" ,
200+ 3 : "Poor" ,
201+ 4 : "Unhealthy"
202+ },
203+ "Wifi status" : { # Wifi Signal quality
204+ 86 : "Bad" ,
205+ 71 : "Average" ,
206+ 56 : "Good"
141207 }
142208}
143209
@@ -317,11 +383,11 @@ def getThermostat(self, name=None):
317383 else : return
318384 return self .thermostat [self .defaultThermostatId ]
319385
320- def moduleNamesList (self , name = None , tid = None ):
386+ def moduleNamesList (self , name = None , tid = None ): # ERROR getThermostat() got an unexpected keyword argument 'tid'
321387 thermostat = self .getThermostat (name = name , tid = tid )
322388 return [m ['name' ] for m in thermostat ['modules' ]] if thermostat else None
323389
324- def getModuleByName (self , name , thermostatId = None ):
390+ def getModuleByName (self , name , thermostatId = None ): # ERROR 'NoneType' object is not subscriptable
325391 thermostat = self .getThermostat (tid = thermostatId )
326392 for m in thermostat ['modules' ]:
327393 if m ['name' ] == name : return m
@@ -792,6 +858,39 @@ class WelcomeData(HomeData):
792858 warnings .warn ("The 'WelcomeData' class was renamed 'HomeData' to handle new Netatmo Home capabilities" ,
793859 DeprecationWarning )
794860 pass
861+
862+ class HomesData :
863+ """
864+ List the Data of most modules
865+
866+ Args:
867+ authData (clientAuth): Authentication information with a working access Token
868+ home : Home name or id of the home who's module belongs to
869+ """
870+ def __init__ (self , authData , home = None ):
871+ #
872+ self .getAuthToken = authData .accessToken
873+ postParams = {
874+ "access_token" : self .getAuthToken ,
875+ "home_id" : home
876+ }
877+ #
878+ resp = postRequest ("Module" , _GETHOMES_DATA , postParams )
879+ # self.rawData = resp['body']['devices']
880+ self .rawData = resp ['body' ]['homes' ]
881+ if not self .rawData : raise NoHome ("No home %s found" % home )
882+ #
883+ if home :
884+ # Find a home who's home id or name is the one requested
885+ for h in self .rawData :
886+ #print (h.keys())
887+ if h ["name" ] == home or h ["id" ] == home :
888+ self .Homes_Data = h
889+ # print (self.Homes_Data)
890+ if not self .Homes_Data : raise NoDevice ("No Devices available" )
891+
892+
893+
795894# Utilities routines
796895
797896def rawAPI (authData , url , parameters = {}):
0 commit comments