Use more shorthand attributes in huawei_lte binary_sensor (#100211)

This commit is contained in:
J. Nick Koston 2023-09-12 12:45:44 -05:00 committed by GitHub
parent 74a57e8676
commit 6a7d5a0fd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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."""