From f6e2a4a282c1f637eacaaba237b56cf6f08314cf Mon Sep 17 00:00:00 2001 From: Ludy Date: Sun, 14 Jan 2024 14:41:21 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20v2.3.0=20(#160)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐛 v2.3.0 Signed-off-by: Ludy87 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: Ludy87 Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/actions/get_version.py | 6 +++--- custom_components/ecotrend_ista/config_flow.py | 3 ++- custom_components/ecotrend_ista/coordinator.py | 18 +++++++++++++++--- custom_components/ecotrend_ista/manifest.json | 4 ++-- custom_components/ecotrend_ista/sensor.py | 8 +++++++- hacs.json | 4 ++-- pyproject.toml | 3 +++ 7 files changed, 34 insertions(+), 12 deletions(-) diff --git a/.github/actions/get_version.py b/.github/actions/get_version.py index eb4516d..7bd3efc 100644 --- a/.github/actions/get_version.py +++ b/.github/actions/get_version.py @@ -1,11 +1,11 @@ -import json +import json # noqa: D100 import sys -def main(): +def main(): # noqa: D103 with open("./custom_components/ecotrend_ista/manifest.json") as json_file: data = json.load(json_file) - print(data["version"]) + print(data["version"]) # noqa: T201 return 0 diff --git a/custom_components/ecotrend_ista/config_flow.py b/custom_components/ecotrend_ista/config_flow.py index 345f4cc..472634b 100644 --- a/custom_components/ecotrend_ista/config_flow.py +++ b/custom_components/ecotrend_ista/config_flow.py @@ -3,6 +3,7 @@ import copy import logging +from types import MappingProxyType from typing import Any from homeassistant import config_entries, core @@ -26,7 +27,7 @@ @staticmethod @core.callback -def login_account(hass: core.HomeAssistant, data: dict, demo: bool = False) -> PyEcotrendIsta: +def login_account(hass: core.HomeAssistant, data: MappingProxyType[str, Any], demo: bool = False) -> PyEcotrendIsta: """Log into an Ecotrend-Ista account and return an account instance.""" account = PyEcotrendIsta( email=data.get(CONF_EMAIL, None), diff --git a/custom_components/ecotrend_ista/coordinator.py b/custom_components/ecotrend_ista/coordinator.py index 192117a..14d127f 100644 --- a/custom_components/ecotrend_ista/coordinator.py +++ b/custom_components/ecotrend_ista/coordinator.py @@ -67,7 +67,11 @@ def set_controller(self) -> None: and other necessary configurations. """ data = self._entry.data - self.controller = login_account(self.hass, data, self._entry.options.get("dev_demo", False)) + self.controller = login_account( + self.hass, + data, + self._entry.options.get("dev_demo", False), + ) async def init(self) -> None: """Initialize the controller and perform the login.""" @@ -79,13 +83,21 @@ async def _async_update_data(self): try: await self.init() _consum_raw: dict[str, Any] = await self.hass.async_add_executor_job( - self.controller.consum_raw, [datetime.datetime.now().year] + self.controller.consum_raw, + [ + datetime.datetime.now().year, + datetime.datetime.now().year - 1, + ], ) if not isinstance(_consum_raw, dict): return self.data consum_raw: CustomRaw = CustomRaw.from_dict(_consum_raw) - await create_directory_file(self.hass, consum_raw, self.controller.getSupportCode()) + await create_directory_file( + self.hass, + consum_raw, + self.controller.getSupportCode(), + ) self.data = consum_raw self.async_set_updated_data(self.data) return self.data diff --git a/custom_components/ecotrend_ista/manifest.json b/custom_components/ecotrend_ista/manifest.json index 1b7f6b8..1f342e2 100644 --- a/custom_components/ecotrend_ista/manifest.json +++ b/custom_components/ecotrend_ista/manifest.json @@ -11,9 +11,9 @@ "iot_class": "cloud_polling", "issue_tracker": "https://github.com/Ludy87/ecotrend-ista/issues", "requirements": [ - "pyecotrend_ista==2.2.7", + "pyecotrend_ista==2.3.0", "pyotp==2.8.0", "marshmallow-enum==1.5.1" ], - "version": "v2.2.0" + "version": "v2.3.0" } diff --git a/custom_components/ecotrend_ista/sensor.py b/custom_components/ecotrend_ista/sensor.py index c6eefed..12999af 100644 --- a/custom_components/ecotrend_ista/sensor.py +++ b/custom_components/ecotrend_ista/sensor.py @@ -134,7 +134,13 @@ async def async_setup_entry( entities: list = [] consum_raw: CustomRaw = CustomRaw.from_dict( - await hass.async_add_executor_job(controller.consum_raw, [datetime.datetime.now().year]) + await hass.async_add_executor_job( + controller.consum_raw, + [ + datetime.datetime.now().year, + datetime.datetime.now().year - 1, + ], + ) ) consum_dict = consum_raw.to_dict() last_value = consum_dict.get("last_value", None) diff --git a/hacs.json b/hacs.json index 58868e8..a16a553 100644 --- a/hacs.json +++ b/hacs.json @@ -3,7 +3,7 @@ "zip_release": true, "country": "DE", "render_readme": true, - "homeassistant": "2023.10.1", + "homeassistant": "2023.12.1", "hacs": "1.33.0", "filename": "ecotrend_ista.zip" -} \ No newline at end of file +} diff --git a/pyproject.toml b/pyproject.toml index cbaf6e2..e616b47 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -94,6 +94,9 @@ ignore = [ ] +[tool.flake8] +max-line-length = 127 + [tool.ruff.flake8-pytest-style] fixture-parentheses = false