mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Set GoogleEntity entity_id in constructor (#124830)
This commit is contained in:
parent
3d39f6ce88
commit
4b59ef4733
@ -521,7 +521,7 @@ def supported_traits_for_state(state: State) -> list[type[trait._Trait]]:
|
|||||||
class GoogleEntity:
|
class GoogleEntity:
|
||||||
"""Adaptation of Entity expressed in Google's terms."""
|
"""Adaptation of Entity expressed in Google's terms."""
|
||||||
|
|
||||||
__slots__ = ("hass", "config", "state", "_traits")
|
__slots__ = ("hass", "config", "state", "entity_id", "_traits")
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, hass: HomeAssistant, config: AbstractConfig, state: State
|
self, hass: HomeAssistant, config: AbstractConfig, state: State
|
||||||
@ -530,17 +530,13 @@ class GoogleEntity:
|
|||||||
self.hass = hass
|
self.hass = hass
|
||||||
self.config = config
|
self.config = config
|
||||||
self.state = state
|
self.state = state
|
||||||
|
self.entity_id = state.entity_id
|
||||||
self._traits: list[trait._Trait] | None = None
|
self._traits: list[trait._Trait] | None = None
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Return the representation."""
|
"""Return the representation."""
|
||||||
return f"<GoogleEntity {self.state.entity_id}: {self.state.name}>"
|
return f"<GoogleEntity {self.state.entity_id}: {self.state.name}>"
|
||||||
|
|
||||||
@property
|
|
||||||
def entity_id(self):
|
|
||||||
"""Return entity ID."""
|
|
||||||
return self.state.entity_id
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def traits(self) -> list[trait._Trait]:
|
def traits(self) -> list[trait._Trait]:
|
||||||
"""Return traits for entity."""
|
"""Return traits for entity."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user