From 402dec34992c329a1a8a97f0c93295338fcc5b82 Mon Sep 17 00:00:00 2001 From: TheJulianJES Date: Fri, 28 Apr 2023 02:19:02 +0200 Subject: [PATCH 1/6] Add new GitHub issue forms (#2361) --- .github/ISSUE_TEMPLATE/bug_report.md | 59 --------- .github/ISSUE_TEMPLATE/bug_report.yml | 111 +++++++++++++++++ .../ISSUE_TEMPLATE/device-support-request.md | 49 -------- .../ISSUE_TEMPLATE/device_support_request.yml | 112 ++++++++++++++++++ 4 files changed, 223 insertions(+), 108 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml delete mode 100644 .github/ISSUE_TEMPLATE/device-support-request.md create mode 100644 .github/ISSUE_TEMPLATE/device_support_request.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index faac7643a6..0000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,59 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: "[BUG]" -labels: '' -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -
- -Device signature - -```yaml -Paste the device signature here. -Don't remove the extra line breaks outside the ``` marks. -``` - -
- -
- -Diagnostic information - -```yaml -Paste the diagnostic information here. -Don't remove the extra line breaks outside the ``` marks. -``` - -
- -
-Additional logs - -``` -Paste any additional debug logs here. -Don't remove the extra line breaks outside the ``` marks. -``` - -
- -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000000..1df59c40c9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,111 @@ +name: Bug report +description: Report a bug in an existing quirk or a general issue with the project. +title: "[BUG] " +body: + - type: markdown + attributes: + value: | + Before filing an issue, please try to reproduce your problem using the latest Home Assistant release. + Also, search the [existing issues](https://github.com/zigpy/zha-device-handlers/issues) to see if your bug has already been reported. + If you have a question, please use [GitHub discussions](https://github.com/zigpy/zha-device-handlers/discussions). + + If you're using custom quirks, remove them first. Then, restart HA and check if the issue persists. + Lastly, make sure to give your issue a descriptive title. + - type: markdown + attributes: + value: | + # General information + - type: textarea + attributes: + label: Bug description + description: Please describe the bug you are running into. + validations: + required: true + - type: textarea + attributes: + label: Steps to reproduce + description: Please describe the steps to reproduce the bug. + placeholder: | + 1. Go to '...' + 2. Click on '....' + 3. Scroll down to '....' + 4. See error + validations: + required: true + - type: textarea + attributes: + label: Expected behavior + description: Please describe what you expected to happen. + validations: + required: true + - type: textarea + attributes: + label: Screenshots/Video + description: | + If helpful, you can upload screenshots or a video relevant to your bug report. + value: | +
Screenshots/Video + + [Paste/upload your media here] + +
+ - type: markdown + attributes: + value: | + # Debug information + - type: textarea + attributes: + label: Device signature + description: | + You can find the device signature by going to the device page, clicking the three dots, clicking on "Manage Zigbee device", and then selecting the "Signature" tab at the top. + + Copy the contents and paste your device signature in between the lines with the backticks below. + value: | +
Device signature + + ```json + [Paste the device signature here] + ``` + +
+ - type: textarea + attributes: + label: Diagnostic information + description: | + You can find the diagnostic information of the device by going to the device page, clicking the three dots, and then by clicking on "Download diagnostics". + + Copy the contents of the downloaded text file and paste it in between the lines with the backticks below. + value: | +
Diagnostic information + + ```json + [Paste the diagnostic information here] + ``` + +
+ - type: textarea + attributes: + label: Logs + description: | + To help in resolving the issue faster, you can upload relevant logs here. + In some cases, it's helpful to enable debug logging, reproducing the issue again, and then uploading the logs. + + Note: To enable debug logging, see [this section](https://www.home-assistant.io/integrations/zha/#debug-logging), then restart Home Assistant, reproduce the issue again, and paste the relevant logs in between the lines with the backticks below. + + You can also enable debug logs at runtime by going to the integrations page in settings, clicking the three dots next to your ZHA integration, and selecting "Enable debug logging". + Reproduce the issue again, click on those three dots again, and select "Disable debug logging". + Then, copy the relevant log parts from the downloaded file and paste them in between the lines with the backticks below. + value: | +
Logs + + ```python + [Paste the logs here] + ``` + +
+ - type: textarea + attributes: + label: Additional information + description: | + If you have additional information or context about the problem, provide it here. + For example, if this issue only started with a specific Home Assistant Core release, please mention the last known working release. diff --git a/.github/ISSUE_TEMPLATE/device-support-request.md b/.github/ISSUE_TEMPLATE/device-support-request.md deleted file mode 100644 index 2253cde088..0000000000 --- a/.github/ISSUE_TEMPLATE/device-support-request.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -name: Device support request -about: Request support for an unsupported device or device feature -title: "[Device Support Request]" -labels: '' -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -
- -Device signature - -```yaml -Paste the device signature here. -Don't remove the extra line breaks outside the ``` marks. -``` - -
- -
- -Diagnostic information - -```yaml -Paste the diagnostic information here. -Don't remove the extra line breaks outside the ``` marks. -``` - -
- -
-Additional logs - -``` -Paste any additional debug logs here. -Don't remove the extra line breaks outside the ``` marks. -``` - -
- -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/device_support_request.yml b/.github/ISSUE_TEMPLATE/device_support_request.yml new file mode 100644 index 0000000000..f6817da271 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/device_support_request.yml @@ -0,0 +1,112 @@ +name: Device support request +description: Request support for an unsupported device or a missing device feature. +title: "[Device Support Request] " +body: + - type: markdown + attributes: + value: | + Before filing an issue, please try to reproduce your problem using the latest Home Assistant release. + Also, search the [existing issues](https://github.com/zigpy/zha-device-handlers/issues) to see if your device has already been reported. + If you have a question, please use [GitHub discussions](https://github.com/zigpy/zha-device-handlers/discussions). + + If you're using custom quirks, remove them first. Then, restart HA and check if the issue persists. + Lastly, make sure to give your issue a descriptive title. + - type: markdown + attributes: + value: | + # General information + - type: textarea + attributes: + label: Problem description + description: Is your feature request related to a problem? Please describe. + validations: + required: true + - type: textarea + attributes: + label: Solution description + description: Please describe what solution you would like. + validations: + required: true + - type: textarea + attributes: + label: Screenshots/Video + description: | + If helpful, you can upload screenshots or videos relevant to your feature request. + value: | +
Screenshots/Video + + [Paste/upload your media here] + +
+ - type: markdown + attributes: + value: | + # Debug information + - type: textarea + attributes: + label: Device signature + description: | + You can find the device signature by going to the device page, clicking the three dots, clicking on "Manage Zigbee device", and then selecting the "Signature" tab at the top. + + Copy the contents and paste your device signature in between the lines with the backticks below. + value: | +
Device signature + + ```json + [Paste the device signature here] + ``` + +
+ - type: textarea + attributes: + label: Diagnostic information + description: | + You can find the diagnostic information of the device by going to the device page, clicking the three dots, and then by clicking on "Download diagnostics". + + Copy the contents of the downloaded text file and paste it in between the lines with the backticks below. + value: | +
Diagnostic information + + ```json + [Paste the diagnostic information here] + ``` + +
+ - type: textarea + attributes: + label: Logs + description: | + If applicable, you can upload relevant logs here. + In some cases, it's helpful to enable debug logging, reproducing the issue again, and then uploading the logs. + + Note: To enable debug logging, see [this section](https://www.home-assistant.io/integrations/zha/#debug-logging), then restart Home Assistant, reproduce the issue again, and paste the relevant logs in between the lines with the backticks below. + + You can also enable debug logs at runtime by going to the integrations page in settings, clicking the three dots next to your ZHA integration, and selecting "Enable debug logging". + Reproduce the issue again, click on those three dots again, and select "Disable debug logging". + Then, copy the relevant log parts from the downloaded file and paste them in between the lines with the backticks below. + value: | +
Logs + + ```python + [Paste the logs here] + ``` + +
+ - type: textarea + attributes: + label: Custom quirk + description: | + If you've started working on a custom quirk, paste it in between the lines with the backticks below. + value: | +
Custom quirk + + ```python + [Paste your custom quirk here] + ``` + +
+ - type: textarea + attributes: + label: Additional information + description: | + If you have additional information or context about the feature request, provide it here. From 2014378d79de7523758fc6c60d574671284e505e Mon Sep 17 00:00:00 2001 From: TheJulianJES Date: Fri, 28 Apr 2023 02:19:16 +0200 Subject: [PATCH 2/6] Add PR template (#2362) --- .github/PULL_REQUEST_TEMPLATE.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000..33052ac329 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,24 @@ +## Proposed change + + + +## Additional information + + + +## Checklist + + +- [ ] The changes are tested and work correctly +- [ ] `pre-commit` checks pass / the code has been formatted using Black +- [ ] Tests have been added to verify that the new code works From d43adc2692d65254a862f22e1b48758b042e0eb2 Mon Sep 17 00:00:00 2001 From: ShogunMan <77636146+ShogunMan@users.noreply.github.com> Date: Tue, 2 May 2023 20:45:01 +0200 Subject: [PATCH 3/6] Remove color-support for Tuya dimmer variation `_TZ3210_i680rtja` (#2332) Add `_TZ3210_i680rtja` to Tuya DimmableLedController quirk --- zhaquirks/tuya/ts0501bs.py | 1 + 1 file changed, 1 insertion(+) diff --git a/zhaquirks/tuya/ts0501bs.py b/zhaquirks/tuya/ts0501bs.py index 48b946ea6d..d8379400b4 100644 --- a/zhaquirks/tuya/ts0501bs.py +++ b/zhaquirks/tuya/ts0501bs.py @@ -34,6 +34,7 @@ class DimmableLedController(CustomDevice): ("_TZ3210_9q49basr", "TS0501B"), ("_TZ3210_4zinq6io", "TS0501B"), ("_TZ3210_e5t9bfdv", "TS0501B"), + ("_TZ3210_i680rtja", "TS0501B"), ], ENDPOINTS: { # Date: Wed, 3 May 2023 07:33:38 -0400 Subject: [PATCH 4/6] Fix ZHA startup `on_off` error in 2023.5.0b2 (#2372) * Add a unit test * Fix broken Tuya cluster --- tests/test_quirks.py | 54 ++++++++++++++++++++++++++++++++++++++++ zhaquirks/tuya/ts130f.py | 15 ++++------- 2 files changed, 59 insertions(+), 10 deletions(-) diff --git a/tests/test_quirks.py b/tests/test_quirks.py index a0f477a156..8d8aa37e1c 100644 --- a/tests/test_quirks.py +++ b/tests/test_quirks.py @@ -19,6 +19,7 @@ import zhaquirks import zhaquirks.bosch.motion +import zhaquirks.centralite.cl_3310S import zhaquirks.const as const from zhaquirks.const import ( ARGS, @@ -48,7 +49,10 @@ PROFILE_ID, SKIP_CONFIGURATION, ) +import zhaquirks.konke +import zhaquirks.philips from zhaquirks.xiaomi import XIAOMI_NODE_DESC +import zhaquirks.xiaomi.aqara.vibration_aq1 zhaquirks.setup() @@ -678,6 +682,18 @@ def test_quirk_device_automation_triggers_unique(quirk): def test_attributes_updated_not_replaced(quirk: CustomDevice) -> None: """Verify no quirks subclass a ZCL cluster but delete its attributes list.""" + base_cluster_attrs_name = {} + base_cluster_attrs_id = {} + + for name, cluster in zcl.clusters.CLUSTERS_BY_NAME.items(): + assert cluster.ep_attribute not in base_cluster_attrs_name + base_cluster_attrs_name[cluster.ep_attribute] = set( + cluster.attributes_by_name.keys() + ) + base_cluster_attrs_id[cluster.cluster_id] = set( + cluster.attributes_by_name.keys() + ) + for ep_id, ep_data in quirk.replacement[ENDPOINTS].items(): for cluster in ep_data.get(INPUT_CLUSTERS, []) + ep_data.get( OUTPUT_CLUSTERS, [] @@ -689,6 +705,44 @@ def test_attributes_updated_not_replaced(quirk: CustomDevice) -> None: assert issubclass(cluster, zigpy.quirks.CustomCluster) + # Check if attributes match based on cluster endpoint attribute + if not ( + base_cluster_attrs_name.get(cluster.ep_attribute, set()) + <= set(cluster.attributes_by_name.keys()) + ): + missing_attrs = base_cluster_attrs_name[cluster.ep_attribute] - set( + cluster.attributes_by_name.keys() + ) + + # A few are expected to fail and are handled by ZHA + if cluster not in ( + zhaquirks.centralite.cl_3310S.SmartthingsRelativeHumidityCluster, + ): + pytest.fail( + f"Cluster {cluster} with endpoint name {cluster.ep_attribute!r}" + f" does not contain all named attributes: {missing_attrs}" + ) + + # Check if attributes match based on cluster ID + if not ( + base_cluster_attrs_id.get(cluster.cluster_id, set()) + <= set(cluster.attributes_by_name.keys()) + ): + missing_attrs = base_cluster_attrs_id[cluster.cluster_id] - set( + cluster.attributes_by_name.keys() + ) + + # A few are expected to fail and are handled by ZHA + if cluster not in ( + zhaquirks.konke.KonkeOnOffCluster, + zhaquirks.philips.PhilipsOccupancySensing, + zhaquirks.xiaomi.aqara.vibration_aq1.VibrationAQ1.MultistateInputCluster, + ): + pytest.fail( + f"Cluster {cluster} with endpoint ID 0x{cluster.cluster_id:04X}" + f" does not contain all named attributes: {missing_attrs}" + ) + base_clusters = set(cluster.__mro__) & ALL_ZIGPY_CLUSTERS # Completely custom cluster diff --git a/zhaquirks/tuya/ts130f.py b/zhaquirks/tuya/ts130f.py index 407bf0cc21..5975523f2c 100644 --- a/zhaquirks/tuya/ts130f.py +++ b/zhaquirks/tuya/ts130f.py @@ -21,22 +21,17 @@ OUTPUT_CLUSTERS, PROFILE_ID, ) -from zhaquirks.tuya import TuyaZBExternalSwitchTypeCluster +from zhaquirks.tuya import SwitchBackLight, TuyaZBExternalSwitchTypeCluster ATTR_CURRENT_POSITION_LIFT_PERCENTAGE = 0x0008 CMD_GO_TO_LIFT_PERCENTAGE = 0x0005 -class TuyaWithBacklightOnOffCluster(CustomCluster): - """TuyaSmartCurtainOnOffCluster: fire events corresponding to press type.""" +class TuyaWithBacklightOnOffCluster(CustomCluster, OnOff): + """Tuya Zigbee On Off cluster with extra attributes.""" - cluster_id = OnOff.cluster_id - - LIGHT_MODE_1 = {0x8001: 0} - LIGHT_MODE_2 = {0x8001: 1} - LIGHT_MODE_3 = {0x8001: 2} - - attributes = {0x8001: ("backlight_mode", t.enum8)} + attributes = OnOff.attributes.copy() + attributes.update({0x8001: ("backlight_mode", SwitchBackLight)}) class MotorMode(t.enum8): From 273edd8f466d725864b3d72cae38ba1ad7c83c35 Mon Sep 17 00:00:00 2001 From: Steven Barkey Date: Wed, 3 May 2023 04:36:00 -0700 Subject: [PATCH 5/6] Fix battery percentage for Sercomm XHS2-SE contact sensor (#2350) * Added XHS2-SE * Format `szwtd02n.py` * Refactor quirks This moves the `SercommPowerConfiguration` class to the Sercomm module `__init__.py`. It also splits out the contact and flood sensor quirks into separate files with proper names. * Update SimpleDescriptor comments --------- Co-authored-by: TheJulianJES --- zhaquirks/sercomm/__init__.py | 9 +++ zhaquirks/sercomm/contact_sensor.py | 62 +++++++++++++++++++ .../sercomm/{szwtd02n.py => flood_sensor.py} | 12 +--- 3 files changed, 73 insertions(+), 10 deletions(-) create mode 100644 zhaquirks/sercomm/contact_sensor.py rename zhaquirks/sercomm/{szwtd02n.py => flood_sensor.py} (85%) diff --git a/zhaquirks/sercomm/__init__.py b/zhaquirks/sercomm/__init__.py index d953f0bd4c..06791d8eef 100644 --- a/zhaquirks/sercomm/__init__.py +++ b/zhaquirks/sercomm/__init__.py @@ -1,2 +1,11 @@ """Module for sercomm quirks.""" +from zhaquirks import PowerConfigurationCluster + SERCOMM = "Sercomm Corp." + + +class SercommPowerConfiguration(PowerConfigurationCluster): + """Sercomm power configuration cluster for flood sensor.""" + + MAX_VOLTS = 3.2 + MIN_VOLTS = 2.1 diff --git a/zhaquirks/sercomm/contact_sensor.py b/zhaquirks/sercomm/contact_sensor.py new file mode 100644 index 0000000000..ac19e21cdd --- /dev/null +++ b/zhaquirks/sercomm/contact_sensor.py @@ -0,0 +1,62 @@ +"""Device handler for Sercomm XHS2-SE contact sensor.""" + +from zigpy.profiles import zha +from zigpy.quirks import CustomDevice +from zigpy.zcl.clusters.general import Basic, Identify, Ota, PollControl +from zigpy.zcl.clusters.homeautomation import Diagnostic +from zigpy.zcl.clusters.measurement import TemperatureMeasurement +from zigpy.zcl.clusters.security import IasZone + +from zhaquirks.const import ( + DEVICE_TYPE, + ENDPOINTS, + INPUT_CLUSTERS, + MODELS_INFO, + OUTPUT_CLUSTERS, + PROFILE_ID, +) +from zhaquirks.sercomm import SERCOMM, SercommPowerConfiguration + + +class XHS2SE(CustomDevice): + """Custom device representing Sercomm XHS2-SE contact sensor.""" + + signature = { + # + MODELS_INFO: [(SERCOMM, "XHS2-SE")], + ENDPOINTS: { + 1: { + PROFILE_ID: zha.PROFILE_ID, + DEVICE_TYPE: zha.DeviceType.IAS_ZONE, + INPUT_CLUSTERS: [ + Basic.cluster_id, + SercommPowerConfiguration.cluster_id, + Identify.cluster_id, + PollControl.cluster_id, + TemperatureMeasurement.cluster_id, + IasZone.cluster_id, + Diagnostic.cluster_id, + ], + OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id], + } + }, + } + + replacement = { + ENDPOINTS: { + 1: { + INPUT_CLUSTERS: [ + Basic.cluster_id, + SercommPowerConfiguration, + Identify.cluster_id, + PollControl.cluster_id, + TemperatureMeasurement.cluster_id, + IasZone.cluster_id, + Diagnostic.cluster_id, + ], + OUTPUT_CLUSTERS: [Identify.cluster_id, Ota.cluster_id], + } + } + } diff --git a/zhaquirks/sercomm/szwtd02n.py b/zhaquirks/sercomm/flood_sensor.py similarity index 85% rename from zhaquirks/sercomm/szwtd02n.py rename to zhaquirks/sercomm/flood_sensor.py index bf1daedd6f..517dd6bd6b 100644 --- a/zhaquirks/sercomm/szwtd02n.py +++ b/zhaquirks/sercomm/flood_sensor.py @@ -6,7 +6,6 @@ from zigpy.zcl.clusters.homeautomation import Diagnostic from zigpy.zcl.clusters.security import IasZone -from zhaquirks import PowerConfigurationCluster from zhaquirks.const import ( DEVICE_TYPE, ENDPOINTS, @@ -15,14 +14,7 @@ OUTPUT_CLUSTERS, PROFILE_ID, ) -from zhaquirks.sercomm import SERCOMM - - -class SercommPowerConfiguration(PowerConfigurationCluster): - """Sercomm power configuration cluster for flood sensor.""" - - MAX_VOLTS = 3.2 - MIN_VOLTS = 2.1 +from zhaquirks.sercomm import SERCOMM, SercommPowerConfiguration class SZWTD02N(CustomDevice): @@ -31,7 +23,7 @@ class SZWTD02N(CustomDevice): signature = { # MODELS_INFO: [(SERCOMM, "SZ-WTD02N_SF")], ENDPOINTS: { From ef871fbbed2a106e519a725f26200f532ec6e31a Mon Sep 17 00:00:00 2001 From: David Mulcahey Date: Wed, 3 May 2023 07:38:25 -0400 Subject: [PATCH 6/6] bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index bee6e39d4a..5b24b56059 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import find_packages, setup -VERSION = "0.0.98" +VERSION = "0.0.99" setup(