Netatmo poll/refresh time is currently 10 minutes, ideally should be ~5 minutes

Thanks!

I tried the scan_interval but it doesn’t seem to work, because the netatmo module is standalone - not a platform submodule, it’s configured in the yaml at root like so https://home-assistant.io/components/netatmo/ and there are not a lot of options.

I want to change the interval in the code directly like you suggested, but not sure where to do that - I’ve installed hass.io or RPI3, I’ve enabled ssh, I’m in, but can’t exactly figure out where the source is located.

Upon further research this may be a limit on Netatmo’s server side. Seems they only get the data every ten minutes

https://dev.netatmo.com/resources/technical/guides/ratelimits

Hm that is strange, for sure the data is updated every 5 minutes. I currently use a custom setup of curl/netatmo librabry for python. Must be an error in their docs or they just wrote 10 minutes so that apps don’t spam their API attached is a screenshot showing data every 5 minutes.

1 Like

Does your current method poll the local device or netamo servers for the data?

It looks like all the HA methods are polling the cloud.

The cloud - correct - Netatmo don’t allow local requests to your device, you have to use their API. And I’ve tried it before - if you query for data every 30 seconds, it doesn’t matter - new data comes in every 5 minutes.

I modified the source code file as you suggested directly, and the updates are still 10 minutes apart, I made sure it’s the correct file, because if I make a syntax error on purpose, netatmo integration stops working.

Did you modify all the files? There is a main file and then a file for each platform ( sensor, binary sensor, etc)

Aha! That was it! I blindly modified the file that you linked, but I had to actually change the main one in the root of folder /components/ - line 32:

MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=10)

Changed that to 5 and behold, it works. :slight_smile:

Also worth nothing, in the climate netatmo module - the interval is set to 300 seconds, so correct (https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/climate/netatmo.py)

Thanks for your help and suggestions! It now works great :slight_smile:

2 Likes

Great work. Did you submit a PR already?

No, I will try and get to it tomorrow. :slight_smile:

1 Like

Could you please tell how you get to the files inside hass.io installation?

@cgtobi I believe more recent installation still defaults to 10 mins, yes? How to change to less? Looks like the file structure has changed since this and my greps cannot find anything related to polling.

In my opinion the current polling intervals are sufficient and play by Netatmos rules, so I won’t be giving instructions on how to change this. Sorry to disappoint you.

Sufficient is highly subjective; they’re not sufficient for me as at times I have to wait 10 minutes for my automations to trigger because conditions resting on Netatmo.
I definitely wasn’t expecting this kind of answer.

I understand that this might not be satisfactory for you, but, to explain my standpoint, Netatmo has certain rate limits for their API which we are committed to follow. And about reducing the polling time for presumably weather sensors below 10 minutes wont change the reaction time on your end by what you might desire since, according to the Netatmo API documentation, data is only pushed to the server every 10 minutes.

Keep in mind that data are measured every 5 minutes by the modules and sent to the servers every 10 minutes.
Source: Netatmo API documentation

Netatmo appears to have made changes to their APIs and rate limits, allowing for much quicker polling of data. From the API documentation (emphasis mine):

As you can notice from the table below, data can be obtained from 2 endpoints: /gestationsdata & /homestatus. The difference between these 2 endpoints is that /getstationsdata retrieves data from the cloud where data are updated every 10min whereas /homestatus retrieves data from the devices and data are near realtime data (<10s).

The strange thing is that any documentation about using /homestatus appears to be missing in the Weather section, but glancing from other parts in the documentation, it’s not hard to use. As an example, this indeed retrieves data from my Weather Station (I obviously didn’t use a real home_id and token below):

curl -X GET "https://api.netatmo.com/api/homestatus?home_id=0123456789abcdef" -H "accept: application/json" -H "Authorization: Bearer 0123456789|abcdef"

The question is: does this actually yield quicker updates than the Home Assistant integration currently allows? The answer is yes.

I tried this out by using the rest platform to create an entity with the API above, like so:

  - platform: rest
    resource: https://api.netatmo.com/api/homestatus?home_id=MY_HOME_ID
    name: Netatmo Temp Test
    state_class: measurement
    device_class: temperature
    unit_of_measurement: "°C"
    scan_interval: 60
    headers:
      Authorization: >
        Bearer MY_KEY
    value_template: "{{ value_json['body']['home']['modules'][0]['Temperature'] }}"
    unique_id: 'some-unique-id'

I then put an electric heater in the same room as the Weather Station to increase the temperature quickly.

After waiting some time, I pulled up a graph in History, comparing the temperature reported through the official Netatmo Integration (blue line) and the sensor I just described (purple line).

As you can see below, the purple line updates more frequently and also shows more recent data, i.e. once the blue line finally updates at around 0:02, it reports a temperature that the purple line showed 12 minutes earlier. At 0:12, the blue line again is still playing catch up.

It would be great if the official integration could be updated to take advantage of this (new rate limit for users appears to be 500 req/h, so there’s some space), but even if not, the rest platform is your friend. :blush:

Note: originally, I had set scan_interval to 15, but it looks like updates come in every minute, so changed it to 60 to prevent unnecessary calls.

3 Likes

This is excellent news, especially for monitoring electricity consumption more reliably.
With the official “home control” application, instantaneous consumption is refreshed every second, but with HA it’s every 10 minutes.

Example: if an appliance consumes 2000 watts for 4 seconds, HA indicates 2000 watts for 10 minutes. This is unusable and false.

With 500 requests per hour, even with a refresh every 10 seconds, there’s still some margin.

I’m not familiar with github and pull requests, but is anyone planning to do it?

It´s been a while since you posted this, but I am trying to achieve the same as you did when this was posted. Is this still working for you?

Today when I try to use getstationsdata on my weatherstation I get back the full listing from the cloud. But if i try to use homestatus, what I get back is:

{
status:“ok”
time_server:1705263616
body:{
home:{
id:“[MY_HOME_ID]”
}
errors:[
{
code:6
id:“[MY STATION MACADDR]”
}
]
}
}

in the next release the polling frequency will scale dynamically to make the most out of the possible request. This should be a big improvement especially for those who use a dev account. Dynamically adjust Netatmo polling frequency by cgtobi · Pull Request #106742 · home-assistant/core · GitHub

Thanks a lot. I have a quick question before I start working on another PR for this:

Would it still additionally make sense to integrate the new /homestatus API (updates every 10 seconds instead of 10 minutes) for faster updates of weather data as mentioned above by @richardvinger ?