Skip to content

Commit dd5ce76

Browse files
Make battery low sensor restore
1 parent c469bb6 commit dd5ce76

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

custom_components/battery_notes/binary_sensor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
config_validation as cv,
2525
device_registry as dr,
2626
entity_registry as er,
27+
template,
2728
)
2829
from homeassistant.helpers.event import (
2930
EventStateChangedData,
@@ -32,7 +33,6 @@
3233
async_track_template_result,
3334
)
3435

35-
from homeassistant.helpers import template
3636
from homeassistant.helpers.template import (
3737
Template,
3838
TemplateStateFromEntityId,
@@ -51,6 +51,7 @@
5151
async_track_entity_registry_updated_event,
5252
)
5353
from homeassistant.helpers.reload import async_setup_reload_service
54+
from homeassistant.helpers.restore_state import RestoreEntity
5455

5556
from homeassistant.const import (
5657
CONF_NAME,
@@ -313,7 +314,7 @@ def handle_result(
313314

314315

315316
class BatteryNotesBatteryLowTemplateSensor(
316-
BinarySensorEntity, CoordinatorEntity[BatteryNotesCoordinator]
317+
BinarySensorEntity, CoordinatorEntity[BatteryNotesCoordinator], RestoreEntity
317318
):
318319
"""Represents a low battery threshold binary sensor."""
319320

custom_components/battery_notes/coordinator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class BatteryNotesCoordinator(DataUpdateCoordinator):
5858
battery_type: str
5959
battery_quantity: int
6060
battery_low_threshold: int
61-
battery_low_template: str
61+
battery_low_template: str | None
6262
wrapped_battery: RegistryEntry
6363
_current_battery_level: str = None
6464
enable_replaced: bool = True

0 commit comments

Comments
 (0)