jeroenterheerdt / HAsmartirrigation

Smart Irrigation custom component for Home Assistant
https://jeroenterheerdt.github.io/HAsmartirrigation/
MIT License
361 stars 49 forks source link

"Cannot talk to OWM API, check API key." With a known good API key #237

Closed Fabbro03 closed 1 year ago

Fabbro03 commented 1 year ago

What happened?

I've just installed the integration, configured it but don't calculates the daily and hourly run time.

Looking for the logs says that it can't talk to OWM but the API key is good (tested on nodered on the same server).

I'll also take a look in the code if I can find something.

How to reproduce

Install/invoking run time calculations

Relevant log output

2023-09-05 12:08:40.053 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration thermal_comfort which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-09-05 12:08:40.054 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration smart_irrigation which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-09-05 12:08:40.055 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration waste_collection_schedule which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-09-05 12:08:40.056 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-09-05 12:08:40.394 WARNING (MainThread) [homeassistant.components.lovelace] Lovelace is running in storage mode. Define resources via user interface
2023-09-05 12:08:47.110 WARNING (SyncWorker_4) [custom_components.smart_irrigation.OWMClient] Cannot talk to OWM API, check API key.
2023-09-05 12:08:54.601 WARNING (MainThread) [homeassistant.config_entries] Config entry '43048' for luftdaten integration not ready yet: Unable to retrieve data from Sensor.Community; Retrying in background
2023-09-05 12:08:56.764 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform smart_irrigation
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 455, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 731, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 845, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 585, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 649, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 591, in _stringify_state
    if (state := self.state) is None:
  File "/config/custom_components/smart_irrigation/sensor.py", line 557, in state
    self._state = self.update_state()
  File "/config/custom_components/smart_irrigation/sensor.py", line 366, in update_state
    data = self.coordinator.data["daily"][0]
TypeError: 'NoneType' object is not subscriptable
2023-09-05 12:08:56.777 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up smart_irrigation platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 312, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 455, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 731, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 845, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 585, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 649, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 591, in _stringify_state
    if (state := self.state) is None:
  File "/config/custom_components/smart_irrigation/sensor.py", line 557, in state
    self._state = self.update_state()
  File "/config/custom_components/smart_irrigation/sensor.py", line 366, in update_state
    data = self.coordinator.data["daily"][0]
TypeError: 'NoneType' object is not subscriptable

Which version are you running?

v0.0.82

Diagnostics file

Additional information

config_entry-smart_irrigation-a3d130c174f09bc9002481f3f1bbb388.json.txt

Fabbro03 commented 1 year ago

After checking the code I saw that the One Call 3.0 API is utilized, so enabling the subscription resolved the issue.

jeroenterheerdt commented 1 year ago

@gatonero please make sure this in the docs

Fabbro03 commented 1 year ago

It's in the doc, but it's unclear. I made a PR (#238) with a propose to make it clearer. I also added a little instruction if someone is scared about the paid api.