zha 2.2.0__tar.gz → 2.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. {zha-2.2.0/zha.egg-info → zha-2.2.2}/PKG-INFO +2 -2
  2. {zha-2.2.0 → zha-2.2.2}/pyproject.toml +1 -1
  3. zha-2.2.2/tests/test_cluster_config.py +133 -0
  4. {zha-2.2.0 → zha-2.2.2}/tests/test_sensor.py +48 -0
  5. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/__init__.py +13 -0
  6. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/virtual.py +48 -0
  7. {zha-2.2.0 → zha-2.2.2}/zha/zigbee/cluster_config.py +32 -17
  8. {zha-2.2.0 → zha-2.2.2/zha.egg-info}/PKG-INFO +2 -2
  9. {zha-2.2.0 → zha-2.2.2}/zha.egg-info/SOURCES.txt +1 -0
  10. {zha-2.2.0 → zha-2.2.2}/zha.egg-info/requires.txt +1 -1
  11. {zha-2.2.0 → zha-2.2.2}/LICENSE +0 -0
  12. {zha-2.2.0 → zha-2.2.2}/README.md +0 -0
  13. {zha-2.2.0 → zha-2.2.2}/setup.cfg +0 -0
  14. {zha-2.2.0 → zha-2.2.2}/setup.py +0 -0
  15. {zha-2.2.0 → zha-2.2.2}/tests/test_alarm_control_panel.py +0 -0
  16. {zha-2.2.0 → zha-2.2.2}/tests/test_application_helpers.py +0 -0
  17. {zha-2.2.0 → zha-2.2.2}/tests/test_async_.py +0 -0
  18. {zha-2.2.0 → zha-2.2.2}/tests/test_binary_sensor.py +0 -0
  19. {zha-2.2.0 → zha-2.2.2}/tests/test_button.py +0 -0
  20. {zha-2.2.0 → zha-2.2.2}/tests/test_climate.py +0 -0
  21. {zha-2.2.0 → zha-2.2.2}/tests/test_cover.py +0 -0
  22. {zha-2.2.0 → zha-2.2.2}/tests/test_debouncer.py +0 -0
  23. {zha-2.2.0 → zha-2.2.2}/tests/test_device.py +0 -0
  24. {zha-2.2.0 → zha-2.2.2}/tests/test_device_tracker.py +0 -0
  25. {zha-2.2.0 → zha-2.2.2}/tests/test_discover.py +0 -0
  26. {zha-2.2.0 → zha-2.2.2}/tests/test_event.py +0 -0
  27. {zha-2.2.0 → zha-2.2.2}/tests/test_fan.py +0 -0
  28. {zha-2.2.0 → zha-2.2.2}/tests/test_gateway.py +0 -0
  29. {zha-2.2.0 → zha-2.2.2}/tests/test_light.py +0 -0
  30. {zha-2.2.0 → zha-2.2.2}/tests/test_lock.py +0 -0
  31. {zha-2.2.0 → zha-2.2.2}/tests/test_number.py +0 -0
  32. {zha-2.2.0 → zha-2.2.2}/tests/test_platform_entity.py +0 -0
  33. {zha-2.2.0 → zha-2.2.2}/tests/test_platform_event.py +0 -0
  34. {zha-2.2.0 → zha-2.2.2}/tests/test_select.py +0 -0
  35. {zha-2.2.0 → zha-2.2.2}/tests/test_siren.py +0 -0
  36. {zha-2.2.0 → zha-2.2.2}/tests/test_switch.py +0 -0
  37. {zha-2.2.0 → zha-2.2.2}/tests/test_update.py +0 -0
  38. {zha-2.2.0 → zha-2.2.2}/tools/__init__.py +0 -0
  39. {zha-2.2.0 → zha-2.2.2}/tools/compare_constants.py +0 -0
  40. {zha-2.2.0 → zha-2.2.2}/tools/import_diagnostics.py +0 -0
  41. {zha-2.2.0 → zha-2.2.2}/tools/migrate_diagnostics.py +0 -0
  42. {zha-2.2.0 → zha-2.2.2}/tools/regenerate_diagnostics.py +0 -0
  43. {zha-2.2.0 → zha-2.2.2}/tools/regenerate_mypy_ignores.py +0 -0
  44. {zha-2.2.0 → zha-2.2.2}/zha/__init__.py +0 -0
  45. {zha-2.2.0 → zha-2.2.2}/zha/application/__init__.py +0 -0
  46. {zha-2.2.0 → zha-2.2.2}/zha/application/const.py +0 -0
  47. {zha-2.2.0 → zha-2.2.2}/zha/application/discovery.py +0 -0
  48. {zha-2.2.0 → zha-2.2.2}/zha/application/gateway.py +0 -0
  49. {zha-2.2.0 → zha-2.2.2}/zha/application/helpers.py +0 -0
  50. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/alarm_control_panel/__init__.py +0 -0
  51. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/alarm_control_panel/const.py +0 -0
  52. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/binary_sensor/__init__.py +0 -0
  53. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/binary_sensor/const.py +0 -0
  54. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/binary_sensor/device_class.py +0 -0
  55. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/button/__init__.py +0 -0
  56. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/button/const.py +0 -0
  57. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/climate/__init__.py +0 -0
  58. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/climate/const.py +0 -0
  59. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/const.py +0 -0
  60. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/cover/__init__.py +0 -0
  61. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/cover/const.py +0 -0
  62. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/device_tracker.py +0 -0
  63. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/event/__init__.py +0 -0
  64. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/event/const.py +0 -0
  65. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/fan/__init__.py +0 -0
  66. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/fan/const.py +0 -0
  67. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/fan/helpers.py +0 -0
  68. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/helpers.py +0 -0
  69. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/legacy_quirks.py +0 -0
  70. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/light/__init__.py +0 -0
  71. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/light/const.py +0 -0
  72. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/light/helpers.py +0 -0
  73. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/lock/__init__.py +0 -0
  74. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/lock/const.py +0 -0
  75. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/number/__init__.py +0 -0
  76. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/number/bacnet.py +0 -0
  77. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/number/const.py +0 -0
  78. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/number/device_class.py +0 -0
  79. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/select.py +0 -0
  80. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/sensor/__init__.py +0 -0
  81. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/sensor/const.py +0 -0
  82. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/sensor/device_class.py +0 -0
  83. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/sensor/helpers.py +0 -0
  84. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/siren.py +0 -0
  85. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/switch.py +0 -0
  86. {zha-2.2.0 → zha-2.2.2}/zha/application/platforms/update.py +0 -0
  87. {zha-2.2.0 → zha-2.2.2}/zha/async_.py +0 -0
  88. {zha-2.2.0 → zha-2.2.2}/zha/const.py +0 -0
  89. {zha-2.2.0 → zha-2.2.2}/zha/debounce.py +0 -0
  90. {zha-2.2.0 → zha-2.2.2}/zha/decorators.py +0 -0
  91. {zha-2.2.0 → zha-2.2.2}/zha/event.py +0 -0
  92. {zha-2.2.0 → zha-2.2.2}/zha/exceptions.py +0 -0
  93. {zha-2.2.0 → zha-2.2.2}/zha/mixins.py +0 -0
  94. {zha-2.2.0 → zha-2.2.2}/zha/quirks.py +0 -0
  95. {zha-2.2.0 → zha-2.2.2}/zha/units.py +0 -0
  96. {zha-2.2.0 → zha-2.2.2}/zha/zigbee/__init__.py +0 -0
  97. {zha-2.2.0 → zha-2.2.2}/zha/zigbee/device.py +0 -0
  98. {zha-2.2.0 → zha-2.2.2}/zha/zigbee/endpoint.py +0 -0
  99. {zha-2.2.0 → zha-2.2.2}/zha/zigbee/group.py +0 -0
  100. {zha-2.2.0 → zha-2.2.2}/zha.egg-info/dependency_links.txt +0 -0
  101. {zha-2.2.0 → zha-2.2.2}/zha.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zha
3
- Version: 2.2.0
3
+ Version: 2.2.2
4
4
  Summary: Library implementing ZHA for Home Assistant
5
5
  Author-email: "David F. Mulcahey" <david.mulcahey@icloud.com>
6
6
  License: Apache-2.0
@@ -16,7 +16,7 @@ Requires-Dist: zigpy-deconz==1.0.0
16
16
  Requires-Dist: zigpy-xbee==0.22.0
17
17
  Requires-Dist: zigpy-zigate==0.14.0
18
18
  Requires-Dist: zigpy-ziggurat==1.1.1
19
- Requires-Dist: zigpy==2.1.0
19
+ Requires-Dist: zigpy==2.2.0
20
20
  Provides-Extra: testing
21
21
  Requires-Dist: pytest; extra == "testing"
22
22
  Requires-Dist: coloredlogs; extra == "testing"
@@ -22,7 +22,7 @@ dependencies = [
22
22
  "zigpy-xbee==0.22.0",
23
23
  "zigpy-zigate==0.14.0",
24
24
  "zigpy-ziggurat==1.1.1",
25
- "zigpy==2.1.0",
25
+ "zigpy==2.2.0",
26
26
  ]
27
27
 
28
28
  [tool.setuptools.packages.find]
@@ -0,0 +1,133 @@
1
+ """Tests for cluster configuration aggregation."""
2
+
3
+ from unittest.mock import patch
4
+
5
+ import pytest
6
+ import zigpy.profiles.zha
7
+ from zigpy.zcl import ReportingConfig
8
+ from zigpy.zcl.clusters import general, homeautomation
9
+
10
+ from tests.common import (
11
+ SIG_EP_INPUT,
12
+ SIG_EP_OUTPUT,
13
+ SIG_EP_PROFILE,
14
+ SIG_EP_TYPE,
15
+ create_mock_zigpy_device,
16
+ join_zigpy_device,
17
+ )
18
+ from zha.application.gateway import Gateway
19
+ from zha.application.platforms import AttrConfig, ClusterConfig, sensor
20
+ from zha.zigbee.cluster_config import AggregatedAttrConfig
21
+
22
+ # A tight, non-overriding config, like the ones ZHA's built-in entities declare
23
+ DEFAULT = ReportingConfig(min_interval=5, max_interval=900, reportable_change=1)
24
+ RELAXED = ReportingConfig(min_interval=30, max_interval=3600, reportable_change=100)
25
+ RELAXED_TIGHTER = ReportingConfig(
26
+ min_interval=10, max_interval=1800, reportable_change=50
27
+ )
28
+
29
+
30
+ def test_merge_tightest_wins_by_default() -> None:
31
+ """Without overrides, the tightest of each reporting field wins."""
32
+ agg = AggregatedAttrConfig()
33
+ agg.merge(AttrConfig(read_on_startup=False, reporting=RELAXED))
34
+ agg.merge(AttrConfig(read_on_startup=True, reporting=DEFAULT))
35
+ assert agg.read_on_startup is True
36
+ assert agg.reporting_override is False
37
+ assert agg.reporting == DEFAULT
38
+
39
+
40
+ def test_merge_override_replaces_defaults() -> None:
41
+ """An overriding config replaces already merged non-overriding configs."""
42
+ agg = AggregatedAttrConfig()
43
+ agg.merge(AttrConfig(read_on_startup=True, reporting=DEFAULT))
44
+ agg.merge(
45
+ AttrConfig(read_on_startup=False, reporting=RELAXED, reporting_override=True)
46
+ )
47
+ assert agg.reporting_override is True
48
+ assert agg.reporting == RELAXED
49
+ # the fresh read is unaffected by the reporting override
50
+ assert agg.read_on_startup is True
51
+
52
+
53
+ def test_merge_override_ignores_later_defaults() -> None:
54
+ """Non-overriding configs merged after an override do not tighten it."""
55
+ agg = AggregatedAttrConfig()
56
+ agg.merge(
57
+ AttrConfig(read_on_startup=False, reporting=RELAXED, reporting_override=True)
58
+ )
59
+ agg.merge(AttrConfig(read_on_startup=False, reporting=DEFAULT))
60
+ assert agg.reporting == RELAXED
61
+
62
+
63
+ def test_merge_multiple_overrides_take_tightest() -> None:
64
+ """Multiple overriding configs are merged with each other."""
65
+ agg = AggregatedAttrConfig()
66
+ agg.merge(AttrConfig(read_on_startup=False, reporting=DEFAULT))
67
+ agg.merge(
68
+ AttrConfig(read_on_startup=False, reporting=RELAXED, reporting_override=True)
69
+ )
70
+ agg.merge(
71
+ AttrConfig(
72
+ read_on_startup=False, reporting=RELAXED_TIGHTER, reporting_override=True
73
+ )
74
+ )
75
+ assert agg.reporting == RELAXED_TIGHTER
76
+
77
+
78
+ def test_override_without_reporting_is_rejected() -> None:
79
+ """An overriding attr config must carry a reporting config."""
80
+ with pytest.raises(ValueError, match="requires a reporting config"):
81
+ AttrConfig(read_on_startup=True, reporting_override=True)
82
+
83
+
84
+ async def test_reporting_override_configures_relaxed_reporting(
85
+ zha_gateway: Gateway,
86
+ ) -> None:
87
+ """An entity's overriding reporting config replaces the built-in default."""
88
+ zigpy_device = create_mock_zigpy_device(
89
+ zha_gateway,
90
+ {
91
+ 1: {
92
+ SIG_EP_INPUT: [
93
+ general.Basic.cluster_id,
94
+ homeautomation.ElectricalMeasurement.cluster_id,
95
+ ],
96
+ SIG_EP_OUTPUT: [],
97
+ SIG_EP_TYPE: zigpy.profiles.zha.DeviceType.SMART_PLUG,
98
+ SIG_EP_PROFILE: zigpy.profiles.zha.PROFILE_ID,
99
+ }
100
+ },
101
+ )
102
+ cluster = zigpy_device.endpoints[1].electrical_measurement
103
+ em_attrs = homeautomation.ElectricalMeasurement.AttributeDefs
104
+
105
+ # Simulate a device-specific (e.g. quirk-provided) entity declaring a relaxed
106
+ # reporting config for `rms_voltage`, alongside the built-in voltage entity
107
+ # declaring the default one for the same attribute. Quirks key attributes by
108
+ # name (str) while built-in entities use the ZCLAttributeDef, so both spellings
109
+ # must aggregate to the same attribute.
110
+ override_config = {
111
+ homeautomation.ElectricalMeasurement.cluster_id: ClusterConfig(
112
+ bind=True,
113
+ attributes={
114
+ em_attrs.rms_voltage.name: AttrConfig(
115
+ read_on_startup=False,
116
+ reporting=RELAXED,
117
+ reporting_override=True,
118
+ ),
119
+ },
120
+ )
121
+ }
122
+ with patch.object(
123
+ sensor.ElectricalMeasurementRMSCurrent,
124
+ "_server_cluster_config",
125
+ override_config,
126
+ ):
127
+ await join_zigpy_device(zha_gateway, zigpy_device)
128
+
129
+ assert len(cluster.configure_reporting_multiple.mock_calls) == 1
130
+ configured = cluster.configure_reporting_multiple.mock_calls[0].args[0]
131
+ assert configured[em_attrs.rms_voltage] == RELAXED
132
+ # Attributes without an override keep the built-in default
133
+ assert configured[em_attrs.active_power] == DEFAULT
@@ -2190,3 +2190,51 @@ async def test_em_poller_runs_independently_of_entity_enabled_state(
2190
2190
  active_power.enable()
2191
2191
  assert active_power.enabled is True
2192
2192
  assert not poll_task.done()
2193
+
2194
+
2195
+ @pytest.mark.parametrize(
2196
+ (
2197
+ "device_file",
2198
+ "divisors",
2199
+ "expected_voltage_change",
2200
+ "expected_current_change",
2201
+ ),
2202
+ [
2203
+ # SONOFF S60 reports with divisors of 100: raw 100 / 5 are 1 V / 0.05 A
2204
+ ("sonoff-s60zbtpg-0x00001002.json", (100, 100), 100, 5),
2205
+ # Other devices keep the default raw reportable change
2206
+ ("shelly-1pm.json", (100, 1000), 1, 1),
2207
+ ],
2208
+ )
2209
+ async def test_sonoff_s60_electrical_measurement_reporting(
2210
+ zha_gateway: Gateway,
2211
+ device_file: str,
2212
+ divisors: tuple[int, int],
2213
+ expected_voltage_change: int,
2214
+ expected_current_change: int,
2215
+ ) -> None:
2216
+ """The SONOFF S60 plugs get relaxed voltage/current reporting configured."""
2217
+ zigpy_device = await zigpy_device_from_json(
2218
+ zha_gateway.application_controller, f"tests/data/devices/{device_file}"
2219
+ )
2220
+ cluster = zigpy_device.endpoints[1].electrical_measurement
2221
+ await join_zigpy_device(zha_gateway, zigpy_device)
2222
+
2223
+ # The raw reportable changes only mean 1 V / 0.05 A for these divisors
2224
+ assert (
2225
+ cluster.get(EMAttrs.ac_voltage_divisor.id),
2226
+ cluster.get(EMAttrs.ac_current_divisor.id),
2227
+ ) == divisors
2228
+
2229
+ assert len(cluster.configure_reporting_multiple.mock_calls) == 1
2230
+ configured = cluster.configure_reporting_multiple.call_args.args[0]
2231
+ assert configured[EMAttrs.rms_voltage] == ReportingConfig(
2232
+ min_interval=5, max_interval=900, reportable_change=expected_voltage_change
2233
+ )
2234
+ assert configured[EMAttrs.rms_current] == ReportingConfig(
2235
+ min_interval=5, max_interval=900, reportable_change=expected_current_change
2236
+ )
2237
+ # Other attributes are unaffected
2238
+ assert configured[EMAttrs.active_power] == ReportingConfig(
2239
+ min_interval=5, max_interval=900, reportable_change=1
2240
+ )
@@ -86,6 +86,19 @@ class AttrConfig:
86
86
  read_on_startup: bool
87
87
  reporting: ReportingConfig | None = None
88
88
 
89
+ # Whether `reporting` replaces the non-overriding reporting configs other
90
+ # entities declare for the same attribute, instead of being merged with them.
91
+ # By default the tightest config wins, which means a config can only ever make
92
+ # reporting more frequent. Device specific configs (e.g. from quirks) set this to
93
+ # relax ZHA's built-in defaults, such as for devices reporting with a high
94
+ # divisor. Multiple overriding configs are still merged with each other.
95
+ reporting_override: bool = False
96
+
97
+ def __post_init__(self) -> None:
98
+ """Validate the configuration."""
99
+ if self.reporting_override and self.reporting is None:
100
+ raise ValueError("reporting_override requires a reporting config")
101
+
89
102
 
90
103
  @dataclass(frozen=True)
91
104
  class ClusterConfig:
@@ -24,6 +24,7 @@ from zigpy.zcl import (
24
24
  )
25
25
  from zigpy.zcl.clusters.closures import DoorLock, WindowCovering
26
26
  from zigpy.zcl.clusters.general import Identify, LevelControl, OnOff, Ota, Scenes
27
+ from zigpy.zcl.clusters.homeautomation import ElectricalMeasurement
27
28
  from zigpy.zcl.clusters.lighting import Color
28
29
  from zigpy.zcl.clusters.lightlink import LightLink
29
30
  from zigpy.zcl.clusters.security import IasZone
@@ -1243,3 +1244,50 @@ class InovelliVzm35Init(VirtualEntity):
1243
1244
  },
1244
1245
  ),
1245
1246
  }
1247
+
1248
+
1249
+ # === Model-specific reporting overrides on standard clusters ===
1250
+
1251
+
1252
+ @register_entity(ElectricalMeasurement.cluster_id)
1253
+ class SonoffS60RelaxedElectricalMeasurementReporting(VirtualEntity):
1254
+ """Relaxed voltage/current reporting for the SONOFF S60 plugs.
1255
+
1256
+ These plugs report `rms_voltage` and `rms_current` with `ac_voltage_divisor` and
1257
+ `ac_current_divisor` of 100 (verified on S60ZBTPG firmware 0x00001002), so the
1258
+ default raw reportable change of 1 is 0.01 V / 0.01 A and the device reports at
1259
+ the 5-second minimum interval. Override with 1 V / 0.05 A.
1260
+
1261
+ Temporary workaround. Overriding configs are merged with each other (tightest
1262
+ wins), so this must be removed in the same release the S60 quirk starts
1263
+ declaring its own reporting override; it becomes redundant once reportable
1264
+ changes are divisor-aware for all devices.
1265
+ """
1266
+
1267
+ _unique_id_suffix = "sonoff_s60_em_reporting"
1268
+ _cluster_match = ClusterMatch(
1269
+ server_clusters=frozenset({ElectricalMeasurement.cluster_id}),
1270
+ manufacturers=frozenset({"SONOFF"}),
1271
+ models=frozenset({"S60ZBTPF", "S60ZBTPG"}),
1272
+ )
1273
+ _server_cluster_config = {
1274
+ ElectricalMeasurement.cluster_id: ClusterConfig(
1275
+ bind=True,
1276
+ attributes={
1277
+ ElectricalMeasurement.AttributeDefs.rms_voltage: AttrConfig(
1278
+ read_on_startup=False,
1279
+ reporting=ReportingConfig(
1280
+ min_interval=5, max_interval=900, reportable_change=100
1281
+ ),
1282
+ reporting_override=True,
1283
+ ),
1284
+ ElectricalMeasurement.AttributeDefs.rms_current: AttrConfig(
1285
+ read_on_startup=False,
1286
+ reporting=ReportingConfig(
1287
+ min_interval=5, max_interval=900, reportable_change=5
1288
+ ),
1289
+ reporting_override=True,
1290
+ ),
1291
+ },
1292
+ ),
1293
+ }
@@ -33,27 +33,42 @@ class AggregatedAttrConfig:
33
33
 
34
34
  read_on_startup: bool = False
35
35
  reporting: ReportingConfig | None = None
36
+ reporting_override: bool = False
36
37
 
37
38
  def merge(self, config: AttrConfig) -> None:
38
- """Merge another attribute config (fresh read and tightest reporting win)."""
39
+ """Merge another attribute config.
40
+
41
+ A fresh read wins over a cached one. For reporting, the tightest config wins,
42
+ except that overriding configs (`AttrConfig.reporting_override`) replace
43
+ non-overriding ones entirely and are only merged with other overriding configs.
44
+ """
39
45
  self.read_on_startup = self.read_on_startup or config.read_on_startup
40
46
 
41
- if config.reporting is not None:
42
- if self.reporting is None:
43
- self.reporting = config.reporting
44
- else:
45
- self.reporting = ReportingConfig(
46
- min_interval=min(
47
- self.reporting.min_interval, config.reporting.min_interval
48
- ),
49
- max_interval=min(
50
- self.reporting.max_interval, config.reporting.max_interval
51
- ),
52
- reportable_change=min(
53
- self.reporting.reportable_change,
54
- config.reporting.reportable_change,
55
- ),
56
- )
47
+ if config.reporting is None:
48
+ return
49
+
50
+ if config.reporting_override and not self.reporting_override:
51
+ # First overriding config: discard whatever the defaults merged to
52
+ self.reporting = config.reporting
53
+ self.reporting_override = True
54
+ elif self.reporting_override and not config.reporting_override:
55
+ # Non-overriding configs cannot tighten an override
56
+ return
57
+ elif self.reporting is None:
58
+ self.reporting = config.reporting
59
+ else:
60
+ self.reporting = ReportingConfig(
61
+ min_interval=min(
62
+ self.reporting.min_interval, config.reporting.min_interval
63
+ ),
64
+ max_interval=min(
65
+ self.reporting.max_interval, config.reporting.max_interval
66
+ ),
67
+ reportable_change=min(
68
+ self.reporting.reportable_change,
69
+ config.reporting.reportable_change,
70
+ ),
71
+ )
57
72
 
58
73
 
59
74
  @dataclass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zha
3
- Version: 2.2.0
3
+ Version: 2.2.2
4
4
  Summary: Library implementing ZHA for Home Assistant
5
5
  Author-email: "David F. Mulcahey" <david.mulcahey@icloud.com>
6
6
  License: Apache-2.0
@@ -16,7 +16,7 @@ Requires-Dist: zigpy-deconz==1.0.0
16
16
  Requires-Dist: zigpy-xbee==0.22.0
17
17
  Requires-Dist: zigpy-zigate==0.14.0
18
18
  Requires-Dist: zigpy-ziggurat==1.1.1
19
- Requires-Dist: zigpy==2.1.0
19
+ Requires-Dist: zigpy==2.2.0
20
20
  Provides-Extra: testing
21
21
  Requires-Dist: pytest; extra == "testing"
22
22
  Requires-Dist: coloredlogs; extra == "testing"
@@ -8,6 +8,7 @@ tests/test_async_.py
8
8
  tests/test_binary_sensor.py
9
9
  tests/test_button.py
10
10
  tests/test_climate.py
11
+ tests/test_cluster_config.py
11
12
  tests/test_cover.py
12
13
  tests/test_debouncer.py
13
14
  tests/test_device.py
@@ -6,7 +6,7 @@ zigpy-deconz==1.0.0
6
6
  zigpy-xbee==0.22.0
7
7
  zigpy-zigate==0.14.0
8
8
  zigpy-ziggurat==1.1.1
9
- zigpy==2.1.0
9
+ zigpy==2.2.0
10
10
 
11
11
  [testing]
12
12
  pytest
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes