Netatmo token refresh fails
I have two independant Home Assistant instances running on two different locations (one in each). One instance is HA-OS (Yellow) and the other is HA Core Docker Container running on a Linux machine.
I have several Netatmo devices (cameras, weather stations etc.) on each location.
Everything has been working fine up until I upgraded to HA 2024.6.2 (I'm not sure this has anything to do with my case).
Then suddenly today I discover that my Netatmo integration on my HA-OS Instance (Yellow) fails with the following error message:
While on my HA Core Installation, the Netatmo Integration works as always.
Both integrations are linked to the same Netatmo account.
How can I debug this?
Is there a way to find and check the authentication settings for the Netatmo Integration inside Home Assistant?
Many thanks for any advise.
Comments
17 comments
Hello,
Just to tell that I had a similar message this morning from a user who updated HA to its latest version. So there is maybe a regression with this version as it seems to work with older ones
Have a good day,
Leslie - Community Manager
The error message in the OP shows that the 500 response is coming from account-link.nabucasa.com, not netatmo.com. I would investigate the nabucasa.com server for the problem.
Well, I ended up deleting the whole integration and reinstalling it, and that seemed to solve the issue.
It's not something one should have to do as it may (will) break existing automations and scripts since all entities ID's are renewed.
I use Homebridge to integrate things in my Iphone Home. Why Homebridge? because netatmo weather station after pairing with Apple Home shows that every piece of has status "no response". In homebridge I figured it out how to make it work, but today something went wrong during logging to Netatmo account (wrong password). So I changed the password, once more log in to Netatmo app and after that all the weather stuff integrated in Apple Home said from that moment "Go to hell". Quick look at the logs in Homebridge and there is info that my fresh token is not "so fresh". I reset my clientID, clientsecret and Fresh_token, no help. Any idea how can I solve this problem?
info from log:"WARN - Netatmo: Error: Authenticate refresh error: invalid_grant".
How can it be, if I generated all the things once more minute ago?
Hello micket,
At each new call to the /token endpoint, both access_token and refresh_token values change and former values invalidated
You must check that the latest generated refresh_token value is correctly used in your call to refresh the access_token
Please note that the access_token value has a 3 hours lifespan
Have a good day,
Leslie - Community Manager
Leslie, i am not sure if I get U right so correct me if i am wrong. I use reset button at the bottom of site to generale new ClientID and Clientsecret. Then i choose „read_station” and generale new access_token and Fresh_token?
or do I need to make new app? And disactivate all previous one?
This tool is mainly for test purposes. It can give you a valid first pair or access/refresh_token, but it can't be used to refresh an access_token "in a loop" to maintain connectivity
For this, you must follow the refresh_token process (https://dev.netatmo.com/apidocumentation/oauth#refreshing-a-token) and store the latest generated refresh_token value
Then, at the access_token expiration, you must use this latest refresh_token value to get the new values in the next request to /token endpoint
Have a good day,
Leslie - Community Manager
I am using Mac OS, can U say how to make this procedure?
Done!:) Maybe U can tell one more thing about Anemometer and Rain Gauge, where can it be compatible with Apple Home Kit? In Google Home and Home Assistant these two things are responding.
Unfortunately, only the Main and outside modules are currently HomeKit compatible : https://helpcenter.netatmo.com/hc/en-us/articles/360010066920-Are-my-Modules-compatible-with-Apple-HomeKit
Have a good day,
Leslie - Community Manager
For a while I had all my Netatmo devices integrated into HA using both the Netatmo Integration and the Apple HomeKit Device Integration.
This was very handy since devices in the HomeKit integration exposed many additional entities not available in the Netatmo Integration. But one day I ran into a problem after a power outage, and had to reinstall the Netatmo integration. From that moment, all devices (except one outdoor camera) disappeared from the HomeKit integration.
Is there a safe way to re-integrate all devices through HomeKit again?
When I first did this, my HA instance autodetected all devices and asked for the HomeKit code. That doesn't happen any more. Once a device is caught by the Netatmo Integration, it seems to become invisible to the HomeKit integration.
Hello oyvindo,
I asked the teams how it works with the outdoor camera, there are 3 ways to reset the HomeKit connection to the device :
In my opinion it should fix the access of the camera via HomeKit
Have a good day,
Leslie - Community Manager
Hi Leslie, and thanks for your support.
But is your steps only valid for the outdoor camera? What about the indoor camera?
And what is the "red QR Code" ? Where do I find that?
I am not an Apple user so I do not have any device an Apple Home App. I just used the HomeKit Device Integration in Home Assistant because it exposes so much more than the Netatmo Integration.
However, with both the Netatmo Integration and the HomeKit Device Integration active in Home Assistant, how can I control (secure) that both integrations will pair with each camera?
My understanding is that there are some limitations here?
Rgds
Oyvindo
Hi again,
The red QR code is the reset code included in the packaging of your camera and in your H+S app
I missed the part where you talked about HA. Honestly as it's a plugin integrated to a third-party service, I can't tell you if it would work. In my opinion no, as it's not directly linked to HomeKit
The most probable : if you delete/redo the link between HA and your Legrand installation (H+S app or https://home.netatmo.com/ > Parameters > My account > Third-party app). It should relaunch on HA's side an authorization request, and so do the same for the HK compatibility part and activate the auto-discovery of devices
Have a good day,
Leslie - Community Manager
Hi Leslie,
Ok, so I followed your advise - and deleted one of the links I had between HA and my Legrand Installation (Netatmo). The URL you gave me I believe is the old one. The new URL is:
https://home.netatmo.com/settings/my-account >> Partner Apps
Anyway, my list of partner apps contained 4 entries of the same App with the same date, named Home Assistant Cloud. So I though; Let me delete one and see what happens. So I did - and all 4 disappeared and my HA instance began to throw thousands of error messages with invalid log-on attempts, and the HA Android Companion App stopped working. I think it was the HA Android Companion App that caused all the invalid log-on attempts, which in turn caused HA to IP-ban my smart phone (with the Android Companion App). Nothing was relaunched on the HA side requesting new authorisation. And activating the auto-discovery in HK just says; No new devices found!
I could not figure out how to fix the connection I broke when I deleted the App, so I decided to delete and re-install the Netatmo Integration as well. Of course this is not a trivial thing as all Device names and Entity names has to be checked and corrected in order to make automations and front-end cards work again. Then, after clearing the IP-Ban I was able to re-connect the Android Companion APP also.
But here comes the interesting part; During installation of the Netatmo Integration, the configuration process asks whether I want to connect via Home Assistant Cloud or directly to my own Netatmo Online Dev. App. In the next step it then asks for the correct URL to access HA remotely. This HA instance isn't set up with the Home Assistant Cloud because it isn't HA-OS based, but HA-Core based, running in a docker container. Remote accessible is provided via a Reverse Proxy. So I chose to connect to my Netatmo Dev App (and not to Home Assistant Cloud), and typed the correct URL to my reverse proxy into the URL field. The App is the one and the same that I created a long time ago in order to get Webhook events. The name I gave it is HomeAss_Oy
Strangely enough, immediately after connecting the Netatmo Integration to the Dev App, HA began receiving webhook events. Checking the event bus i saw that all these webhook events came from the Netatmo Raingauge (because it was raining outside). Ok, so I thought - perhaps webhooks finally began to work the way it should, again! Great!
Then I went to my other HA instance which had also suffered from a lot of unavailable devices and entities when I first deleted the Online Netatmo App named "Home Assistant Cloud". This is because both HA instances shows all the devices from the other HA instance in addition to its own, because they are both connected to the same Netatmo user account.
Well, I decided to delete the Netatmo Integration here also, and reinstall it. Also this time I had to decide if I should connect to the Home Assistant cloud or to my other Netatmo dev App which I created some time ago specifically for this HA instance in order to try to get webhooks working. Since my first attempt seemed successful, I decided to go for the Netatmo Dev App, even though this HA instance is based on HA-OS and the Home Assistant Cloud for remote login. But this time I typed the correct Home Assistant Cloud URL into the URL field in the integration config dialog.
Interestingly, this HA instance also immediately began to receive webhook events, but from my camera each time I moved my body. (This HA server is in Spain and it never rains in Spain). But the interesting thing is that as soon as the server in Spain began to receive webhook events, the HA server in Norway stopped receiving webhook events - although it still rains in Norway.
So, clearly something is still wrong. The two webhook streams refuse to co-exist.
Experimenting with deleting and re-installing the Netatmo Integration in HA (trial'n'error) is very time consuming since each time I delete and re-install it, I have to check, inspect and correct a large number of device and entity names in order to make HA run correctly. Therefor it would be very good to have some qualified assistance from your dev team. They should be able to tell me the correct procedure to follow when connecting two HA instances, each to a separate dedicated Dev App with unique client_id and client_secrets, but under the same Netatmo user account.
Regards
Oyvindo
I'm still confused about the installation process for the Home Assistant Netatmo-Integration.
I've left everything quietly untouched for several days now, and it's very "quiet", until suddenly - for no apparent reason at all, it starts to report camera events, but not for long. Today, it reported 3 events quickly and successively, and very correctly that it had seen myself and my wife.
Then, after those 3 events reported, it drops back into complete silence again, and nothing more is reported today. And like this, it goes on. 2-3 days of dead silence, and suddenly it wakes up and reports some events again before falling back to sleep. This is utterly confusing.
My Netatmo Security App on my mobile phone, reports all events all the time. There's never any quota bans on the Netatmo dev settings page.
I wish I could have some advise on how to debug this situation.
Please sign in to leave a comment.