Set GoogleEntity entity_id in constructor (#124830)

pull/124837/head^2
J. Nick Koston 2024-08-28 15:47:11 -10:00 committed by GitHub
parent 3d39f6ce88
commit 4b59ef4733
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 6 deletions

View File

@ -521,7 +521,7 @@ def supported_traits_for_state(state: State) -> list[type[trait._Trait]]:
class GoogleEntity:
"""Adaptation of Entity expressed in Google's terms."""
__slots__ = ("hass", "config", "state", "_traits")
__slots__ = ("hass", "config", "state", "entity_id", "_traits")
def __init__(
self, hass: HomeAssistant, config: AbstractConfig, state: State
@ -530,17 +530,13 @@ class GoogleEntity:
self.hass = hass
self.config = config
self.state = state
self.entity_id = state.entity_id
self._traits: list[trait._Trait] | None = None
def __repr__(self) -> str:
"""Return the representation."""
return f"<GoogleEntity {self.state.entity_id}: {self.state.name}>"
@property
def entity_id(self):
"""Return entity ID."""
return self.state.entity_id
@callback
def traits(self) -> list[trait._Trait]:
"""Return traits for entity."""