From dc973a28dd251cde75358ac14de6989f2cded8c4 Mon Sep 17 00:00:00 2001 From: TheJulianJES Date: Wed, 15 Feb 2023 19:12:29 +0100 Subject: [PATCH 1/2] Initialize consumer_connected attribute --- .../components/zha/core/channels/manufacturerspecific.py | 1 + 1 file changed, 1 insertion(+) diff --git a/homeassistant/components/zha/core/channels/manufacturerspecific.py b/homeassistant/components/zha/core/channels/manufacturerspecific.py index e6b88a6c9adf2..85a478b0d4dd5 100644 --- a/homeassistant/components/zha/core/channels/manufacturerspecific.py +++ b/homeassistant/components/zha/core/channels/manufacturerspecific.py @@ -125,6 +125,7 @@ def __init__(self, cluster: zigpy.zcl.Cluster, ch_pool: ChannelPool) -> None: elif self.cluster.endpoint.model in ("lumi.plug.mmeu01", "lumi.plug.maeu01"): self.ZCL_INIT_ATTRS = { "power_outage_memory": True, + "consumer_connected": True, } elif self.cluster.endpoint.model == "aqara.feeder.acn001": self.ZCL_INIT_ATTRS = { From f275369da64ba78a304fca62a6b9a1cbd87a1d34 Mon Sep 17 00:00:00 2001 From: TheJulianJES Date: Wed, 15 Feb 2023 19:14:42 +0100 Subject: [PATCH 2/2] Add binary sensor for consumer_connected --- homeassistant/components/zha/binary_sensor.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/homeassistant/components/zha/binary_sensor.py b/homeassistant/components/zha/binary_sensor.py index af7ce6b5bf71e..dc5a5eebbaa12 100644 --- a/homeassistant/components/zha/binary_sensor.py +++ b/homeassistant/components/zha/binary_sensor.py @@ -203,3 +203,13 @@ class AqaraPetFeederErrorDetected(BinarySensor, id_suffix="error_detected"): SENSOR_ATTR = "error_detected" _attr_device_class: BinarySensorDeviceClass = BinarySensorDeviceClass.PROBLEM _attr_name: str = "Error detected" + + +@MULTI_MATCH( + channel_names="opple_cluster", models={"lumi.plug.mmeu01", "lumi.plug.maeu01"} +) +class XiaomiPlugConsumerConnected(BinarySensor, id_suffix="consumer_connected"): + """ZHA Xiaomi plug consumer connected binary sensor.""" + + SENSOR_ATTR = "consumer_connected" + _attr_name: str = "Consumer connected"