Pirate-Weather / pirate-weather-ha

Replacement for the default Dark Sky Home Assistant integration using Pirate Weather
https://pirateweather.net/
Apache License 2.0
369 stars 26 forks source link

Errors on integration reload #227

Closed jhemak closed 7 months ago

jhemak commented 7 months ago

Describe the bug

I am not sure if this is new since version 1.5 or just something I've not noticed until now. However, when HA starts up, the logs are clean. If I reload the PirateWeather integration, I receive these errors:

2024-04-29 21:55:34.314 WARNING (MainThread) [homeassistant.helpers.service] Referenced entities weather.pirateweather are missing or not currently available
2024-04-29 21:55:34.314 ERROR (MainThread) [homeassistant.helpers.script.trigger_update_coordinator] Trigger Update Coordinator: Error executing script. Error for call_service at pos 1: Service call requested response data but did not match any entities
2024-04-29 21:55:34.318 WARNING (MainThread) [homeassistant.helpers.service] Referenced entities weather.pirateweather are missing or not currently available
2024-04-29 21:55:34.318 ERROR (MainThread) [homeassistant.helpers.script.trigger_update_coordinator] Trigger Update Coordinator: Error executing script. Error for call_service at pos 1: Service call requested response data but did not match any entities
2024-04-29 21:55:35.472 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/template/coordinator.py", line 97, in _handle_triggered_with_script
if script_result := await self._script.async_run(run_variables, script_context):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1728, in async_run
return await asyncio.shield(create_eager_task(run.async_run()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 457, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 509, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 539, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 507, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 742, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 705, in _async_run_long_action
return await long_task
^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2543, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2580, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 963, in entity_service_call
raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Service call requested response data but did not match any entities
2024-04-29 21:55:35.483 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/template/coordinator.py", line 97, in _handle_triggered_with_script
if script_result := await self._script.async_run(run_variables, script_context):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1728, in async_run
return await asyncio.shield(create_eager_task(run.async_run()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 457, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 509, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 539, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 507, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 742, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 705, in _async_run_long_action
return await long_task
^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2543, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2580, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 963, in entity_service_call
raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Service call requested response data but did not match any entities

Expected behavior

Integration should reload without errors

Actual behavior

See above

Home Assistant version

2024.4.4

Integration version

1.5

Other details

image

Troubleshooting steps

alexander0042 commented 7 months ago

Thanks for posting this! The issue is with your config UI, and makes me think we should change the defaults or make it more clear. You've selected that sensors should be created; however, didn't include any times for them. If you put something in either/both the hourly/ daily fields, then this should go away. Alternatively, you could uncheck the sensors button, which should fix this.

jhemak commented 7 months ago

Thanks @alexander0042! The reason I set it up this way initially was that I needed the weather entity and was also interested in the "currently" sensors such as sensor_pirateweather.temperature, sensor_pirateweather.wind_speed, etc. (but not the daily/hourly ones). All of those sensors were created and have been working as expected. If I un-check "Sensors" then I have only the weather entity. If that configuration is not supported, that could probably be clarified in the documentation.

But in any case, I tried a few tests:

So, it seems the problem is related in some way to "Weather" and not "Sensors". This seems different than what you may have been expecting, so it might be good for someone else to try the same test to see if this is unique to my environment for some reason.

cloneofghosts commented 7 months ago

I have my HA integration setup like this:

Screenshot_20240502_154349_DuckDuckGo

I've tried manually reloading and I receive no errors in the log. I sometimes see warnings about sensors taking a long time to update and that's it.

jhemak commented 7 months ago

Thanks, that was helpful in getting me to look at other explanations. Turns out, I caused this due to two of my trigger templates pulling daily and hourly forecasts using weather.get_forecasts. By editing my trigger to include the last two lines (not_to and not_from), I was able to make the errors go away on integration reload. Always something to learn!

- trigger:
  - platform: state
    entity_id: weather.pirateweather
    not_from: "unavailable"
    not_to: "unavailable"