feat: refactor code to add more attributes.

This commit is contained in:
sususweet
2025-09-24 19:57:11 +08:00
parent 39f88365e5
commit 51f0fcc8dc
10 changed files with 299 additions and 223 deletions

View File

@@ -57,18 +57,17 @@ class MideaDeviceStatusSensorEntity(MideaEntity, BinarySensorEntity):
device.sn,
device.sn8,
device.model,
entity_key
entity_key,
device=device,
manufacturer=manufacturer,
rationale=rationale,
config=config,
)
self._device = device
self._manufacturer = manufacturer
self._rationale = rationale
self._config = config
@property
def entity_id_suffix(self) -> str:
"""Return the suffix for entity ID."""
return "status"
@property
def device_class(self):
"""Return the device class."""
@@ -102,7 +101,11 @@ class MideaBinarySensorEntity(MideaEntity, BinarySensorEntity):
device.sn,
device.sn8,
device.model,
entity_key
entity_key,
device=device,
manufacturer=manufacturer,
rationale=rationale,
config=config,
)
self._device = device
self._manufacturer = manufacturer
@@ -110,11 +113,6 @@ class MideaBinarySensorEntity(MideaEntity, BinarySensorEntity):
self._entity_key = entity_key
self._config = config
@property
def entity_id_suffix(self) -> str:
"""Return the suffix for entity ID."""
return f"binary_sensor_{self._entity_key}"
@property
def is_on(self):
"""Return if the binary sensor is on."""