mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use shorthand attributes in Starline (#99882)
This commit is contained in:
parent
4e826f1704
commit
92628ea068
@ -21,6 +21,8 @@ class StarlineEntity(Entity):
|
|||||||
self._account = account
|
self._account = account
|
||||||
self._device = device
|
self._device = device
|
||||||
self._key = key
|
self._key = key
|
||||||
|
self._attr_unique_id = f"starline-{key}-{device.device_id}"
|
||||||
|
self._attr_device_info = account.device_info(device)
|
||||||
self._unsubscribe_api: Callable | None = None
|
self._unsubscribe_api: Callable | None = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -28,16 +30,6 @@ class StarlineEntity(Entity):
|
|||||||
"""Return True if entity is available."""
|
"""Return True if entity is available."""
|
||||||
return self._account.api.available
|
return self._account.api.available
|
||||||
|
|
||||||
@property
|
|
||||||
def unique_id(self):
|
|
||||||
"""Return the unique ID of the entity."""
|
|
||||||
return f"starline-{self._key}-{self._device.device_id}"
|
|
||||||
|
|
||||||
@property
|
|
||||||
def device_info(self):
|
|
||||||
"""Return the device info."""
|
|
||||||
return self._account.device_info(self._device)
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Read new state data."""
|
"""Read new state data."""
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
@ -77,6 +77,8 @@ class StarlineSwitch(StarlineEntity, SwitchEntity):
|
|||||||
|
|
||||||
entity_description: StarlineSwitchEntityDescription
|
entity_description: StarlineSwitchEntityDescription
|
||||||
|
|
||||||
|
_attr_assumed_state = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
account: StarlineAccount,
|
account: StarlineAccount,
|
||||||
@ -108,11 +110,6 @@ class StarlineSwitch(StarlineEntity, SwitchEntity):
|
|||||||
else self.entity_description.icon_off
|
else self.entity_description.icon_off
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
|
||||||
def assumed_state(self):
|
|
||||||
"""Return True if unable to access real state of the entity."""
|
|
||||||
return True
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
"""Return True if entity is on."""
|
"""Return True if entity is on."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user