Skip to content

Commit f319e50

Browse files
committed
Fix deprecations
1 parent b593558 commit f319e50

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 5.3.0
4+
5+
- Fix deprecations
6+
- Bump pyecodevices
7+
38
## 5.2.0
49

510
- Compare total sensors with previous value when possible to avoid wrong values

custom_components/ecodevices/__init__.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,7 @@ async def async_update_data():
132132
UNDO_UPDATE_LISTENER: undo_listener,
133133
}
134134

135-
for platform in PLATFORMS:
136-
hass.async_create_task(
137-
hass.config_entries.async_forward_entry_setup(entry, platform)
138-
)
135+
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
139136

140137
return True
141138

custom_components/ecodevices/manifest.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"issue_tracker": "https://github.com/Aohzan/ecodevices/issues",
1212
"requirements": [
1313
"xmltodict==0.13.0",
14-
"pyecodevices==1.6.1"
14+
"pyecodevices==1.7.0"
1515
],
16-
"version": "5.2.0"
16+
"version": "5.3.0"
1717
}

custom_components/ecodevices/sensor.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from homeassistant.const import UnitOfApparentPower, UnitOfEnergy
1717
from homeassistant.core import HomeAssistant
1818
from homeassistant.helpers.entity_platform import AddEntitiesCallback
19+
from homeassistant.helpers.typing import StateType
1920
from homeassistant.helpers.update_coordinator import (
2021
CoordinatorEntity,
2122
DataUpdateCoordinator,
@@ -327,7 +328,7 @@ def __init__(
327328
)
328329
self._attr_device_info = get_device_info(self.controller)
329330

330-
self._last_state: float | None = None
331+
self._last_state: StateType | None = None
331332

332333
async def async_added_to_hass(self) -> None:
333334
"""Restore state on startup."""
@@ -336,7 +337,7 @@ async def async_added_to_hass(self) -> None:
336337
last_state = await self.async_get_last_state()
337338

338339
if last_state:
339-
self._last_state = float(last_state.state)
340+
self._last_state = last_state.state
340341

341342

342343
class TeleinfoInputEdDevice(EdSensorEntity):
@@ -365,7 +366,7 @@ class TeleinfoInputTotalEdDevice(EdSensorEntity):
365366
def native_value(self) -> float | None:
366367
"""Return the total value if it's greater than 0."""
367368
if (value := float(self.coordinator.data[f"T{self._input_number}_BASE"])) > 0:
368-
if self._last_state is None or value >= self._last_state:
369+
if self._last_state is None or value >= float(self._last_state):
369370
self._last_state = value
370371
return value
371372
_LOGGER.warning(
@@ -387,7 +388,7 @@ def native_value(self) -> float | None:
387388
value_hc = float(self.coordinator.data[f"T{self._input_number}_HCHC"])
388389
value_hp = float(self.coordinator.data[f"T{self._input_number}_HCHP"])
389390
if (value := value_hc + value_hp) > 0:
390-
if self._last_state is None or value >= self._last_state:
391+
if self._last_state is None or value >= float(self._last_state):
391392
self._last_state = value
392393
return value
393394
_LOGGER.warning(
@@ -407,7 +408,7 @@ class TeleinfoInputTotalHcEdDevice(EdSensorEntity):
407408
def native_value(self) -> float | None:
408409
"""Return the total value if it's greater than 0."""
409410
if (value := float(self.coordinator.data[f"T{self._input_number}_HCHC"])) > 0:
410-
if self._last_state is None or value >= self._last_state:
411+
if self._last_state is None or value >= float(self._last_state):
411412
self._last_state = value
412413
return value
413414
_LOGGER.warning(
@@ -427,7 +428,7 @@ class TeleinfoInputTotalHpEdDevice(EdSensorEntity):
427428
def native_value(self) -> float | None:
428429
"""Return the total value if it's greater than 0."""
429430
if (value := float(self.coordinator.data[f"T{self._input_number}_HCHP"])) > 0:
430-
if self._last_state is None or value >= self._last_state:
431+
if self._last_state is None or value >= float(self._last_state):
431432
self._last_state = value
432433
return value
433434
_LOGGER.warning(
@@ -450,7 +451,7 @@ def native_value(self) -> float | None:
450451
for key in TELEINFO_TEMPO_ATTR.values():
451452
value += float(self.coordinator.data[f"T{self._input_number}_{key}"])
452453
if value > 0:
453-
if self._last_state is None or value >= self._last_state:
454+
if self._last_state is None or value >= float(self._last_state):
454455
self._last_state = value
455456
return value
456457
_LOGGER.warning(
@@ -470,7 +471,7 @@ class TeleinfoInputTempoEdDevice(EdSensorEntity):
470471
def native_value(self) -> float | None:
471472
"""Return the total value if it's greater than 0 or the previous value."""
472473
if (value := float(self.coordinator.data[self._input_name.upper()])) > 0:
473-
if self._last_state is None or value >= self._last_state:
474+
if self._last_state is None or value >= float(self._last_state):
474475
self._last_state = value
475476
return value
476477
_LOGGER.warning(
@@ -562,7 +563,7 @@ def native_value(self) -> float | None:
562563
if (
563564
value := float(self.coordinator.data[f"count{self._input_number - 1}"])
564565
) > 0:
565-
if self._last_state is None or value >= self._last_state:
566+
if self._last_state is None or value >= float(self._last_state):
566567
self._last_state = value / 1000
567568
return value / 1000
568569
_LOGGER.warning(

0 commit comments

Comments
 (0)