Re: Netatmo authentication changes Oct 2022
Posted: Wednesday 19 March 2025 15:28
Following my previous post, to be complete, I am on Domoticz Version: 2025.1 (build 16581)
Open source Home Automation System
https://forum.domoticz.com/
Code: Select all
2025-03-19 22:10:24.247 Status: Netatmo2: Use refresh token from database...
2025-03-19 22:10:24.247 Status: Netatmo2: Requesting refreshed tokens
2025-03-19 22:10:24.368 Error: Netatmo2: Invalid/no data received (refresh tokens)... HTTP/2 403
In the Beta we use thecadkey wrote: ↑Wednesday 19 March 2025 22:24 I identified the problem. homestatus no longer works with a URL request as shown in netatmo.dev, only works with a cURL request like this one in PHP that I use via a class:
protected $_apiurl = 'https://api.netatmo.net/';
NO LONGER WORKS with URL request
public function getHomestatus()
{
$api_url = $this->_apiurl.'api/homestatus?home_id='.$this->_homeID.'&device_types=NLG&access_token='.$this->_accesstoken;
$response = @file_get_contents($api_url, false);
if ($response === false) return false;
$jsonDatas = json_decode($response, true);
return $jsonDatas['body']['home'];
}
WORKS with cURL request:
public function getHomestatus()
{
$author = 'Authorization: Bearer '.$this->_accesstoken;
$api_url = $this->_apiurl.'api/homestatus?home_id='.$this->_homeID.'&device_types=NLG';
$curl = curl_init($api_url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$headers = array('accept: application/json',$author,'Content-Type: application/json',);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curl);
curl_close($curl);
if ($response === false) return false;
$jsonDatas = json_decode($response, true);
return $jsonDatas['body']['home'];
}
Adapt the code according to your use of a function or a class![]()
Code: Select all
#define NETATMO_API_URI "https://api.netatmo.com/"
Do you see the yellow tekst in the Hardware Page ?
Check with nslookup, api.netatmo.com and api.netatmo.net return the same IP addresses. I use both.homeJLB wrote: ↑Wednesday 19 March 2025 23:29 In the Beta we use theas described by https://dev.netatmo.com/apidocumentation/oauthCode: Select all
#define NETATMO_API_URI "https://api.netatmo.com/"
Yes I have the yellow text (otherwise the button will be greyed out.)
I'm in the same position as @DomoFlits, I have followed your specific advice but cannot get past "Error: Netatmo: Invalid/no data received".
What version are you on? What was your solution?