diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index 909480d165b..52aac7cca79 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -1124,9 +1124,6 @@ class Entity( # Polling returned after the entity has already been removed return - hass = self.hass - entity_id = self.entity_id - if (entry := self.registry_entry) and entry.disabled_by: if not self._disabled_reported: self._disabled_reported = True @@ -1135,7 +1132,7 @@ class Entity( "Entity %s is incorrectly being triggered for updates while it" " is disabled. This is a bug in the %s integration" ), - entity_id, + self.entity_id, self.platform.platform_name, ) return @@ -1177,7 +1174,7 @@ class Entity( "Entity %s (%s) is updating its capabilities too often," " please %s" ), - entity_id, + self.entity_id, type(self), report_issue, ) @@ -1194,7 +1191,7 @@ class Entity( report_issue = self._suggest_report_issue() _LOGGER.warning( "Updating state for %s (%s) took %.3f seconds. Please %s", - entity_id, + self.entity_id, type(self), time_now - state_calculate_start, report_issue, @@ -1205,12 +1202,12 @@ class Entity( # set and since try is near zero cost # on py3.11+ its faster to assume it is # set and catch the exception if it is not. - customize = hass.data[DATA_CUSTOMIZE] + custom = self.hass.data[DATA_CUSTOMIZE].get(self.entity_id) except KeyError: pass else: # Overwrite properties that have been set in the config file. - if custom := customize.get(entity_id): + if custom: attr |= custom if ( @@ -1224,15 +1221,15 @@ class Entity( _LOGGER.error( "State %s for %s is longer than %s, falling back to %s", state, - entity_id, + self.entity_id, MAX_LENGTH_STATE_STATE, STATE_UNKNOWN, ) state = STATE_UNKNOWN # Intentionally called with positional args for performance reasons - hass.states.async_set_internal( - entity_id, + self.hass.states.async_set_internal( + self.entity_id, state, attr, self.force_update,