- 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
If you don't have Netatmo App yet, just create one, it's simple and free:
- Register at https://dev.netatmo.com
- Create an app at https://dev.netatmo.com/apps/createanapp#form (Enter any name)
- After successfully created your app, just get client_id and client_secret
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);
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>";