mirror of
https://github.com/home-assistant/core.git
synced 2025-07-07 13:27:09 +00:00
Use more shorthand attributes in huawei_lte binary_sensor (#100211)
This commit is contained in:
parent
74a57e8676
commit
6a7d5a0fd4
@ -52,15 +52,12 @@ async def async_setup_entry(
|
||||
class HuaweiLteBaseBinarySensor(HuaweiLteBaseEntityWithDevice, BinarySensorEntity):
|
||||
"""Huawei LTE binary sensor device base class."""
|
||||
|
||||
_attr_entity_registry_enabled_default = False
|
||||
|
||||
key: str = field(init=False)
|
||||
item: str = field(init=False)
|
||||
_raw_state: str | None = field(default=None, init=False)
|
||||
|
||||
@property
|
||||
def entity_registry_enabled_default(self) -> bool:
|
||||
"""Return if the entity should be enabled when first added to the entity registry."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def _device_unique_id(self) -> str:
|
||||
return f"{self.key}.{self.item}"
|
||||
@ -106,6 +103,7 @@ class HuaweiLteMobileConnectionBinarySensor(HuaweiLteBaseBinarySensor):
|
||||
"""Huawei LTE mobile connection binary sensor."""
|
||||
|
||||
_attr_name: str = field(default="Mobile connection", init=False)
|
||||
_attr_entity_registry_enabled_default = True
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
"""Initialize identifiers."""
|
||||
@ -135,11 +133,6 @@ class HuaweiLteMobileConnectionBinarySensor(HuaweiLteBaseBinarySensor):
|
||||
"""Return mobile connectivity sensor icon."""
|
||||
return "mdi:signal" if self.is_on else "mdi:signal-off"
|
||||
|
||||
@property
|
||||
def entity_registry_enabled_default(self) -> bool:
|
||||
"""Return if the entity should be enabled when first added to the entity registry."""
|
||||
return True
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> dict[str, Any] | None:
|
||||
"""Get additional attributes related to connection status."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user