Add configure_reporting() method to zha component (#16487)

* Add zha.configure_reporting() method.

Binds a cluster and configures reporting for the specified attribute.

* git add homeassistant/components/binary_sensor/zha.py

* Refactor sensor.zha to use new 'configure_reporting() method.

* Zha configure reporting - switch (#1)

* use configure_reporting for zha switch

* lint fixes

* Rename variables/classes to properly reflect the content
This commit is contained in:
Alexei Chetroi authored and Paulus Schoutsen committed 2018-09-13 09:11:47 +02:00
1 parent 1586d3000c
commit f2203e52ef
4 files changed
+66 -24

No files matched your search

+12 -6
View File
@@ -17,17 +17,23 @@ DEPENDENCIES = ['zha']
async def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
"""Set up the Zigbee Home Automation switches."""
from zigpy.zcl.clusters.general import OnOff
discovery_info = zha.get_discovery_info(hass, discovery_info)
if discovery_info is None:
return
from zigpy.zcl.clusters.general import OnOff
in_clusters = discovery_info['in_clusters']
cluster = in_clusters[OnOff.cluster_id]
await cluster.bind()
await cluster.configure_reporting(0, 0, 600, 1,)
switch = Switch(**discovery_info)
async_add_entities([Switch(**discovery_info)], update_before_add=True)
if discovery_info['new_join']:
in_clusters = discovery_info['in_clusters']
cluster = in_clusters[OnOff.cluster_id]
await zha.configure_reporting(
switch.entity_id, cluster, switch.value_attribute,
min_report=0, max_report=600, reportable_change=1
)
async_add_entities([switch], update_before_add=True)
class Switch(zha.Entity, SwitchDevice):