Climacell integration - make rate limit adjustable in configurable and add slower update frequency options

Hello @raman325 , thanks for your climacell integration contribution - this is really great, and I was so happy to have a new solution to replace dark sky. I noted that the rate limit was set to 100 lately. According to tomorrow.io, the free rate limit is 500 and I still have 1000 as you have. It seems, that multiple situations need to be covered. My requests/idea:

  1. Rate limit adjustable in configuration flow or at least in the configuration files
    To support different rate limit plans, this would be great. I would like to be able to set this permanently in my docker environment, stored in the /config folder.

  2. Frequency only allows updates every 5/10/15/30 minutes (or similar) - I would like to allow lower update rates due to item 1
    Sample case: I do have 3 locations, I am supervising with climacell. 2 of them are of low importance and I just need an update every 3 hours.
    Can you add also 1h, 2h,3h, 6h, 12h, 24h (or similar) to the config flow?

  3. Frequency updates to be different during time of the day
    To optimize the free API call usage, I would like to specify a generic update frequency per day. But for specific time windows, I would like to have an increased or slowed down rate (depending on implementation).
    E.g. I am interested in latest updates in the morning, before leaving the house. During the rest of the day, I am fine with hourly updates. During night I might even want to reduce the update rate to every 3 hours or none at all.
    The r-renato custom component (https://github.com/r-renato/ha-climacell-weather) allowed “exclude” intervals. This would also be sufficient for my case.

Item 3 would actually combine item 1 and 2. I consider it the most complex one (specifically with UI in the config flow - if UI is required, probably this is something we can also define without UI to make it simpler?).

For now, I changed the const.py in my climacell integration, but this is unfortunately not permanent throughout updates in docker…

Thanks, regards,

André

Btw, my weather components are not updating, I see calls on the climacell API in the tomorrow.io dashboard on hourly basis. They got more when increasing the rate limit in const.py.
But the weather components are not being updated since hours…
I will create a bug for this. Running 2021.10.1

What needs to be changed to add the update interval as a configuration option? I’d also like to increase the frequency of the updates, but haven’t written an integration for HA before.

Hello @masterfink,

What I did with the current integration:

  • enable polling for the first integration and set the interval to every 15min
  • disable polling for the second integration and poll manually
  • disable polling for the third integration and poll manually

Disabling polling is possible in the integration UI. you click on the three dots of the integration and disable automated polling.

Then I created an automation like this:

- alias: "Climacell manual update for Ham and Val"
  id: "climacell_manualupdate_ham_val"
  trigger:
    - platform: time
      at: 
        - '06:30:00'
        - '07:30:00'
        - '08:30:00'
  action:
    service: homeassistant.update_entity
    target:
      entity_id:
      - weather.climacell_daily_2
      - weather.climacell_daily_3

Additionally I had to modify the accepted limit of API calls, as my account can do 1000 and the default config is 100:

  1. Goto your machine running HA (or open a terminal inside docker).
  2. Goto “/usr/src/homeassistant/homeassistant/components/climacell/”
  3. Open const.py in editor
  4. Line 69 change number
  5. Save and exit
  6. restart HA

Unfortunately this needs to be done after every update…

I also checked “config_flow.py”. In line 100 you will find the values being shown in the configuration flow of the integration. If you change this and add your new values, you can select them. I didnt check further, it this is being taken into account by the integration. You can try and create a PR if successful… :slight_smile:
I simply had no time and my manual update solution worked great - especially I could focus only on specific times of the day and reduce API calls.
I personally would like to be able to set the max calls per day in the config flow. This would need to be added and I am not a developer, so I dont know exactly what to change.

Thanks for the response, this works for now. I have it query the max 25 requests an hour using node red during the day, then less frequent at night. Works really well.