Skip to content

Commit fe5021d

Browse files
committed
overcomplication borke the number sensor
1 parent 27625e8 commit fe5021d

1 file changed

Lines changed: 3 additions & 14 deletions

File tree

custom_components/cardata/number.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,22 +165,11 @@ async def async_added_to_hass(self) -> None:
165165

166166
# Restore previous value
167167
last_state = await self.async_get_last_state()
168-
last_number_data = await self.async_get_last_number_data()
169-
170-
if last_number_data is not None and last_number_data.native_value is not None:
171-
value = last_number_data.native_value
172-
# Store restored value in coordinator
173-
if value > 0:
174-
self._coordinator.set_manual_battery_capacity(self._vin, value)
175-
_LOGGER.debug(
176-
"Restored manual battery capacity for %s: %.1f kWh",
177-
redact_vin(self._vin),
178-
value,
179-
)
180-
self._attr_native_value = value
181-
elif last_state is not None and last_state.state not in ("unknown", "unavailable"):
168+
169+
if last_state is not None and last_state.state not in ("unknown", "unavailable"):
182170
try:
183171
value = float(last_state.state)
172+
# Store restored value in coordinator
184173
if value > 0:
185174
self._coordinator.set_manual_battery_capacity(self._vin, value)
186175
_LOGGER.debug(

0 commit comments

Comments
 (0)