@@ -93,7 +93,7 @@ netatmo.prototype.authenticate = function (args, callback) {
9393 password = args . password ;
9494 client_id = args . client_id ;
9595 client_secret = args . client_secret ;
96- scope = args . scope || 'read_station read_thermostat write_thermostat read_camera' ;
96+ scope = args . scope || 'read_station read_thermostat write_thermostat read_camera read_homecoach ' ;
9797
9898 var form = {
9999 client_id : client_id ,
@@ -866,4 +866,53 @@ netatmo.prototype.getCameraPicture = function (options, callback) {
866866 return this ;
867867} ;
868868
869+ /**
870+ * https://dev.netatmo.com/dev/resources/technical/reference/healthyhomecoach/gethomecoachsdata
871+ * @param options
872+ * @param callback
873+ * @returns {* }
874+ */
875+ netatmo . prototype . getHealthyHomeCoachData = function ( options , callback ) {
876+ // Wait until authenticated.
877+ if ( ! access_token ) {
878+ return this . on ( 'authenticated' , function ( ) {
879+ this . getHealthyHomeCoachData ( options , callback ) ;
880+ } ) ;
881+ }
882+
883+ if ( options != null && callback == null ) {
884+ callback = options ;
885+ options = null ;
886+ }
887+
888+ var url = util . format ( '%s/api/gethomecoachsdata?access_token=%s' , BASE_URL , access_token ) ;
889+ if ( options != null ) {
890+ url = util . format ( url + '&device_id=%s' , options . device_id ) ;
891+ }
892+
893+ request ( {
894+ url : url ,
895+ method : "GET" ,
896+ } , function ( err , response , body ) {
897+ if ( err || response . statusCode != 200 ) {
898+ return this . handleRequestError ( err , response , body , "getHealthyHomeCoachData error" ) ;
899+ }
900+
901+ body = JSON . parse ( body ) ;
902+
903+ var devices = body . body . devices ;
904+
905+ this . emit ( 'get-healthhomecoaches-data' , err , devices ) ;
906+
907+ if ( callback ) {
908+ return callback ( err , devices ) ;
909+ }
910+
911+ return this ;
912+
913+ } . bind ( this ) ) ;
914+
915+ return this ;
916+ } ;
917+
869918module . exports = netatmo ;
0 commit comments