Add Aqara smoke sensor entities to ZHA (#90159)

* Add Aqara smoke sensor entities (WIP)

* Update smoke sensor entities (WIP)

* Drop two init attributes

* Move self-test button

* Remove self-test switch, add icons

* Add smoke sensor dbm entity

* Also add SMOKE device class to linkage alarm

Note: Enable "Linkage alarm" for this
This commit is contained in:
TheJulianJES 2023-03-29 03:30:56 +02:00 committed by GitHub
parent 12f49006cf
commit 47a2598b66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 92 additions and 0 deletions

View File

@ -240,3 +240,12 @@ class AqaraThermostatExternalSensor(BinarySensor, id_suffix="sensor"):
SENSOR_ATTR = "sensor"
_attr_entity_category: EntityCategory = EntityCategory.DIAGNOSTIC
_attr_name: str = "External sensor"
@MULTI_MATCH(channel_names="opple_cluster", models={"lumi.sensor_smoke.acn03"})
class AqaraLinkageAlarmState(BinarySensor, id_suffix="linkage_alarm_state"):
"""ZHA Aqara linkage alarm state binary sensor."""
SENSOR_ATTR = "linkage_alarm_state"
_attr_name: str = "Linkage alarm state"
_attr_device_class: BinarySensorDeviceClass = BinarySensorDeviceClass.SMOKE

View File

@ -184,3 +184,15 @@ class AqaraPetFeederFeedButton(ZHAAttributeButton, id_suffix="feeding"):
_attribute_name = "feeding"
_attr_name = "Feed"
_attribute_value = 1
@CONFIG_DIAGNOSTIC_MATCH(
channel_names="opple_cluster", models={"lumi.sensor_smoke.acn03"}
)
class AqaraSelfTestButton(ZHAAttributeButton, id_suffix="self_test"):
"""Defines a ZHA self-test button for Aqara smoke sensors."""
_attribute_name = "self_test"
_attr_name = "Self-test"
_attribute_value = 1
_attr_entity_category = EntityCategory.CONFIG

View File

@ -152,6 +152,15 @@ class OppleRemote(ZigbeeChannel):
"schedule": True,
"sensor": True,
}
elif self.cluster.endpoint.model == "lumi.sensor_smoke.acn03":
self.ZCL_INIT_ATTRS = {
"buzzer_manual_mute": True,
"smoke_density": True,
"heartbeat_indicator": True,
"buzzer_manual_alarm": True,
"buzzer": True,
"linkage_alarm": True,
}
async def async_initialize_channel_specific(self, from_cache: bool) -> None:
"""Initialize channel specific."""

View File

@ -955,3 +955,15 @@ class AqaraPetFeederWeightDispensed(Sensor, id_suffix="weight_dispensed"):
_attr_native_unit_of_measurement = UnitOfMass.GRAMS
_attr_state_class: SensorStateClass = SensorStateClass.TOTAL_INCREASING
_attr_icon: str = "mdi:weight-gram"
@MULTI_MATCH(channel_names="opple_cluster", models={"lumi.sensor_smoke.acn03"})
class AqaraSmokeDensityDbm(Sensor, id_suffix="smoke_density_dbm"):
"""Sensor that displays the smoke density of an Aqara smoke sensor in dB/m."""
SENSOR_ATTR = "smoke_density_dbm"
_attr_name: str = "Smoke density"
_attr_native_unit_of_measurement = "dB/m"
_attr_state_class: SensorStateClass = SensorStateClass.MEASUREMENT
_attr_icon: str = "mdi:google-circles-communities"
_attr_suggested_display_precision: int = 3

View File

@ -506,3 +506,53 @@ class AqaraThermostatChildLock(ZHASwitchConfigurationEntity, id_suffix="child_lo
_zcl_attribute: str = "child_lock"
_attr_name = "Child lock"
_attr_icon: str = "mdi:account-lock"
@CONFIG_DIAGNOSTIC_MATCH(
channel_names="opple_cluster", models={"lumi.sensor_smoke.acn03"}
)
class AqaraHeartbeatIndicator(
ZHASwitchConfigurationEntity, id_suffix="heartbeat_indicator"
):
"""Representation of a heartbeat indicator configuration entity for Aqara smoke sensors."""
_zcl_attribute: str = "heartbeat_indicator"
_attr_name = "Heartbeat indicator"
_attr_icon: str = "mdi:heart-flash"
@CONFIG_DIAGNOSTIC_MATCH(
channel_names="opple_cluster", models={"lumi.sensor_smoke.acn03"}
)
class AqaraLinkageAlarm(ZHASwitchConfigurationEntity, id_suffix="linkage_alarm"):
"""Representation of a linkage alarm configuration entity for Aqara smoke sensors."""
_zcl_attribute: str = "linkage_alarm"
_attr_name = "Linkage alarm"
_attr_icon: str = "mdi:shield-link-variant"
@CONFIG_DIAGNOSTIC_MATCH(
channel_names="opple_cluster", models={"lumi.sensor_smoke.acn03"}
)
class AqaraBuzzerManualMute(
ZHASwitchConfigurationEntity, id_suffix="buzzer_manual_mute"
):
"""Representation of a buzzer manual mute configuration entity for Aqara smoke sensors."""
_zcl_attribute: str = "buzzer_manual_mute"
_attr_name = "Buzzer manual mute"
_attr_icon: str = "mdi:volume-off"
@CONFIG_DIAGNOSTIC_MATCH(
channel_names="opple_cluster", models={"lumi.sensor_smoke.acn03"}
)
class AqaraBuzzerManualAlarm(
ZHASwitchConfigurationEntity, id_suffix="buzzer_manual_alarm"
):
"""Representation of a buzzer manual mute configuration entity for Aqara smoke sensors."""
_zcl_attribute: str = "buzzer_manual_alarm"
_attr_name = "Buzzer manual alarm"
_attr_icon: str = "mdi:bullhorn"