diff --git a/.gitignore b/.gitignore index e3711c8..76296d5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ __pycache__ pythonenv* .coverage coverage.xml +.storage \ No newline at end of file diff --git a/custom_components/openei/__init__.py b/custom_components/openei/__init__.py index 2821c96..60e3497 100644 --- a/custom_components/openei/__init__.py +++ b/custom_components/openei/__init__.py @@ -4,6 +4,7 @@ from datetime import datetime, timedelta import openeihttp +import os from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady @@ -89,6 +90,7 @@ async def _async_update_data(self) -> dict: except AssertionError: pass except Exception as exception: + _LOGGER.debug("Exception: %s", exception) raise UpdateFailed() from exception return self._data @@ -109,6 +111,7 @@ async def _async_refresh_data(self, data=None) -> None: except AssertionError: pass except Exception as exception: + _LOGGER.debug("Exception: %s", exception) raise UpdateFailed() from exception async def get_sensors(self) -> dict: @@ -116,6 +119,7 @@ async def get_sensors(self) -> dict: api = self._config.data.get(CONF_API_KEY) plan = self._config.data.get(CONF_PLAN) meter = self._config.data.get(CONF_SENSOR) + cache_file = f'.storage/openei_{self._config.entry_id}' reading = None if self._config.data.get(CONF_MANUAL_PLAN): @@ -134,6 +138,7 @@ async def get_sensors(self) -> dict: api=api, plan=plan, reading=reading, + cache_file=cache_file, ) if self._rate_limit_count == 0: try: diff --git a/custom_components/openei/manifest.json b/custom_components/openei/manifest.json index 1f72809..edb7669 100644 --- a/custom_components/openei/manifest.json +++ b/custom_components/openei/manifest.json @@ -7,6 +7,6 @@ "documentation": "https://github.com/firstof9/ha-openei", "iot_class": "cloud_polling", "issue_tracker": "https://github.com/firstof9/ha-openei/issues", - "requirements": ["python_openei==0.2.1", "aiofiles"], + "requirements": ["python_openei==0.2.3", "aiofiles"], "version": "0.1.6" } diff --git a/requirements_tests.txt b/requirements_tests.txt index 2a240da..6f5ab03 100644 --- a/requirements_tests.txt +++ b/requirements_tests.txt @@ -1,5 +1,5 @@ -r requirements_dev.txt -python_openei==0.2.1 +python_openei==0.2.3 pytest pytest-cov pytest-homeassistant-custom-component