Skip to content

Need a simple way to get your Netatmo Presence datas with a few lines of php? Here you are!

License

Notifications You must be signed in to change notification settings

KiboOst/php-simpleNetatmoAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-simpleNetatmoAPI

Simple php API to get data from your Netatmo devices.

Supported devices

  • Netatmo Weather Station
  • Netatmo Presence Cameras
  • Netatmo Welcome Cameras
  • Netatmo Doorbell

This is a simple stand-alone API to get your Netatmo devices data in a more easy and more readable way.

It does rely on official Netatmo SDK, even if no other resources are needed to get your data. Just download and use one single php file!

Need to setup a Netatmo callback ? Check here

Requirements

If you don't have Netatmo App yet, just create one, it's simple and free:

In your app, check Token generator section: enter all needed scopes, then hit Generate Token

Copy Refresh Token into refreshtoken.txt file beside your php script. This is extremely important, as for each API initialisation, this refresh token will change, and write back into the file for next calls. Also, this means you can't anymore (December 2023, thanks Netatmo, awkward decision!!) use same app for different scripts locations, or will have to synch this file!

If you need to have this file in different folders you can try that:

require($_SERVER['DOCUMENT_ROOT']."/path/to/splNetatmoAPI.php");
chdir('/path/to/token/'); //for refreshtoken api file path
$_splNetatmo = new splNetatmoAPI($Netatmo_app_id, $Netatmo_app_secret);

How-to

All functions return a json array, you can echo it to see which key to get.

Initialize:

require($_SERVER['DOCUMENT_ROOT']."/path/to/splNetatmoAPI.php");
$_splNetatmo = new splNetatmoAPI($Netatmo_app_id, $Netatmo_app_secret);
if (isset($_splNetatmo->error)) die($_splNetatmo->error);

If you have several homes, you can specify a homeID as last argument.

require($_SERVER['DOCUMENT_ROOT']."/path/to/splNetatmoAPI.php");
$_splNetatmo = new splNetatmoAPI($Netatmo_app_id, $Netatmo_app_secret, 1);
if (isset($_splNetatmo->error)) die($_splNetatmo->error);

//You can also check homes configured on your account to connect to the right one
//It will return all homes with name, id and camera number found.
$homes = $_splNetatmo->getHomes();
echo "<pre><br>homes:<br>".json_encode($homes, JSON_PRETTY_PRINT)."</pre><br>";

Weather Station: