From e10e27d809c90658cab5f019c981929ea6553958 Mon Sep 17 00:00:00 2001 From: roblandry Date: Mon, 4 Mar 2019 18:56:05 -0500 Subject: [PATCH] Add SmartThingsAccelCluster to ZHA binary_sensor (#21609) * Add SmartThingsAccelCluster to binary_sensor * Make corrections per discussion with @dmulcahey * Add missing const to gateway.py * Remove Acceleration from no sensor --- homeassistant/components/zha/binary_sensor.py | 3 ++- homeassistant/components/zha/core/const.py | 1 + homeassistant/components/zha/core/gateway.py | 7 ++++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/zha/binary_sensor.py b/homeassistant/components/zha/binary_sensor.py index a46ffdd305d..30f730f3de4 100644 --- a/homeassistant/components/zha/binary_sensor.py +++ b/homeassistant/components/zha/binary_sensor.py @@ -12,7 +12,7 @@ from .core.const import ( DATA_ZHA, DATA_ZHA_DISPATCHERS, ZHA_DISCOVERY_NEW, ON_OFF_CHANNEL, LEVEL_CHANNEL, ZONE_CHANNEL, SIGNAL_ATTR_UPDATED, SIGNAL_MOVE_LEVEL, SIGNAL_SET_LEVEL, ATTRIBUTE_CHANNEL, UNKNOWN, OPENING, ZONE, OCCUPANCY, - ATTR_LEVEL, SENSOR_TYPE) + ATTR_LEVEL, SENSOR_TYPE, ACCELERATION) from .entity import ZhaEntity _LOGGER = logging.getLogger(__name__) @@ -41,6 +41,7 @@ DEVICE_CLASS_REGISTRY = { OPENING: OPENING, ZONE: get_ias_device_class, OCCUPANCY: OCCUPANCY, + ACCELERATION: 'moving', } diff --git a/homeassistant/components/zha/core/const.py b/homeassistant/components/zha/core/const.py index ecaa1c9bd20..33376b056c6 100644 --- a/homeassistant/components/zha/core/const.py +++ b/homeassistant/components/zha/core/const.py @@ -68,6 +68,7 @@ UNKNOWN = 'unknown' OPENING = 'opening' ZONE = 'zone' OCCUPANCY = 'occupancy' +ACCELERATION = 'acceleration' ATTR_LEVEL = 'level' diff --git a/homeassistant/components/zha/core/gateway.py b/homeassistant/components/zha/core/gateway.py index dcaf0d4a3ba..42548d6bd1b 100644 --- a/homeassistant/components/zha/core/gateway.py +++ b/homeassistant/components/zha/core/gateway.py @@ -23,7 +23,7 @@ from .const import ( REPORT_CONFIG_ASAP, REPORT_CONFIG_DEFAULT, REPORT_CONFIG_MIN_INT, REPORT_CONFIG_MAX_INT, REPORT_CONFIG_OP, SIGNAL_REMOVE, NO_SENSOR_CLUSTERS, POWER_CONFIGURATION_CHANNEL, BINDABLE_CLUSTERS, - DATA_ZHA_GATEWAY) + DATA_ZHA_GATEWAY, ACCELERATION) from .device import ZHADevice, DeviceStatus from ..device_entity import ZhaDeviceEntity from .channels import ( @@ -452,7 +452,6 @@ def establish_device_mappings(): NO_SENSOR_CLUSTERS.append( zcl.clusters.general.PowerConfiguration.cluster_id) NO_SENSOR_CLUSTERS.append(zcl.clusters.lightlink.LightLink.cluster_id) - NO_SENSOR_CLUSTERS.append(SMARTTHINGS_ACCELERATION_CLUSTER) BINDABLE_CLUSTERS.append(zcl.clusters.general.LevelControl.cluster_id) BINDABLE_CLUSTERS.append(zcl.clusters.general.OnOff.cluster_id) @@ -501,6 +500,7 @@ def establish_device_mappings(): zcl.clusters.security.IasZone: 'binary_sensor', zcl.clusters.measurement.OccupancySensing: 'binary_sensor', zcl.clusters.hvac.Fan: 'fan', + SMARTTHINGS_ACCELERATION_CLUSTER: 'binary_sensor', }) SINGLE_OUTPUT_CLUSTER_DEVICE_CLASS.update({ @@ -523,7 +523,8 @@ def establish_device_mappings(): BINARY_SENSOR_TYPES.update({ zcl.clusters.measurement.OccupancySensing.cluster_id: OCCUPANCY, zcl.clusters.security.IasZone.cluster_id: ZONE, - zcl.clusters.general.OnOff.cluster_id: OPENING + zcl.clusters.general.OnOff.cluster_id: OPENING, + SMARTTHINGS_ACCELERATION_CLUSTER: ACCELERATION, }) CLUSTER_REPORT_CONFIGS.update({