Skip to content

Commit fe0cb83

Browse files
Fix
1 parent e46e39b commit fe0cb83

File tree

4 files changed

+30
-11
lines changed

4 files changed

+30
-11
lines changed

custom_components/periodic_min_max/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
LOGGER: Logger = getLogger(__package__)
1010

11-
MIN_HA_VERSION = "2025.1"
11+
MIN_HA_VERSION = "2025.3"
1212

1313
manifestfile = Path(__file__).parent / "manifest.json"
1414
with open(file=manifestfile, encoding="UTF-8") as json_file:

custom_components/periodic_min_max/sensor.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ async def async_setup_platform(
9696

9797
await async_setup_reload_service(hass, DOMAIN, PLATFORMS)
9898

99-
async_add_entities([PeriodicMinMaxSensor(hass, entity_id, name, sensor_type, unique_id)])
99+
async_add_entities(
100+
[PeriodicMinMaxSensor(hass, entity_id, name, sensor_type, unique_id)]
101+
)
100102

101103

102104
class PeriodicMinMaxSensor(SensorEntity, RestoreEntity):
@@ -136,13 +138,14 @@ def __init__(
136138
self.max_value: float | None = None
137139
self._state: Any = None
138140

139-
140141
async def async_added_to_hass(self) -> None:
141142
"""Handle added to Hass."""
142143

143144
self.async_on_remove(
144145
async_track_state_change_event(
145-
self.hass, self._source_entity_id, self._async_min_max_sensor_state_listener
146+
self.hass,
147+
self._source_entity_id,
148+
self._async_min_max_sensor_state_listener,
146149
)
147150
)
148151

@@ -158,18 +161,34 @@ async def async_added_to_hass(self) -> None:
158161

159162
if entry:
160163
self._unit_of_measurement = entry.unit_of_measurement
161-
self._attr_device_class = SensorDeviceClass(entry.device_class) if entry.device_class else None
162-
self._attr_icon = entry.icon if entry.icon else entry.original_icon if entry.original_icon else ICON
164+
self._attr_device_class = (
165+
SensorDeviceClass(entry.device_class) if entry.device_class else None
166+
)
167+
self._attr_icon = (
168+
entry.icon
169+
if entry.icon
170+
else entry.original_icon
171+
if entry.original_icon
172+
else ICON
173+
)
163174

164175
state = await self.async_get_last_state()
165-
if state is not None and state.state not in [STATE_UNKNOWN, STATE_UNAVAILABLE]:
176+
if state is not None and state.state not in [
177+
STATE_UNKNOWN,
178+
STATE_UNAVAILABLE,
179+
]:
166180
self._state = float(state.state)
167181
self._calc_values()
168182

169183
# Replay current state of source entitiy
170184
state = self.hass.states.get(self._source_entity_id)
171185
state_event: Event[EventStateChangedData] = Event(
172-
"", {"entity_id": self._source_entity_id, "new_state": state, "old_state": None}
186+
"",
187+
{
188+
"entity_id": self._source_entity_id,
189+
"new_state": state,
190+
"old_state": None,
191+
},
173192
)
174193
self._async_min_max_sensor_state_listener(state_event, update_state=False)
175194

@@ -259,4 +278,4 @@ async def handle_reset(self) -> None:
259278
self.min_value = self._state
260279
self.max_value = self._state
261280

262-
self.async_write_ha_state()
281+
self.async_write_ha_state()

hacs.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"name": "Periodic Min/Max",
33
"filename": "periodic_min_max.zip",
44
"hide_default_branch": true,
5-
"homeassistant": "2025.1.0",
5+
"homeassistant": "2025.3.0",
66
"zip_release": true
77
}

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
colorlog==6.9.0
2-
homeassistant==2025.1.0
2+
homeassistant==2025.3.0
33
pip>=21.0,<25.1
44
ruff==0.11.2

0 commit comments

Comments
 (0)