-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature request: add pull of "Einheiten" and old data #1 Feature request: Set pull intervall #2 correction of value seperator #3 Signed-off-by: Ludy87 <Ludy87@users.noreply.github.com>
- Loading branch information
Showing
4 changed files
with
206 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
DOMAIN = "ecotrend_ista" | ||
|
||
DEFAULT_SCAN_INTERVAL_TIME = 3 * 60 * 10 | ||
DEFAULT_SCAN_INTERVAL_TIME = 11 * 60 * 60 | ||
|
||
CONF_CONTROLLER = "controller" | ||
CONF_EMAIL = "email" | ||
CONF_PASSWORD = "password" | ||
CONF_UPDATE_FREQUENCY = "update_frequency" | ||
|
||
CONF_UNIT = "unit" | ||
CONF_YEARMONTH = "yearmonth" | ||
CONF_YEAR = "year" | ||
|
||
CONF_TYPE_HEATING = "heating" | ||
CONF_TYPE_HEATWATER = "warmwater" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
"""Entity ecotrend-ista.""" | ||
from __future__ import annotations | ||
|
||
import logging | ||
import datetime | ||
|
||
from typing import Any, Dict, Mapping | ||
|
||
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription | ||
from homeassistant.helpers.entity import DeviceInfo | ||
from homeassistant.helpers.restore_state import RestoreEntity | ||
from homeassistant.helpers.typing import StateType | ||
|
||
from pyecotrend_ista import pyecotrend_ista as ista | ||
|
||
from .const import DOMAIN | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class EcoEntity(SensorEntity, RestoreEntity): | ||
def __init__( | ||
self, controller: ista.PyEcotrendIsta, description: SensorEntityDescription, consum: Dict[str, Any], unit: str | ||
) -> None: | ||
self._controller = controller | ||
self._supportCode = controller.getSupportCode() | ||
self.entity_description = description | ||
self._consum = consum | ||
self._name = "{}".format(self._consum.get("entity_id")) | ||
self._attr_unique_id = self._name | ||
self._attr_last_reset = datetime.datetime.now() | ||
self._unit = unit | ||
|
||
@property | ||
def name(self) -> str | None: | ||
"""Return the name of the entity.""" | ||
return self._name | ||
|
||
@property | ||
def native_unit_of_measurement(self) -> str | None: | ||
"""Return the unit of measurement of this entity, if any.""" | ||
return self._consum.get("unit{}".format(self._unit)) | ||
|
||
@property | ||
def native_value(self) -> StateType: | ||
"""Return the value reported by the sensor.""" | ||
return float(str(self._consum.get("value{}".format(self._unit))).replace(",", ".")) | ||
|
||
@property | ||
def device_info(self) -> DeviceInfo: | ||
"""Return a device description for device registry.""" | ||
return DeviceInfo( | ||
identifiers={(DOMAIN, self._attr_unique_id)}, | ||
manufacturer="ista", | ||
name=self._name, | ||
) | ||
|
||
@property | ||
def extra_state_attributes(self) -> Mapping[str, Any] | None: | ||
"""Return entity specific state attributes. | ||
Implemented by platform classes. Convention for attribute names | ||
is lowercase snake_case. | ||
""" | ||
return { | ||
"unit": self._consum.get("unit"), | ||
"value": float(str(self._consum.get("value")).replace(",", ".")), | ||
"unitkwh": self._consum.get("unitkwh"), | ||
"valuekwh": float(str(self._consum.get("valuekwh")).replace(",", ".")), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters