From 8f5e61ee8083492c1a6bae307b370976744cf820 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 5 May 2022 14:48:45 -0400 Subject: [PATCH] Remove logbook split_entity_id caching (#71359) --- homeassistant/components/logbook/__init__.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/homeassistant/components/logbook/__init__.py b/homeassistant/components/logbook/__init__.py index 1c930cf3004..f29276489a2 100644 --- a/homeassistant/components/logbook/__init__.py +++ b/homeassistant/components/logbook/__init__.py @@ -354,10 +354,11 @@ def humanify( # Process events for event in events_batch: if event.event_type == EVENT_STATE_CHANGED: - if event.domain != SENSOR_DOMAIN: - continue 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 assert entity_id is not None continuous_sensors[entity_id] = _is_sensor_continuous(hass, entity_id) @@ -378,10 +379,9 @@ def humanify( for event in events_batch: if event.event_type == EVENT_STATE_CHANGED: entity_id = event.entity_id - domain = event.domain assert entity_id is not None - if domain == SENSOR_DOMAIN and continuous_sensors[entity_id]: + if continuous_sensors.get(entity_id): # Skip continuous sensors continue @@ -872,14 +872,6 @@ class LazyEventPartialState: self.time_fired_minute: int = self._row.time_fired.minute 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 def attributes_icon(self) -> str | None: """Extract the icon from the decoded attributes or json."""