home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.82k stars 30.08k forks source link

Tomorrow.io integration is not respecting the polling setting in config flow with multiple locations and different automatic polling settings #82734

Closed bigcookie closed 1 year ago

bigcookie commented 1 year ago

The problem

I have setup 3 locations in with the tomorrow.io integration. For each location you need to add the integration newly and add the location details. In my case, I set 1 location for automatic polling, but two other locations I disabled the automatic polling and create an automation to update the entity at specific times (4 times during the day).

When checking the logs, it can be noticed, that all 3 locations are being updated with the automatic polling. Also when triggering the update of one weather entity (e.g. 1 location - hourly), all locations get updated as well.

Desired outcome:

What version of Home Assistant Core has the issue?

2022.11.2

What was the last working version of Home Assistant Core?

None

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Tomorrow.io

Link to integration documentation on our website

https://www.home-assistant.io/integrations/tomorrowio/

Diagnostics information

No response

Example YAML snippet

- alias: "Tomorrow.io manual update for Ham and Val"
  id: "tomorrowio_manualupdate_ham_val"
  trigger:
    - platform: time
      at: 
        - '05:45:00'
        - '06:45:00'
        - '07:45:00'
        - '08:45:00'
  action:
    service: homeassistant.update_entity
    target:
      entity_id:
        - weather.tomorrow_io_haus_eltern_daily
        - weather.tomorrow_io_daily

Anything in the logs that might be useful for us?

Log with automated updates (polling) enabled only for one location. But always all three are being updated. Please note that I added a blocking call (1s sleep) between the updates of the locations in the for-loop. This is to solve the issue https://github.com/home-assistant/core/issues/77355 temporarily 
I had to shorten the log file to only contain one update event.

2022-11-26 09:21:47.094 DEBUG (MainThread) [homeassistant.components.tomorrowio] Fetching data for 3 entries
2022-11-26 09:21:47.094 DEBUG (MainThread) [pytomorrowio.pytomorrowio] Sending the following payload to tomorrow.io: {'location': '52**************619', 'units': 'metric', 'timesteps': ['30m', '1h', '1d'], 'startTime': '2022-11-26T09:21:47+00:00', 'fields': ['temperatureMin', 'temperatureMax', 'windSpeed', 'windDirection', 'weatherCode', 'precipitationIntensityAvg', 'precipitationProbability']}
2022-11-26 09:21:47.375 DEBUG (MainThread) [pytomorrowio.pytomorrowio] Received a response with status code 200 and headers <CIMultiDictProxy('Date': 'Sat, 26 Nov 2022 09:21:52 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip', 'Vary': 'Accept-Encoding', 'Vary': 'Origin', 'X-Correlation-Id': '6ce09a6d-0b48-4298-93e5-6342195d3c9e', 'X-Request-Id': 'b4974b5f-bdb8-4dd5-b840-b787cdbb1dc7', 'Access-Control-Allow-Origin': '*', 'X-Moesif-Transaction-Id': '583abae7-2564-4544-8163-a49ba27a2122', 'X-Kong-Upstream-Latency': '53', 'X-Kong-Proxy-Latency': '10', 'Via': '1.1 google', 'CF-Cache-Status': 'DYNAMIC', 'Server-Timing': 'cf-q-config;dur=6.9999950937927e-06', 'Server': 'cloudflare', 'CF-RAY': '77018e6b9e5a4541-TXL')>
2022-11-26 09:21:47.375 DEBUG (MainThread) [pytomorrowio.pytomorrowio] Sending the following payload to tomorrow.io: {'location': '52**************619', 'units': 'metric', 'timesteps': ['current'], 'fields': ['temperature', 'humidity', 'pressureSeaLevel', 'windSpeed', 'windDirection', 'weatherCode', 'visibility', 'pollutantO3', 'windGust', 'cloudCover', 'precipitationType', 'pollutantCO', 'mepIndex', 'mepHealthConcern', 'mepPrimaryPollutant', 'cloudBase', 'cloudCeiling', 'cloudCover', 'dewPoint', 'epaIndex', 'epaHealthConcern', 'epaPrimaryPollutant', 'temperatureApparent', 'fireIndex', 'pollutantNO2', 'pollutantO3', 'particulateMatter10', 'particulateMatter25', 'grassIndex', 'treeIndex', 'weedIndex', 'precipitationType', 'pressureSurfaceLevel', 'solarGHI', 'pollutantSO2', 'windGust']}
2022-11-26 09:21:47.575 DEBUG (MainThread) [pytomorrowio.pytomorrowio] Received a response with status code 200 and headers <CIMultiDictProxy('Date': 'Sat, 26 Nov 2022 09:21:52 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip', 'Vary': 'Accept-Encoding', 'Vary': 'Origin', 'X-Correlation-Id': '660f35f3-5f0e-4a15-a7d2-fc0845402a38', 'X-Request-Id': '695bc9c6-b20c-4a9e-91bd-0539070e6395', 'Access-Control-Allow-Origin': '*', 'X-Moesif-Transaction-Id': 'f9a6a947-2ec0-46a7-be81-2cc4cb6f0d3e', 'X-Kong-Upstream-Latency': '29', 'X-Kong-Proxy-Latency': '8', 'Via': '1.1 google', 'CF-Cache-Status': 'DYNAMIC', 'Server-Timing': 'cf-q-config;dur=5.9999874792993e-06', 'Server': 'cloudflare', 'CF-RAY': '77018e6d09d24541-TXL')>
2022-11-26 09:21:47.577 WARNING (MainThread) [homeassistant.util.async_] Detected blocking call to sleep inside the event loop. This is causing stability issues. Please report issue for tomorrowio doing blocking calls at homeassistant/components/tomorrowio/__init__.py, line 317: time.sleep(1)
2022-11-26 09:21:48.578 DEBUG (MainThread) [pytomorrowio.pytomorrowio] Sending the following payload to tomorrow.io: {'location': '53.6***************************96471', 'units': 'metric', 'timesteps': ['30m', '1h', '1d'], 'startTime': '2022-11-26T09:21:48+00:00', 'fields': ['temperatureMin', 'temperatureMax', 'windSpeed', 'windDirection', 'weatherCode', 'precipitationIntensityAvg', 'precipitationProbability']}
2022-11-26 09:21:48.784 DEBUG (MainThread) [pytomorrowio.pytomorrowio] Received a response with status code 200 and headers <CIMultiDictProxy('Date': 'Sat, 26 Nov 2022 09:21:53 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip', 'Vary': 'Accept-Encoding', 'Vary': 'Origin', 'X-Correlation-Id': 'ad05cb69-a406-4742-9b22-fa4362be96ee', 'X-Request-Id': '09ba9ecb-08e2-4c19-8fd3-a5af5c46b057', 'Access-Control-Allow-Origin': '*', 'X-Moesif-Transaction-Id': '7274cb20-ca5d-4cc3-af81-7d68aef432a9', 'X-Kong-Upstream-Latency': '39', 'X-Kong-Proxy-Latency': '12', 'Via': '1.1 google', 'CF-Cache-Status': 'DYNAMIC', 'Server-Timing': 'cf-q-config;dur=6.9999950937927e-06', 'Server': 'cloudflare', 'CF-RAY': '77018e7499054541-TXL')>
2022-11-26 09:21:48.785 DEBUG (MainThread) [pytomorrowio.pytomorrowio] Sending the following payload to tomorrow.io: {'location': '53.6***************************96471', 'units': 'metric', 'timesteps': ['current'], 'fields': ['temperature', 'humidity', 'pressureSeaLevel', 'windSpeed', 'windDirection', 'weatherCode', 'visibility', 'pollutantO3', 'windGust', 'cloudCover', 'precipitationType', 'pollutantCO', 'mepIndex', 'mepHealthConcern', 'mepPrimaryPollutant', 'cloudBase', 'cloudCeiling', 'cloudCover', 'dewPoint', 'epaIndex', 'epaHealthConcern', 'epaPrimaryPollutant', 'temperatureApparent', 'fireIndex', 'pollutantNO2', 'pollutantO3', 'particulateMatter10', 'particulateMatter25', 'grassIndex', 'treeIndex', 'weedIndex', 'precipitationType', 'pressureSurfaceLevel', 'solarGHI', 'pollutantSO2', 'windGust']}
2022-11-26 09:21:48.987 DEBUG (MainThread) [pytomorrowio.pytomorrowio] Received a response with status code 200 and headers <CIMultiDictProxy('Date': 'Sat, 26 Nov 2022 09:21:53 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip', 'Vary': 'Accept-Encoding', 'Vary': 'Origin', 'X-Correlation-Id': '66fe2874-ab0e-47fb-ad2f-ce87a7dcbaa4', 'X-Request-Id': '8c8a3793-d8d1-4991-b241-933fef69f3e6', 'Access-Control-Allow-Origin': '*', 'X-Moesif-Transaction-Id': '2042dfff-ddab-4c17-95ed-05ade5328d22', 'X-Kong-Upstream-Latency': '29', 'X-Kong-Proxy-Latency': '8', 'Via': '1.1 google', 'CF-Cache-Status': 'DYNAMIC', 'Server-Timing': 'cf-q-config;dur=1.0000017937273e-05', 'Server': 'cloudflare', 'CF-RAY': '77018e75dc1d4541-TXL')>
2022-11-26 09:21:48.990 WARNING (MainThread) [homeassistant.util.async_] Detected blocking call to sleep inside the event loop. This is causing stability issues. Please report issue for tomorrowio doing blocking calls at homeassistant/components/tomorrowio/__init__.py, line 317: time.sleep(1)
2022-11-26 09:21:49.992 DEBUG (MainThread) [pytomorrowio.pytomorrowio] Sending the following payload to tomorrow.io: {'location': '41.65***************************78315', 'units': 'metric', 'timesteps': ['30m', '1h', '1d'], 'startTime': '2022-11-26T09:21:49+00:00', 'fields': ['temperatureMin', 'temperatureMax', 'windSpeed', 'windDirection', 'weatherCode', 'precipitationIntensityAvg', 'precipitationProbability']}
2022-11-26 09:21:50.193 DEBUG (MainThread) [pytomorrowio.pytomorrowio] Received a response with status code 200 and headers <CIMultiDictProxy('Date': 'Sat, 26 Nov 2022 09:21:54 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip', 'Vary': 'Accept-Encoding', 'Vary': 'Origin', 'X-Correlation-Id': 'f6cdad03-1288-4491-b305-ac43a834fea5', 'X-Request-Id': '933a5e35-302b-489a-84b5-8bb99b37e716', 'Access-Control-Allow-Origin': '*', 'X-Moesif-Transaction-Id': '1713d663-a6af-4f9a-96eb-a162abb93ccf', 'X-Kong-Upstream-Latency': '47', 'X-Kong-Proxy-Latency': '7', 'Via': '1.1 google', 'CF-Cache-Status': 'DYNAMIC', 'Server-Timing': 'cf-q-config;dur=6.9999950937927e-06', 'Server': 'cloudflare', 'CF-RAY': '77018e7d6b034541-TXL')>
2022-11-26 09:21:50.193 DEBUG (MainThread) [pytomorrowio.pytomorrowio] Sending the following payload to tomorrow.io: {'location': '41.65***************************78315', 'units': 'metric', 'timesteps': ['current'], 'fields': ['temperature', 'humidity', 'pressureSeaLevel', 'windSpeed', 'windDirection', 'weatherCode', 'visibility', 'pollutantO3', 'windGust', 'cloudCover', 'precipitationType', 'pollutantCO', 'mepIndex', 'mepHealthConcern', 'mepPrimaryPollutant', 'cloudBase', 'cloudCeiling', 'cloudCover', 'dewPoint', 'epaIndex', 'epaHealthConcern', 'epaPrimaryPollutant', 'temperatureApparent', 'fireIndex', 'pollutantNO2', 'pollutantO3', 'particulateMatter10', 'particulateMatter25', 'grassIndex', 'treeIndex', 'weedIndex', 'precipitationType', 'pressureSurfaceLevel', 'solarGHI', 'pollutantSO2', 'windGust']}
2022-11-26 09:21:50.392 DEBUG (MainThread) [pytomorrowio.pytomorrowio] Received a response with status code 200 and headers <CIMultiDictProxy('Date': 'Sat, 26 Nov 2022 09:21:55 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip', 'Vary': 'Accept-Encoding', 'Vary': 'Origin', 'X-Correlation-Id': 'b6745180-4cb6-4076-9832-eb82d3437cd6', 'X-Request-Id': '0f5b7bac-12b8-459f-812a-5924ef8b0371', 'Access-Control-Allow-Origin': '*', 'X-Moesif-Transaction-Id': '14dbc27f-5855-49c7-a6da-1c825ac89f63', 'X-Kong-Upstream-Latency': '28', 'X-Kong-Proxy-Latency': '7', 'Via': '1.1 google', 'CF-Cache-Status': 'DYNAMIC', 'Server-Timing': 'cf-q-config;dur=4.9999798648059e-06', 'Server': 'cloudflare', 'CF-RAY': '77018e7eadf74541-TXL')>
2022-11-26 09:21:50.393 WARNING (MainThread) [homeassistant.util.async_] Detected blocking call to sleep inside the event loop. This is causing stability issues. Please report issue for tomorrowio doing blocking calls at homeassistant/components/tomorrowio/__init__.py, line 317: time.sleep(1)
2022-11-26 09:21:51.397 DEBUG (MainThread) [homeassistant.components.tomorrowio] Finished fetching tomorrowio_6Cki************************Ove7 data in 4.303 seconds (success: True)

### Additional information

The sleep fix for the issue is the following patched in /usr/src/homeassistant/homeassistant/components/tomorrowio/__init__,py . See second last line
async def _async_update_data(self) -> dict[str, Any]:
    """Update data via library."""
    data = {}

... ) as error: raise UpdateFailed from error time.sleep(1) return data

home-assistant[bot] commented 1 year ago

Hey there @raman325, @lymanepp, mind taking a look at this issue as it has been labeled with an integration (tomorrowio) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `tomorrowio` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign tomorrowio` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


tomorrowio documentation tomorrowio source (message by IssueLinks)