Core: forecast-sensor is spamming log because it constantly opens new https-connections

Created on 23 May 2016  ·  17Comments  ·  Source: home-assistant/core

Make sure you run the latest version before reporting an issue. Feature requests should go in the forum: https://community.home-assistant.io/c/feature-requests

Home Assistant release (hass --version):
0.20.1

Python release (python3 --version):
3.5.1

Component/platform:
components/sensor/forecast.py

Description of problem:
Forecast is constantly (for each monitored_conditions) opening a new https-connection to the forecast.io-api. I think this increases the network-load on forecast.io-side unnecessarily.

Expected:
It would be nice if home-assistant is decreasing the very high frequency it is polling the data and is using one connection for each monitored_conditions if the api of forecast supports this.

Problem-relevant configuration.yaml entries and steps to reproduce:

sensor 2:
  platform: forecast
  api_key: 1234567890
  units: ca
  monitored_conditions:
    - icon
    - temperature
    - apparent_temperature
    - summary
    - precip_type
    - precip_intensity
    - wind_speed
    - wind_bearing
    - cloud_cover
    - nearest_storm_distance
    - humidity
    - pressure
    - visibility
    - ozone
    - daily_summary

Most helpful comment

@philhawthorne thanks, updated.

All 17 comments

//cc @bitnukl

I logged into my forecast.io account yesterday and noticed I've been pushed over the free tier several days now.

Going to disable forecast.io till this is resolved before I rack up too much debt,

I just checked my Forecast.io stats and everything looks good for me. Running latest dev build. Not sure what would cause this...

My stats for the last 7 days (I'm running 0,19) have the following

  • 6,370 (give or take 1 or two) calls per day, which was getting 2 stats
  • I then added 2 new paramaters (precip probability and something else), and now my average daily calls are 12,000.

I've disabled forecast.io for now until I upgrade to the latest 0.20 release. Not sure if there was/is something in the 0.19 release which could have caused this?

This appears to be an ongoing issue in 0.20.1 also. It started around 0.19 and hasn't stopped. I've not logged into forecast.io to check but my console (still tinkering) is showing...

INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.forecast.io
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.forecast.io
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.forecast.io
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.forecast.io
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.forecast.io
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.forecast.io
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.forecast.io
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.forecast.io
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.forecast.io
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.forecast.io
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.forecast.io
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.forecast.io
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.forecast.io
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.forecast.io
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.forecast.io
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.forecast.io

This is showing every few seconds. Further to this, when performing a ^C on the shell to terminate, it waits for these connections to complete which can take anything up to 3 or 4 minutes. Hitting ^C again terminates everything forcibly but obviously isn't ideal.

If you need more information about this, please let me know and I'll update this issue.

Edit: Adding sensor details

- platform: forecast
  api_key: XXX
  monitored_conditions:
    - summary
    - icon
    - nearest_storm_distance
    - nearest_storm_bearing
    - precip_type
    - precip_intensity
    - precip_probability
    - temperature
    - apparent_temperature
    - dew_point
    - wind_speed
    - wind_bearing
    - cloud_cover
    - humidity
    - pressure
    - visibility
    - ozone

Added forecast.io API call summary.

2016-05-24-142822_999x282_scrot

Hey, writer of the weather library here. @fabaff asked me to take a look into this.

It seems like the problematic part is here https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/sensor/forecast.py#L85

I think a new python-forecastio.io Forecast object via ForeCastData.update is being created for each monitored condition and therefore a new request to forecast.io. Does anyone know if there is a way to have the Forecast itself being the entity, and have the monitored_condition as properties of that entity?

Otherwise we should be able to solve this by delegating from each monitored_condition to the same backing Forecast.

As far as I can see, there is only one instance of ForeCastData shared by all the entities. The decorator @Throttle(MIN_TIME_BETWEEN_UPDATES) should prevent multiple call to update.
A work around could be to create the forecastio object in the constructor, and keep it as an attribute.

Agreed, throttle is probably helping and ForeCastData is shared but still, a new request is made every time forecastio.load_forecast is called.

Nope no new request but a new https connection if the debug-messages are correct.

Am 26.05.2016 um 10:42 schrieb ZeevG [email protected]:

Agreed, throttle is probably helping and ForeCastData is shared but still, a new request is made every time forecastio.load_forecast is called.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub

Happening in 0.20.2 as well. Just ramped up from 550 to 12000 k.

Same problem here.
Got an email from forecast.io today.
Checking the jan-april im at 550 request per day. After that I have a gap since Í was moving but going on May till now I'm at 10k request per day with the same config.

I guess that we introduced this issue with #1943.

I just got an email from forecast.io telling me that I owe them $15 because I made 175K API calls in the last month :(

Looks like HA has made a bit of money for Forecast.io this month

We have just released hotfix 0.20.3 that fixes this issue. Sorry about this !

0.20.3*

@philhawthorne thanks, updated.

Was this page helpful?
0 / 5 - 0 ratings