diff --git a/homeassistant/components/zha/binary_sensor.py b/homeassistant/components/zha/binary_sensor.py index a0d8abc1233..e6f03a8a848 100644 --- a/homeassistant/components/zha/binary_sensor.py +++ b/homeassistant/components/zha/binary_sensor.py @@ -20,6 +20,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect from .core import discovery from .core.const import ( CHANNEL_ACCELEROMETER, + CHANNEL_BINARY_INPUT, CHANNEL_OCCUPANCY, CHANNEL_ON_OFF, CHANNEL_ZONE, @@ -136,6 +137,13 @@ class Opening(BinarySensor): DEVICE_CLASS = DEVICE_CLASS_OPENING +@STRICT_MATCH(channel_names=CHANNEL_BINARY_INPUT) +class BinaryInput(BinarySensor): + """ZHA BinarySensor.""" + + SENSOR_ATTR = "present_value" + + @STRICT_MATCH( channel_names=CHANNEL_ON_OFF, manufacturers="IKEA of Sweden", diff --git a/homeassistant/components/zha/core/const.py b/homeassistant/components/zha/core/const.py index 76f025dd79a..04ed3ba4281 100644 --- a/homeassistant/components/zha/core/const.py +++ b/homeassistant/components/zha/core/const.py @@ -73,6 +73,7 @@ BAUD_RATES = [2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200, 128000, 2560 BINDINGS = "bindings" CHANNEL_ACCELEROMETER = "accelerometer" +CHANNEL_BINARY_INPUT = "binary_input" CHANNEL_ANALOG_INPUT = "analog_input" CHANNEL_ANALOG_OUTPUT = "analog_output" CHANNEL_ATTRIBUTE = "attribute" diff --git a/homeassistant/components/zha/core/registries.py b/homeassistant/components/zha/core/registries.py index 04e97f8b7ed..53425e329c0 100644 --- a/homeassistant/components/zha/core/registries.py +++ b/homeassistant/components/zha/core/registries.py @@ -66,6 +66,7 @@ SINGLE_INPUT_CLUSTER_DEVICE_CLASS = { VOC_LEVEL_CLUSTER: SENSOR, zcl.clusters.closures.DoorLock.cluster_id: LOCK, zcl.clusters.closures.WindowCovering.cluster_id: COVER, + zcl.clusters.general.BinaryInput.cluster_id: BINARY_SENSOR, zcl.clusters.general.AnalogInput.cluster_id: SENSOR, zcl.clusters.general.AnalogOutput.cluster_id: NUMBER, zcl.clusters.general.MultistateInput.cluster_id: SENSOR, diff --git a/tests/components/zha/zha_devices_list.py b/tests/components/zha/zha_devices_list.py index 1ea52d4e604..004be25d21f 100644 --- a/tests/components/zha/zha_devices_list.py +++ b/tests/components/zha/zha_devices_list.py @@ -1398,6 +1398,11 @@ DEVICES = [ "entity_class": "ElectricalMeasurement", "entity_id": "sensor.lumi_lumi_plug_maus01_77665544_electrical_measurement", }, + ("binary_sensor", "00:11:22:33:44:55:66:77-100-15"): { + "channels": ["binary_input"], + "entity_class": "BinaryInput", + "entity_id": "binary_sensor.lumi_lumi_plug_maus01_77665544_binary_input", + }, }, "event_channels": ["1:0x0019"], "manufacturer": "LUMI", @@ -2659,7 +2664,12 @@ DEVICES = [ "channels": ["power"], "entity_class": "Battery", "entity_id": "sensor.philips_rwl020_77665544_power", - } + }, + ("binary_sensor", "00:11:22:33:44:55:66:77-2-15"): { + "channels": ["binary_input"], + "entity_class": "BinaryInput", + "entity_id": "binary_sensor.philips_rwl020_77665544_binary_input", + }, }, "event_channels": ["1:0x0005", "1:0x0006", "1:0x0008", "2:0x0019"], "manufacturer": "Philips", @@ -2741,7 +2751,7 @@ DEVICES = [ }, ("binary_sensor", "00:11:22:33:44:55:66:77-1-64514"): { "channels": ["manufacturer_specific"], - "entity_class": "BinarySensor", + "entity_class": "BinaryInput", "entity_id": "binary_sensor.samjin_multi_77665544_manufacturer_specific", "default_match": True, }, @@ -3099,6 +3109,11 @@ DEVICES = [ "entity_class": "ElectricalMeasurement", "entity_id": "sensor.smartthings_outletv4_77665544_electrical_measurement", }, + ("binary_sensor", "00:11:22:33:44:55:66:77-1-15"): { + "channels": ["binary_input"], + "entity_class": "BinaryInput", + "entity_id": "binary_sensor.smartthings_outletv4_77665544_binary_input", + }, }, "event_channels": ["1:0x0019"], "manufacturer": "SmartThings", @@ -3122,7 +3137,12 @@ DEVICES = [ "channels": ["power"], "entity_class": "ZHADeviceScannerEntity", "entity_id": "device_tracker.smartthings_tagv4_77665544_power", - } + }, + ("binary_sensor", "00:11:22:33:44:55:66:77-1-15"): { + "channels": ["binary_input"], + "entity_class": "BinaryInput", + "entity_id": "binary_sensor.smartthings_tagv4_77665544_binary_input", + }, }, "event_channels": ["1:0x0019"], "manufacturer": "SmartThings",