Aller au contenu

Intégration station Netatmo dans HC3


Sanderic

Messages recommandés

Hi all,

 

I was working yesterday on further improving Netatmo Weather station QA and Netatmo Air Quality QA code to better handle tokens. It seems that Netatmo servers do not like refreshing tokens too often and it is not actually necessary, so now my code refreshes tokens on the QA restart and then every two hours. I reduced token validity time from 3 hours (180 min) to 2 hours just to have enough time (approximately 1 hour) to make backup and reboot HC3.

 

According to the Netatmo instructions on page: https://dev.netatmo.com/apidocumentation/oauth#refreshing-a-token

 

It is necessary to refresh access token only when it expires, so will also test it with normal validity time of 180 minutes. Since only access token expires it should be possible to renew it even after expiration time or more than 3 hours after last renewal with the existing refresh token.

 

I believe that it is also possible that sometimes Netatmo servers send wrong token update and my code now checks that and keeps refresh token until successful renewal of the access token. This is also only possible explanation for loosing connection to the Netatmo servers even access token didn't really expire. Of course, to test if this really works takes time, but will not wait much further to publish new version of my Netatmo solution.

 

IMPORTANT NOTE - It is very important that for each instance of QA users add corresponding app on Netatmo connect. Using one Netatmo app for more than one QA will cause them to stop working eventually, except if all QA refreshes tokens to one shared variable.

 

  • Like 3
Lien vers le commentaire
Partager sur d’autres sites

Great these coming improvement !

 

Do not forget to add the variable to keep the name of the child devices, as I just spend few hours to understand why sope of my QA crached, and  this was because they refered to non existing items in a table ... So, it is important (for me) to be able to keep the name I "want". => THANK YOU

Lien vers le commentaire
Partager sur d’autres sites

Dear all,

 

I have just published new versions of Netatmo integrations and weather providers and they are available on Fibaro forum download section and will be also available on Fibaro Marketplace as soon as they are approved.

 

Here is the list of new QA published on 29/06/2024 @ 00:05h:

 

1. Netatmo Weather Station QA v2.0 Standalone (in this version can be selected as weather provider)

2. Netatmo Indoor Air Quality Monitor QA v2.0 Standalone

3. WeatherBit weather provider QA v1.0 Standalone

4. Weather Underground weather provider QA v1.0 Standalone

5. Open Weather Map weather provider QA v1.0 Standalone

6. Tempest Weather Station QA v1.1 Standalone

 

NOTE - due to Fibaro upload file type restrictions, all above QA download files are with fqa extensions, but are actually ZIP packages, so you need first to change extension to ZIP and then extract it.

 

 

  • Like 4
Lien vers le commentaire
Partager sur d’autres sites

Il y a 10 heures, flacon030 a dit :

Is it not possible to make an update without having to withdraw the old version?

'Cast frankly having to lose child IDs again is boring

Thank you.

 

Hello @flacon030,

 

Everything is explained in description of my work and also in provided User manuals. It is up to you to decide what is the best for you.

 

BTW - I forget to mention one important part, all my QA child devices have unique variable added. Can this be used to find it?

I managed to make UHAS for HC2 where scenes and VD's could find each other without needing user to do any settings regarding that. I'm still learning what is the best way to get the same solution on HC3.

 

 

 

  • Like 1
Lien vers le commentaire
Partager sur d’autres sites

Hello all,

 

Thanks to one user from USA that give feedback for Weather Underground I'm now working on corrections for all weather providers.

 

I forgot to test weather providers if temperature and wind units are changed on Fibaro controllers. If user change temperature unit on controller from Celsius to Fahrenheit and also setup "imperial" units on weather provider then temperature shown on child devices of temperature type is wrong since it is recalculated by controller from Fahrenheit to Fahrenheit which gives wrong values.

 

I'm now correcting weather providers to check measuring units setup on controllers (HC3, HC3L, Yubii home, Z-box) and use them to retrieve data from weather providers servers and recalculate values as necessary. The QA variables "units" and "wind_ms" will be removed as they are not needed anymore.

 

I hope to publish new version in two days.

 

NOTE - users that have set temperature to Celsius on their controllers are not affected with this bug.

Lien vers le commentaire
Partager sur d’autres sites

Hello all,

 

I have corrected and uploaded all three weather providers to Fibaro forum and Fibaro Marketplace.

 

NOTE - Users that setup their HC to use degrees Celsius and QA variable units to metric are not affected with this bug and can continue to use weather provider version 1.0

  • Like 1
Lien vers le commentaire
Partager sur d’autres sites

since your fqa is encrypted, we can not replace the existing code by the new one, and so have to reimport the whole QA ,with the icons and changes of IDs ...

Is my interpretation correct ?

Lien vers le commentaire
Partager sur d’autres sites

Hello @jojo,


Yes t is true, unfortunately not so good solution. I'm now working on establishing my repository that will enable me to add possibility to update QA without needing reinstalling it. Any suggestions which is the best? Github maybe or have even better one?

 

 

 

Lien vers le commentaire
Partager sur d’autres sites

Hi.

How do you guarantee that your auto-update QA will not one day risk being replaced or modified with malicious code in the event that your Github account is hacked?

Especially since your code is encrypted and the user will have no way of analyzing it to ensure that it does not contain malicious code.

Lien vers le commentaire
Partager sur d’autres sites

Hello @MAM78,

 

That is a very good question. Security is of highest importance when home automation and our homes are on the line.

Currently I do not have satisfying answer.

 

BTW - I know that encryption sounds here like a problem. But I have one question for you:

 

How many programs for your PC computer did you reverse engineered just to be sure that there is no malicious code inside? Or asked authors of those programs to send you source code in that matter?

Modifié par Sankotronic
added
Lien vers le commentaire
Partager sur d’autres sites

Hi @jojo,

 

This is never ending story. And with what do you check antivirus programs or you just trust them? No need to answer ;)

 

As I mentioned already, I completely understand everyone's need to know what is installed on home center controller.

I'm not asking for questions, but solutions, so go ahead and suggest what is the best way to distribute solutions for Fibaro control center?

 

I guess it is open source? But then how to control who and how is using that code? Nowadays, many are lazy even to give some feedback or at least to vote (1 to 5 stars), not to mention that is easy to spent 5-10€ for beer that will be pissed out, but it is very difficult to give such amount to support software that is working for long time bringing happiness with home automation.

 

So, go ahead, don't ask me what and how, but give some constructive suggestions <_<

Lien vers le commentaire
Partager sur d’autres sites

From my point of view, it is better to leave the code readable and not encode it.

This has several advantages:

- avoiding recreating the numbering of modules during upgrades,
- allowing users to control the content
- sharing it so that a larger number can train and progress in the development of the news codes,
- make you some suggestions for improvements to existing code.

This is what I do and many of us here do in a spirit of sharing and transparency.

  • Like 2
Lien vers le commentaire
Partager sur d’autres sites

@Sankotronic. It has stopped on my side on HC2, I am in 3.4.

What I do not understand, is that logs are ok... I tried to change access and refresh token, even the same.

 

But logs, all is ok :

 

image.thumb.png.b4239c8b5bb9649935460debdbf7f5fa.png

 

But on VD side, debug ok too, but in interface, I see just update error...

 

Any idea ?

Lien vers le commentaire
Partager sur d’autres sites

Hi @Nico,

 

sorry for late replay, I'm far away from home. To renew tokens, you need to do the following:

 

  1. Paste new tokens to the scene code and save the scene
  2. Delete global variable NetatmoW_scene_[scene ID]
  3. Run scene manually to rebuild global variable and store new tokens.

If it doesn't work then there is another global variable added by the scene. You can check to which global variable tokens are stored using HC2 REST_API. I'm at my work in Singapore and can't check it my self and it was sometime ago I make this so not sure 100%

 

  • Upvote 1
Lien vers le commentaire
Partager sur d’autres sites

hello @Sankotronic

I have a strans behaviour of the QA (I'm still with v2.0) :
it is marked as disconnected
u661.png
This is the case from few days, and at that time child devices where ok.
But now they also are marked as disonnectected.
A restart of the QA (after having changed the value of the connection variable) does not change the situation.
Now I see nothing in the preview pane :
aumh.png
So I reseted my clientID and tokens.
And now my devices are still shown as disconnected, all seems ok in the preview pane :
1r5n.png
When I click on the button "Update Measurements", I see this
dd64.png
and after about 30 seconds, I'm back as previous screenshot

What did I wrong ?

Lien vers le commentaire
Partager sur d’autres sites

  • 3 semaines après...

Bonjour

Le QA semble avoir des probleme pour recevoir le nouveau token

Il y a parfois plusieurs séquences de 10minutes avant d'avoir un nouveau token ( 3 séquences en principe)

du coup on peut attendre plus d'une 1/2 heure avant d'avoir une valeur

 

[03.08.2024] [11:49:56] [DEBUG] [QA_NETATMO_1021]: Token expiry time: 03.08.24 @ 12:29 Current time: 03.08.24 @ 11:49
[03.08.2024] [11:49:56] [DEBUG] [QA_NETATMO_1021]: INFO Updating Netatmo station(s)
[03.08.2024] [11:49:57] [DEBUG] [QA_NETATMO_1021]: Found station ID: 70:ee:50:06:ac:ea Name: Maison Tignet (T° / Humidité Salon) Last seen: 03.08.24 @ 11:49
[03.08.2024] [11:50:01] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a un moment
[03.08.2024] [11:50:41] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 01 minutes
[03.08.2024] [11:51:41] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 02 minutes
[03.08.2024] [11:52:41] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 03 minutes
[03.08.2024] [11:53:41] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 04 minutes
[03.08.2024] [11:54:41] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 05 minutes
[03.08.2024] [11:55:42] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 06 minutes
[03.08.2024] [11:56:42] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 07 minutes
[03.08.2024] [11:57:42] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 08 minutes
[03.08.2024] [11:58:42] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 09 minutes
[03.08.2024] [11:59:42] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 10 minutes
[03.08.2024] [12:00:02] [DEBUG] [QA_NETATMO_1021]: Token expiry time: 03.08.24 @ 12:29 Current time: 03.08.24 @ 12:00
[03.08.2024] [12:00:02] [DEBUG] [QA_NETATMO_1021]: INFO Updating Netatmo station(s)
[03.08.2024] [12:00:02] [DEBUG] [QA_NETATMO_1021]: ERROR Received response status: 403 Message: invalid_grant Please check your credentials
[03.08.2024] [12:00:02] [DEBUG] [QA_NETATMO_1021]: Set Netatmo weather unreachable
[03.08.2024] [12:00:07] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a un moment
[03.08.2024] [12:01:02] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 01 minutes
[03.08.2024] [12:02:02] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 02 minutes
[03.08.2024] [12:03:02] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 03 minutes
[03.08.2024] [12:04:02] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 04 minutes
[03.08.2024] [12:05:02] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 05 minutes
[03.08.2024] [12:06:02] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 06 minutes
[03.08.2024] [12:07:02] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 07 minutes
[03.08.2024] [12:08:02] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 08 minutes
[03.08.2024] [12:09:02] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 09 minutes
[03.08.2024] [12:10:02] [DEBUG] [QA_NETATMO_1021]: Station [1] updated Il y a 10 minutes
[03.08.2024] [12:10:22] [DEBUG] [QA_NETATMO_1021]: Token expiry time: 03.08.24 @ 12:29 Current time: 03.08.24 @ 12:10
[03.08.2024] [12:10:22] [DEBUG] [QA_NETATMO_1021]: INFO Updating Netatmo station(s)
[03.08.2024] [12:10:22] [DEBUG] [QA_NETATMO_1021]: ERROR Received response status: 403 Message: invalid_grant Please check your credentials

 

Modifié par flacon030
Lien vers le commentaire
Partager sur d’autres sites

×
×
  • Créer...