Skip to content

Commit

Permalink
🐛 v2.3.0
Browse files Browse the repository at this point in the history
Signed-off-by: Ludy87 <[email protected]>
  • Loading branch information
Ludy87 committed Jan 14, 2024
1 parent 1a9fc0f commit 5323f4c
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .github/actions/get_version.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
3 changes: 2 additions & 1 deletion custom_components/ecotrend_ista/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

import logging

import voluptuous as vol

from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
import voluptuous as vol

from .const import DATA_HASS_CONFIG, DOMAIN
from .const_schema import DEFAULT_DATA_SCHEMA
Expand Down
12 changes: 7 additions & 5 deletions custom_components/ecotrend_ista/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@

import copy
import logging
from types import MappingProxyType
from typing import Any

from pyecotrend_ista.exception_classes import LoginError
from pyecotrend_ista.pyecotrend_ista import PyEcotrendIsta
import requests
import voluptuous as vol

from homeassistant import config_entries, core
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD
from homeassistant.data_entry_flow import FlowResult
Expand All @@ -13,10 +19,6 @@
NumberSelectorConfig,
NumberSelectorMode,
)
from pyecotrend_ista.exception_classes import LoginError
from pyecotrend_ista.pyecotrend_ista import PyEcotrendIsta
import requests
import voluptuous as vol

from .const import CONF_MFA, CONF_UPDATE_INTERVAL, CONF_URL, DOMAIN, MANUFACTURER
from .const_schema import DATA_SCHEMA_EMAIL, URL_SELECTOR
Expand All @@ -26,7 +28,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),
Expand Down
3 changes: 2 additions & 1 deletion custom_components/ecotrend_ista/const_schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Const schema for ista EcoTrend Version 2."""
from __future__ import annotations

import voluptuous as vol

from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, CONF_SCAN_INTERVAL
from homeassistant.helpers.selector import (
NumberSelector,
Expand All @@ -14,7 +16,6 @@
TextSelectorConfig,
TextSelectorType,
)
import voluptuous as vol

from .const import (
CONF_MFA,
Expand Down
25 changes: 19 additions & 6 deletions custom_components/ecotrend_ista/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
import os
from typing import Any

from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from pyecotrend_ista.helper_object_de import CustomRaw
from pyecotrend_ista.pyecotrend_ista import PyEcotrendIsta
import requests

from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator

from .config_flow import login_account
from .const import CONF_UPDATE_INTERVAL, DOMAIN

Expand Down Expand Up @@ -67,7 +68,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."""
Expand All @@ -79,13 +84,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
Expand Down
4 changes: 2 additions & 2 deletions custom_components/ecotrend_ista/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
13 changes: 10 additions & 3 deletions custom_components/ecotrend_ista/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import logging
from typing import Any, cast

from pyecotrend_ista.helper_object_de import CustomRaw
from pyecotrend_ista.pyecotrend_ista import PyEcotrendIsta

from homeassistant.components.sensor import RestoreSensor, SensorEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
Expand All @@ -14,8 +17,6 @@
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from pyecotrend_ista.helper_object_de import CustomRaw
from pyecotrend_ista.pyecotrend_ista import PyEcotrendIsta

from .const import (
CONF_TYPE_HEATING_CUSTOM,
Expand Down Expand Up @@ -134,7 +135,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)
Expand Down
4 changes: 2 additions & 2 deletions hacs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ ignore = [

]

[tool.flake8]
max-line-length = 127

[tool.ruff.flake8-pytest-style]
fixture-parentheses = false

Expand Down

0 comments on commit 5323f4c

Please sign in to comment.