CFenner / MMM-Netatmo

A module for the MagicMirror to display information about your rooms climate from your Netatmo system.
MIT License
37 stars 33 forks source link

Module stopped working #158

Open ihadx opened 1 year ago

ihadx commented 1 year ago

I'm pretty sure that Netatmo has finally depricated "Client credentials grant type" in favour of "Authorization code grant type". Go to https://dev.netatmo.com/apidocumentation/oauth and look for 'Client credentials grant type'

Is someone in the community skilled enough to upgrade the existing code?

Laz2516 commented 1 year ago

I join the request! ((( I also stopped working the module, after about June 29.... (((

CFenner commented 1 year ago

Will try to setup MM again to fix this. Any more hints for me? Are you willing to test the changes?

skyhawk180 commented 1 year ago

Will try to setup MM again to fix this. Any more hints for me? Are you willing to test the changes?

I'll be glad to test the changes as well. I believe the oauth2 auth code changes are described here: https://dev.netatmo.com/apidocumentation/oauth#authorization-code. I'd suspecting the changes will need to be in "node_helper.js". Standing by.

Laz2516 commented 1 year ago

I am also ready to help if I understand how to get a new authorization (token probably).

Laz2516 commented 1 year ago

Maybe this will help the developer fix the authorization?.....

https://forum.netatmo.com/viewtopic.php?t=21383

Laz2516 commented 1 year ago

https://forum.magicmirror.builders/topic/12315/mmm-netatmo-updated/42?page=5

Could help the developer.... How you can get tokens. The module from RaymondMolenaar works after retrieving the authorization data again on the Netatmo website.

Laz2516 commented 1 year ago

Authorization also stopped working in the RainMachine application. This solution appeared on the user forum. Perhaps this will help a respected developer. I cite links....

"Change: https://github.com/zagy/rainmachine-developer-resources/commit/df1d75b84cf9fb12b3334029c48e5cbf6b8625d0

File: https://raw.githubusercontent.com/zagy/rainmachine-developer-resources/df1d75b84cf9fb12b3334029c48e5cbf6b8625d0/sdk-parsers/RMParserFramework/parsers/personalnetatmo-parser.py (can be uploaded via the rainmachine UI)

It's not very tested, but seems to work for now. "

skyhawk180 commented 1 year ago

Many examples are available on how to implement OAuth2.0 auth code / access token flows. Hopefully someone can implement it here: https://developer.goto.com/guides/Authentication/04_HOW_accessTokenNodeJS/

Laz2516 commented 1 year ago

The token can be obtained from the Netatmo app. Where are the keys. image

CFenner commented 1 year ago

@Laz2516 @skyhawk180 @ihadx Can you check if this works for you?

https://github.com/CFenner/MMM-Netatmo/pull/182

Laz2516 commented 1 year ago

Of course. I will check now.))

Laz2516 commented 1 year ago

Unfortunately, it doesn't work. Module icons do not appear on the screen. The inscription "Loading..." is shown. I deleted only my login and password. He left the keys. And added a refresh token. Right? Raspberry overloaded.
Perhaps in the Personal Account-Settings-Partner Applications you need to remove the permission for the old MagicMirror?

" { module: 'netatmo', position: 'top_left', // the location where the module should be displayed header: 'ДОМАШНЯЯ МЕТЕОСТАНЦИЯ', // a header if you like one config: { clientId: '63319aa6d7d9ebХХХХХХХХХ', // your app id clientSecret: 'ХХХХХBeNDqyerfjkZaХХХХХХХХХХХ', // your app secret refresh_token: 'ХХХХХХХХ75368c04c4188c8b52cf|0e864b8ХХХХХХХХХХХХХХ', // username: 'ХХХХХХХХ', // your netatmo username // password: 'ХХХХХХХХХ', // your netatmo password // moduleOrder: ["NAMain", "NAModule4", "NAModule1", "NAModule3", "NAModule2" ], } },

image

Laz2516 commented 1 year ago

Maybe the syntax of the name refresh token is not correct? Could you add another access token? Do you want to change only the lines in the configuration? Do you need any changes in the module itself?

https://forum.magicmirror.builders/topic/12315/mmm-netatmo-updated/42?page=5

Laz2516 commented 1 year ago

refresh_token: 'ХХХХХХХХХХХХХХХХХХХХ88c8b52cf|0e864b8f9ХХХХХХХХХХХХХХ', access_token: 'ХХХХХХХХХХХХХХХХХХХХХХcf|d8d36de50b9c7ХХХХХХХХХХХХХХ',

Alas, adding an access token to the configuration did not help. The weather station does not show the data....

CFenner commented 1 year ago

I deleted only my login and password. He left the keys. And added a refresh token. Right?

Did you update the module code from the auth branch?

Laz2516 commented 1 year ago

No.... (( Can I completely download the module again in the zip file and expand the archive on top of the old module?)

Or tell me how to update your module from SSH?

Laz2516 commented 1 year ago

I downloaded the archive, uploaded it to raspberries. And replaced all the files that were fresh. But there are no files in the archive helper.js helper.test.js module.js

CFenner commented 1 year ago

Please use this archive https://github.com/CFenner/MMM-Netatmo/archive/refs/heads/auth.zip

Laz2516 commented 1 year ago

Downloaded your archive from the link. Replaced only new files. After rebooting the raspberry, the MM program itself does not start. I see only a raspberry desktop. Then I wrote completely all the files from your archive on top of the installed module. The same thing, I see only the desktop, MM does not start....

Laz2516 commented 1 year ago

Returned the old module completely from the copy, MM starts.

CFenner commented 1 year ago

Ok, then I'm need to run the module myself. Sorry for the inconvenience.

Laz2516 commented 1 year ago

Good. Then I am waiting for your decision. A separate archive with only modified files would be good. To avoid spoiling module settings.

And I would very much like, since you have taken up the module, to be able to display the pressure value in mm Hg.

CFenner commented 1 year ago

I would very much like, since you have taken up the module, to be able to display the pressure value in mm Hg.

Let's fix this first and then I will have a look.

It actually works for me, I just missed to run npm clean-install --production --ignore-scripts as stated in the instructions.

skyhawk180 commented 1 year ago

Good. Then I am waiting for your decision. A separate archive with only modified files would be good. To avoid spoiling module settings.

And I would very much like, since you have taken up the module, to be able to display the pressure value in mm Hg.

As a temporary fix for Pressure in 'in Hg', you can update netatmo.js follows. For mmHg, look for the formula and replace the numbers:

case this.measurement.PRESSURE: return (value.toFixed(0)*0.02953).toFixed(2)// pressure conv to inHg.

skyhawk180 commented 1 year ago

-I have tried to merge both my original code and 'auth' branch and while the error goes away, nothing gets loaded on the screen. -I have tried to only copy node helper files to my original main code, and it fails with dependency errors.

Not sure the code is correctly loaded/committed into git. I see differences in netatmo files between branches and also helper files. I am sure I'm missing something that you have a local copy of. Can you just zip your working copy of netatmo folder (under MM/modules) and provide me and I can see if that runs. If so, we can compare code base with git. I have the latest MM 2.4 and node/npm and all other modules are working if I remove this folder.

CFenner commented 1 year ago

So changes are merged to main branch. You need to

Laz2516 commented 1 year ago

Good afternoon! Performed your actions. Deleted the module, wrote the contents of the archive to the module folder. Executed a command inside the module folder. MM starts (I have a previous version, not 2.4), but only the clock is loaded from the modules. All other modules in the "Download" state

CFenner commented 1 year ago

Which version could that be?

Laz2516 commented 1 year ago

Last before 2.4 If you tell me how to find out the version number, I will look more accurately. Unfortunately, I am not a strong specialist in raspberries. I can only repeat according to the written... ((

Laz2516 commented 1 year ago

If I temporarily rename the netatmo folder, for example, to netatmo1 and restart the raspberry, then MM starts and all modules start.

CFenner commented 1 year ago

@skyhawk180

Not sure the code is correctly loaded/committed into git. I see differences in netatmo files between branches and also helper files. I am sure I'm missing something that you have a local copy of. Can you just zip your working copy of netatmo folder (under MM/modules) and provide me and I can see if that runs. If so, we can compare code base with git. I have the latest MM 2.4 and node/npm and all other modules are working if I remove this folder.

If you download the current main branch content, there is a compose folder with instructions how to run locally in a MM docker container. Would that help?

Laz2516 commented 1 year ago

Какая это может быть версия?

Please help figure out why the MM does not start if you install your modified module Netatmo...? ((((((((

skyhawk180 commented 1 year ago

Какая это может быть версия?

Please help figure out why the MM does not start if you install your modified module Netatmo...? ((((((((

In my case, MM Is starting without loading actual data from Netatmo and preventing other modules from loading data as well. If I change config to mockData:true, it will load all modules. In fact, even with brand new MM and Netatamo (latest) being the only module, it still has the same behavior. I changed the logs to "Debug" and it has little details, I even created a new App on Netatmo Dev without luck. As Chris mentioned, I tried to test in Docker as well and again same issue. For some reason. while the Auth may be working now, its still not pulling the data or parsing it. The error handling may be skipped and its forcing MM to just hang after initial load of modules before netatmo. Same with netatmo being only module in MM config (other than defaults). I wish "Debug" logs will push more details after - Netatmo Helper has started....... Standing by for more users to test it or Chris to increase logging before and after Auth flow. I want to see the data json dumped into the logs. BTW, I tested Netatmo APIs via Postman and same credentials and it works for "read_station" scope.

skyhawk180 commented 1 year ago

@skyhawk180

Not sure the code is correctly loaded/committed into git. I see differences in netatmo files between branches and also helper files. I am sure I'm missing something that you have a local copy of. Can you just zip your working copy of netatmo folder (under MM/modules) and provide me and I can see if that runs. If so, we can compare code base with git. I have the latest MM 2.4 and node/npm and all other modules are working if I remove this folder.

If you download the current main branch content, there is a compose folder with instructions how to run locally in a MM docker container. Would that help?

In my case, MM Is starting without loading actual data from Netatmo and preventing other modules from loading data as well. If I change config to mockData:true, it will load all modules. In fact, even with brand new MM and Netatamo (latest) being the only module, it still has the same behavior. I changed the logs to "Debug" and it has little details, I even created a new App on Netatmo Dev without luck. As Chris mentioned, I tried to test in Docker as well and again same issue. For some reason. while the Auth may be working now, its still not pulling the data or parsing it. The error handling may be skipped and its forcing MM to just hang after initial load of modules before netatmo. Same with netatmo being only module in MM config (other than defaults). I wish "Debug" logs will push more details after - Netatmo Helper has started....... Standing by for more users to test it or Chris to increase logging before and after Auth flow. I want to see the data json dumped into the logs. BTW, I tested Netatmo APIs via Postman and same credentials and it works for "read_station" scope.

Laz2516 commented 1 year ago

Probably in vain closed the problem....

CFenner commented 1 year ago

On vacation for the next days, can look into it next week.

Laz2516 commented 1 year ago

Have a great holiday!! (we hope that you can defeat Netatmo authorization!!))))

CFenner commented 1 year ago

@skyhawk180 @Laz2516 what does the browser console show? There should be an error message.

Laz2516 commented 1 year ago

@skyhawk180 @Laz2516что показывает консоль браузера ? Должно появиться сообщение об ошибке.

Unfortunately, I am not very well versed in programming. I can only repeat the tips. Tell me how to see the error? At the moment, with the latest version of the module (I wrote about this above), MM does not start completely. Only two modules are launched, the rest in the "Download" status. If you change the name of the netatmo module to netatmo1, so that the module does not start from the config, then the MM starts normally, all the modules that I use.

skyhawk180 commented 1 year ago

@skyhawk180 @Laz2516 what does the browser console show? There should be an error message.

CFenner commented 1 year ago

Did you connect to your MM on the RPi with the Firefox or was MM running on your machine? So is the error when displaying it with electron or on the RPi in general?

skyhawk180 commented 1 year ago

Did you connect to your MM on the RPi with the Firefox or was MM running on your machine? So is the error when displaying it with electron or on the RPi in general?

Both are working in server mode. I tried remote and local via browser. As a workaround now, I am running firefox-esr in kiosk mode with the mm url and its working. I'd rather have a local option too so it can be managed via pm2.

eierfeile commented 1 year ago

I also have the same issue. But it sounds the latest version of netatmo module isnt the final solution. Is it mandatory to have latest version of magirmirrorOS installed to make the module run properly?

Laz2516 commented 1 year ago

Unfortunately, for some reason we are not enough in this topic. Is Netatmo station in MM really so little used? Maybe one of us should give access to the author of the module to his station so that the author can check the module improvements himself?

Laz2516 commented 1 year ago

https://support.rainmachine.com/hc/en-us/articles/13251844688151-NetAtmo-Weather-Service-2023-Update-Fix-

Dear module developer, perhaps this can help you as a sample? This developer of the auto-watering system has changed its module to access Netatmo.

torth commented 1 year ago

hi folks, I read your instructions and I can agree - problem is still existing.

I generated a new App in dev.netatmo.com generated a "read_station" Token mv netatmo -> netatmo_old git clone https://github.com/CFenner/MMM-Netatmo.git netatmo npm ci --production --ignore-scripts reconfigured config.js with clientId: '', clientSecret: '', refresh_token: '',

but ... after pm2 restart are all modules in state "Downloading" and showing no data

once I deactivated 'netamo' in my config the MM runs as expected and correctly. When 'netatmo' config is enabled I'm also not able to access MM remote with browser :8080

don't know how to help / assist, but I'll you support as much as I can.

torth commented 1 year ago

i don't know if it's good news or bad news, but with the RaymondMolenaar Netatmo-Module and my new credentials works it and MMM show me the data of my station. Tested 10 minutes ago ...

Laz2516 commented 1 year ago

Привет, ребята, я прочитал ваши инструкции и могу согласиться - проблема все еще существует.

Я создал новое приложение на dev.netatmo.com, сгенерировал токен «read_station» mv netatmo -> netatmo_old git clone https://github.com/CFenner/MMM-Netatmo.git netatmo npm ci --production --ignore-scripts перенастроил config.js с clientId: '', clientSecret: '',refresh_token: '',

но... после перезапуска pm2 все модули находятся в состоянии «Загрузка» и не отображают никаких данных

как только я деактивировал «netamo» в своей конфигурации, ММ работает как положено и правильно. Когда включена конфигурация «netatmo», я также не могу получить удаленный доступ к MM с помощью браузера :8080.

не знаю чем помочь/содействовать, но поддержу, чем смогу.

I also have the same, one in one

Laz2516 commented 1 year ago

но с модулем RaymondMolenaar Netatmo и моими новыми учетными данными все работает,

I would not like to change the module. I'm quite fine with this one. If I can then change the pressure display format. And perhaps now there are errors in the display of the wind, but I have a faulty wind sensor itself, I bought a new one. Then I will write comments.

Laz2516 commented 1 year ago

Попробую снова настроить MM, чтобы это исправить. Есть еще подсказки для меня? Готовы ли вы протестировать изменения?

Did you manage to change something in the module for Netatmo authorization? I wrote you a sentence and links above. I can give access to my station for your experiments. If it doesn't work out differently.....