|
12 | 12 | from homeassistant.components.sensor import ( |
13 | 13 | PLATFORM_SCHEMA, |
14 | 14 | RestoreSensor, |
| 15 | + SensorDeviceClass, |
15 | 16 | SensorEntity, |
16 | 17 | SensorEntityDescription, |
| 18 | + SensorStateClass, |
17 | 19 | ) |
18 | | -from homeassistant.components.sensor.const import SensorDeviceClass, SensorStateClass |
19 | 20 | from homeassistant.config_entries import ConfigEntry |
20 | 21 | from homeassistant.const import ( |
21 | 22 | CONF_DEVICE_ID, |
22 | 23 | CONF_NAME, |
23 | 24 | PERCENTAGE, |
24 | 25 | STATE_UNAVAILABLE, |
25 | 26 | STATE_UNKNOWN, |
26 | | - EntityCategory, |
27 | | -) |
28 | | -from homeassistant.core import ( |
29 | | - Event, |
30 | | - EventStateReportedData, |
31 | | - HomeAssistant, |
32 | | - callback, |
33 | | - split_entity_id, |
34 | 27 | ) |
| 28 | +from homeassistant.core import Event, HomeAssistant, callback, split_entity_id |
35 | 29 | from homeassistant.helpers import ( |
36 | 30 | config_validation as cv, |
37 | 31 | ) |
|
41 | 35 | from homeassistant.helpers import ( |
42 | 36 | entity_registry as er, |
43 | 37 | ) |
44 | | -from homeassistant.helpers.device_registry import DeviceInfo |
| 38 | +from homeassistant.helpers.entity import DeviceInfo, EntityCategory |
45 | 39 | from homeassistant.helpers.entity_platform import AddEntitiesCallback |
46 | 40 | from homeassistant.helpers.entity_registry import ( |
47 | 41 | EVENT_ENTITY_REGISTRY_UPDATED, |
48 | 42 | ) |
49 | 43 | from homeassistant.helpers.event import ( |
50 | 44 | EventStateChangedData, |
| 45 | + EventStateReportedData, |
51 | 46 | async_track_entity_registry_updated_event, |
52 | 47 | async_track_state_change_event, |
53 | 48 | async_track_state_report_event, |
|
57 | 52 | from homeassistant.helpers.update_coordinator import ( |
58 | 53 | CoordinatorEntity, |
59 | 54 | ) |
60 | | -from propcache.api import cached_property |
61 | 55 |
|
62 | 56 | from .common import utcnow_no_timezone, validate_is_float |
63 | 57 | from .const import ( |
@@ -247,7 +241,7 @@ async def async_setup_platform( |
247 | 241 |
|
248 | 242 |
|
249 | 243 | class BatteryNotesBatteryPlusSensor( |
250 | | - SensorEntity, CoordinatorEntity[BatteryNotesCoordinator] |
| 244 | + RestoreSensor, SensorEntity, CoordinatorEntity[BatteryNotesCoordinator] |
251 | 245 | ): |
252 | 246 | """Represents a battery plus type sensor.""" |
253 | 247 |
|
@@ -580,7 +574,7 @@ def _handle_coordinator_update(self) -> None: |
580 | 574 |
|
581 | 575 | self.async_write_ha_state() |
582 | 576 |
|
583 | | - @cached_property |
| 577 | + @property |
584 | 578 | def extra_state_attributes(self) -> dict[str, Any] | None: |
585 | 579 | """Return the state attributes of the battery type.""" |
586 | 580 |
|
@@ -610,7 +604,7 @@ def extra_state_attributes(self) -> dict[str, Any] | None: |
610 | 604 | attrs.update(self._wrapped_attributes) |
611 | 605 | return attrs |
612 | 606 |
|
613 | | - @cached_property |
| 607 | + @property |
614 | 608 | def native_value(self) -> StateType | Any | datetime: |
615 | 609 | """Return the value reported by the sensor.""" |
616 | 610 | return self._attr_native_value |
|
0 commit comments