Remove logbook split_entity_id caching (#71359)

pull/71367/head
J. Nick Koston 2022-05-05 14:48:45 -04:00 committed by GitHub
parent d9a7c4a483
commit 8f5e61ee80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 13 deletions

View File

@ -354,10 +354,11 @@ def humanify(
# Process events # Process events
for event in events_batch: for event in events_batch:
if event.event_type == EVENT_STATE_CHANGED: if event.event_type == EVENT_STATE_CHANGED:
if event.domain != SENSOR_DOMAIN:
continue
entity_id = event.entity_id entity_id = event.entity_id
if entity_id in continuous_sensors: if (
entity_id in continuous_sensors
or split_entity_id(entity_id)[0] != SENSOR_DOMAIN
):
continue continue
assert entity_id is not None assert entity_id is not None
continuous_sensors[entity_id] = _is_sensor_continuous(hass, entity_id) continuous_sensors[entity_id] = _is_sensor_continuous(hass, entity_id)
@ -378,10 +379,9 @@ def humanify(
for event in events_batch: for event in events_batch:
if event.event_type == EVENT_STATE_CHANGED: if event.event_type == EVENT_STATE_CHANGED:
entity_id = event.entity_id entity_id = event.entity_id
domain = event.domain
assert entity_id is not None assert entity_id is not None
if domain == SENSOR_DOMAIN and continuous_sensors[entity_id]: if continuous_sensors.get(entity_id):
# Skip continuous sensors # Skip continuous sensors
continue continue
@ -872,14 +872,6 @@ class LazyEventPartialState:
self.time_fired_minute: int = self._row.time_fired.minute self.time_fired_minute: int = self._row.time_fired.minute
self._event_data_cache = event_data_cache self._event_data_cache = event_data_cache
@property
def domain(self) -> str | None:
"""Return the domain for the state."""
if self._domain is None:
assert self.entity_id is not None
self._domain = split_entity_id(self.entity_id)[0]
return self._domain
@property @property
def attributes_icon(self) -> str | None: def attributes_icon(self) -> str | None:
"""Extract the icon from the decoded attributes or json.""" """Extract the icon from the decoded attributes or json."""