Olen / home-assistant-openplantbook

Integration to search and fetch data from Openplantbook.io
GNU General Public License v3.0
165 stars 5 forks source link

OpenPlantbook: Clean Cache service error Home Assistant 2023.8.3 Supervisor 2023.08.1 Operating System 10.5 #10

Closed DDomnick closed 10 months ago

DDomnick commented 1 year ago
service: openplantbook.clean_cache
data:
  hours: 0

Results in:

Logger: homeassistant.components.automation.openplantbook_clear_cache Source: custom_components/openplantbook/init.py:203 Integration: Automation (documentation, issues) First occurred: August 22, 2023 at 5:52:18 AM (56 occurrences) Last logged: 5:27:11 AM

🌱 Openplantbook Clear Cache: Error executing script. Unexpected error for call_service at pos 1: 'timestamp'
While executing automation automation.openplantbook_clear_cache

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 703, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 665, in _async_run_long_action return long_task.result() ^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 1974, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2011, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/openplantbook/init.py", line 203, in clean_cache value[OPB_ATTR_TIMESTAMP]


KeyError: 'timestamp'
kloodhu commented 1 year ago

same here.

Olen commented 1 year ago

I think I know what the problem is. I am creating a cache-entry also for species that does not exist. But these cache entries do not have a timestamp associated with them. I'll make an update that won't cache bad results.