"zha-toolkit" - a big set of Zigbee commands on top of ZHA/zigpy

I changed zha_toolkit so that by default it should let the quirk automatically set the manufacturer code.

1 Like

Arg
 can’t attach a .txt file


I am surprised only images are allowed - you can add an issue/discussion on github - they allow more file types.
But all that is really needed is the manufacturer id - I checked one of my scans: the manufacturer id is not mentionned, I checked the device information provided in ZHA, the manufacturer ID is not provided 
 .
So, I’ll make some updates to zha-toolkit for that as well.

In the mean time, just try the last version like this:

service: zha_toolkit.attr_write
  data:
    ieee: 54:0f:57:ff:fe:7f:e9:29
    cluster: 6
    attribute: 0x8002
    attr_type: 0x30
    attr_val: 1

and probably this works as well (because the endpoint and the attr_type and the manufacturer id should be detected eiher in zha-toolkit or the quirk):

service: zha_toolkit.attr_write
  data:
    ieee: 54:0f:57:ff:fe:7f:e9:29
    cluster: 6
    attribute: 0x8002
    attr_val: 1

P.S.: I just updated ‘zha_toolkit.scan_device’ and it seems that I also have the 0x8002 attribute on one of them - even though it’s something specific to the manufacturer, the manufacturer id should be be set in my case, so the provided examples above should work.
FYI, I prefer mentioning the entity name rather than the IEEE address which is harder to ge (scan example):

service: zha_toolkit.scan_device
data:
  ieee: button.sonoff_01minizb_3f25c224_identify

Hi,
Thx again for trying to help out.
My last try was this one:
No matter what I try, when I try to write I get the same error:
AttributeError("‘NoneType’ object has no attribute ‘serialize’"

2022-02-28 08:41:08 INFO (MainThread) [custom_components.zha_toolkit] Running ZHA Toolkit service: <ServiceCall zha_toolkit.attr_write (c:aa26c934a1966db347494932352b018f): ieee=button.st_droogkast_identify, cluster=6, attribute=32770, attr_type=48, attr_val=1>

2022-02-28 08:41:08 DEBUG (MainThread) [custom_components.zha_toolkit] module is <module ‘custom_components.zha_toolkit’ from ‘/config/custom_components/zha_toolkit/init.py’>

2022-02-28 08:41:08 DEBUG (MainThread) [custom_components.zha_toolkit.utils] Parameters ‘{‘ieee’: ‘button.st_droogkast_identify’, ‘cluster’: 6, ‘attribute’: 32770, ‘attr_type’: 48, ‘attr_val’: 1}’

2022-02-28 08:41:08 DEBUG (MainThread) [custom_components.zha_toolkit.utils] registry_entity RegistryEntry(entity_id=‘button.st_droogkast_identify’, unique_id=‘54:0f:57:ff:fe:7f:e9:29-1-3’, platform=‘zha’, area_id=None, capabilities=None, config_entry_id=‘f44ffad5582b24ea67bc482e01e785ed’, device_class=‘update’, device_id=‘fc557ccb7df951f7d5f27bc79a1e45ab’, disabled_by=None, entity_category=<EntityCategory.DIAGNOSTIC: ‘diagnostic’>, icon=None, id=‘e4e9542aa2f4aca81977749f5410bc87’, name=None, options={}, original_device_class=‘update’, original_icon=None, original_name=’_TZ3000_u5u4cakc TS011F 29e97ffe identify’, supported_features=0, unit_of_measurement=None)

2022-02-28 08:41:08 DEBUG (MainThread) [custom_components.zha_toolkit.utils] registry_device DeviceEntry(area_id=‘berging’, config_entries={‘f44ffad5582b24ea67bc482e01e785ed’}, configuration_url=None, connections={(‘zigbee’, ‘54:0f:57:ff:fe:7f:e9:29’)}, disabled_by=None, entry_type=None, id=‘fc557ccb7df951f7d5f27bc79a1e45ab’, identifiers={(‘zha’, ‘54:0f:57:ff:fe:7f:e9:29’)}, manufacturer=’_TZ3000_u5u4cakc’, model=‘TS011F’, name_by_user=‘stopcontact droogkast’, name=’_TZ3000_u5u4cakc TS011F’, suggested_area=None, sw_version=None, hw_version=None, via_device_id=‘05a0302d82a5f9732a855fa9e7a6b2c4’, is_new=False)

2022-02-28 08:41:08 DEBUG (MainThread) [custom_components.zha_toolkit] Key <custom_components.zha_toolkit.params.INTERNAL_PARAMS_consts object at 0x7fc2ab785c40>

2022-02-28 08:41:08 DEBUG (MainThread) [custom_components.zha_toolkit.utils] Type recognition for ‘<class ‘zigpy_deconz.zigbee.application.ControllerApplication’>’ not implemented

2022-02-28 08:41:08 DEBUG (MainThread) [custom_components.zha_toolkit] ‘ieee’ parameter: ‘button.st_droogkast_identify’ → IEEE Addr: ‘54:0f:57:ff:fe:7f:e9:29’

2022-02-28 08:41:08 DEBUG (MainThread) [custom_components.zha_toolkit] Default handler for attr_write

2022-02-28 08:41:08 DEBUG (MainThread) [custom_components.zha_toolkit] Handler: <function command_handler_default at 0x7fc251c293a0>

2022-02-28 08:41:08 DEBUG (MainThread) [custom_components.zha_toolkit] running default command: <ServiceCall zha_toolkit.attr_write (c:aa26c934a1966db347494932352b018f): ieee=button.st_droogkast_identify, cluster=6, attribute=32770, attr_type=48, attr_val=1>

2022-02-28 08:41:08 DEBUG (MainThread) [custom_components.zha_toolkit.default] Trying to import custom_components.zha_toolkit.zcl_attr to call attr_write

2022-02-28 08:41:08 DEBUG (MainThread) [custom_components.zha_toolkit.utils] Endpoint 1 found for cluster ‘6’

2022-02-28 08:41:08 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Request attr read [32770]

2022-02-28 08:41:08 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Reading attr result (attrs, status): ({32770: <PowerOnState.Off: 0>}, {})

2022-02-28 08:41:08 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Request attr write [Attribute(attrid=32770, value=)]

2022-02-28 08:41:08 DEBUG (MainThread) [custom_components.zha_toolkit] event_data {‘zha_toolkit_version’: ‘v0.7.21’, ‘zigpy_version’: ‘0.43.0’, ‘zigpy_rf_version’: None, ‘ieee_org’: ‘button.st_droogkast_identify’, ‘ieee’: ‘54:0f:57:ff:fe:7f:e9:29’, ‘command’: None, ‘command_data’: None, ‘start_time’: ‘2022-02-28T07:41:08.489814+00:00’, ‘errors’: [‘AttributeError("‘NoneType’ object has no attribute ‘serialize’")’], ‘params’: {‘cluster_id’: 6, ‘attr_id’: 32770, ‘attr_type’: 48, ‘attr_val’: 1, ‘dir’: 0, ‘tries’: 1, ‘expect_reply’: True, ‘args’: [], ‘read_before_write’: True, ‘read_after_write’: True}, ‘compare_val’: 1, ‘write_is_equal’: False, ‘read_before’: ({32770: <PowerOnState.Off: 0>}, {}), ‘success’: False}

Reading the same attribute works a charm

2022-02-28 09:53:25 INFO (MainThread) [custom_components.zha_toolkit] Running ZHA Toolkit service: <ServiceCall zha_toolkit.attr_read (c:8e9a7ee24d4819dd822a08c761d6586e): ieee=button.st_droogkast_identify, cluster=6, attribute=32770, attr_type=48, manufacturer=16536>

2022-02-28 09:53:25 DEBUG (MainThread) [custom_components.zha_toolkit] module is <module ‘custom_components.zha_toolkit’ from ‘/config/custom_components/zha_toolkit/init.py’>

2022-02-28 09:53:25 DEBUG (MainThread) [custom_components.zha_toolkit.utils] Parameters ‘{‘ieee’: ‘button.st_droogkast_identify’, ‘cluster’: 6, ‘attribute’: 32770, ‘attr_type’: 48, ‘manufacturer’: 16536}’

2022-02-28 09:53:25 DEBUG (MainThread) [custom_components.zha_toolkit.utils] registry_entity RegistryEntry(entity_id=‘button.st_droogkast_identify’, unique_id=‘54:0f:57:ff:fe:7f:e9:29-1-3’, platform=‘zha’, area_id=None, capabilities=None, config_entry_id=‘f44ffad5582b24ea67bc482e01e785ed’, device_class=‘update’, device_id=‘fc557ccb7df951f7d5f27bc79a1e45ab’, disabled_by=None, entity_category=<EntityCategory.DIAGNOSTIC: ‘diagnostic’>, icon=None, id=‘e4e9542aa2f4aca81977749f5410bc87’, name=None, options={}, original_device_class=‘update’, original_icon=None, original_name=’_TZ3000_u5u4cakc TS011F 29e97ffe identify’, supported_features=0, unit_of_measurement=None)

2022-02-28 09:53:25 DEBUG (MainThread) [custom_components.zha_toolkit.utils] registry_device DeviceEntry(area_id=‘berging’, config_entries={‘f44ffad5582b24ea67bc482e01e785ed’}, configuration_url=None, connections={(‘zigbee’, ‘54:0f:57:ff:fe:7f:e9:29’)}, disabled_by=None, entry_type=None, id=‘fc557ccb7df951f7d5f27bc79a1e45ab’, identifiers={(‘zha’, ‘54:0f:57:ff:fe:7f:e9:29’)}, manufacturer=’_TZ3000_u5u4cakc’, model=‘TS011F’, name_by_user=‘stopcontact droogkast’, name=’_TZ3000_u5u4cakc TS011F’, suggested_area=None, sw_version=None, hw_version=None, via_device_id=‘05a0302d82a5f9732a855fa9e7a6b2c4’, is_new=False)

2022-02-28 09:53:25 DEBUG (MainThread) [custom_components.zha_toolkit] Key <custom_components.zha_toolkit.params.INTERNAL_PARAMS_consts object at 0x7fc251bda620>

2022-02-28 09:53:25 DEBUG (MainThread) [custom_components.zha_toolkit.utils] Type recognition for ‘<class ‘zigpy_deconz.zigbee.application.ControllerApplication’>’ not implemented

2022-02-28 09:53:25 DEBUG (MainThread) [custom_components.zha_toolkit] ‘ieee’ parameter: ‘button.st_droogkast_identify’ → IEEE Addr: ‘54:0f:57:ff:fe:7f:e9:29’

2022-02-28 09:53:25 DEBUG (MainThread) [custom_components.zha_toolkit] Default handler for attr_read

2022-02-28 09:53:25 DEBUG (MainThread) [custom_components.zha_toolkit] Handler: <function command_handler_default at 0x7fc251f2dd30>

2022-02-28 09:53:25 DEBUG (MainThread) [custom_components.zha_toolkit] running default command: <ServiceCall zha_toolkit.attr_read (c:8e9a7ee24d4819dd822a08c761d6586e): ieee=button.st_droogkast_identify, cluster=6, attribute=32770, attr_type=48, manufacturer=16536>

2022-02-28 09:53:25 DEBUG (MainThread) [custom_components.zha_toolkit.default] Trying to import custom_components.zha_toolkit.zcl_attr to call attr_read

2022-02-28 09:53:25 DEBUG (MainThread) [custom_components.zha_toolkit.utils] Endpoint 1 found for cluster ‘6’

2022-02-28 09:53:25 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Request attr read [32770]

2022-02-28 09:53:25 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Reading attr result (attrs, status): ({32770: <PowerOnState.Off: 0>}, {})

2022-02-28 09:53:25 DEBUG (MainThread) [custom_components.zha_toolkit] event_data {‘zha_toolkit_version’: ‘v0.7.21’, ‘zigpy_version’: ‘0.43.0’, ‘zigpy_rf_version’: None, ‘ieee_org’: ‘button.st_droogkast_identify’, ‘ieee’: ‘54:0f:57:ff:fe:7f:e9:29’, ‘command’: None, ‘command_data’: None, ‘start_time’: ‘2022-02-28T08:53:25.335969+00:00’, ‘errors’: [], ‘params’: {‘cluster_id’: 6, ‘attr_id’: 32770, ‘attr_type’: 48, ‘dir’: 0, ‘tries’: 1, ‘expect_reply’: True, ‘args’: [], ‘read_before_write’: True, ‘read_after_write’: True}, ‘write_is_equal’: False, ‘result_read’: ({32770: <PowerOnState.Off: 0>}, {}), ‘success’: True}

Ok, I see that type conversion did not work for “enums”, so I updated the code & tested it.
It works for me in v0.7.22 - same attribute:

I tested like this:

service: zha_toolkit.attr_write
data:
  ieee: switch.prise_bureau_on_off
  cluster: 6
  attribute: 0x8002
  attr_type: 48
  attr_val: 2
1 Like

Hi,
Works perfectly now!

service: zha_toolkit.attr_write
data:
ieee: button.st_droogkast_identify
cluster: 6
attribute: 0x8002
attr_type: 0x30
attr_val: 1

Thx for all the help. Hope you keep up improving a great tool!

I’m happy I found your HACS custom integration! zha_toolkit does all the stuff I fiddled around with scripts and the integrated ZHA service but so much better! I already replaced (re-factored :sunglasses:) my whole automations and scripts. This makes my zigbee based automations much more resilient and with that (and that’s the key benefit so far) enhances the WAF (wife acceptance factor) really well!

2 Likes

@le_top Have you by the way tested zha-toolkit with the new radio API for zigpy so that this change does not break your backup blueprints, etc.?

https://github.com/zigpy/zigpy/pull/848

_Originally posted by puddly in New radio API by puddly · Pull Request #848 · zigpy/zigpy · GitHub

Alright, this PR is about as ready as it will ever be. Any final thoughts before I merge this and the corresponding PRs in all of the other radio libraries?

See [SUGGESTION] Move zha-toolkit repository to zigpy organization? · Discussion #901 · zigpy/zigpy · GitHub .

It is noteworthy to watchers of this thread that zha_toolkit/ota_notify now includes an option to request downloading the firmware listed in koenkk/zigbee-OTA used in Z2M. this extends beyond the FW currently downloaded by zha (when configured to do so).

2 Likes

Thank you for UI mode, but I miss here choice to input or see data in hex format.
In HA Manage Zigbee Device all data is in hex format.
It’s soo annoying to convert cluster/attribute numbers from hex to number.

I agree, but for defining the UI of the service call, I am bound to Selectors - Home Assistant .

This could have been a nice entry for the WTH month - maybe it is still open .

How do you remove this, i moved to Zigbee2mqtt and removed this integration, now i cant restart
 I reinstalled the HACS integration but still nothing

The system cannot restart because the configuration is not valid: Integration error: zha_toolkit - Integration 'zha_toolkit' not found.
``

You probably have zha_toolkit: in configuration.yaml which tries to load the component.
Remove/comment that.

I needed to set the time and timezone data (dststart, dstend, dstshift) for several of my objects.

Getting the DST data using templates is at least complex so I implemented ‘misc_settime’ to do that with just one service.

You may also be interested in an “off topic” service: ha_set_state which allows you to change any state in ha. I use it to detect same value attribute updates of temperatures.

1 Like

I need to add reporting on a manufacturer cluster attribute on a ZHA device. I’ve already configured the reporting on the attribute but I can’t find the way to activate reporting. Can anybody point me to where I should go to do that activation.

Documentation:

Example where one is written, without the manufacturer id. You just need to add the manufacturer id and change the other values to what you need:

Example where a manufacturer attribute’s reporting configuration is read back:

I’ve done this:

service: zha_toolkit.conf_report
data:
  ieee: 50:0b:91:40:00:01:f1:e7
  cluster: 65281
  attribute: 84
  min_interval: 1
  max_interval: 300
  reportable_change: 1
  event_success: my_read_success_trigger_event
  event_fail: my_read_fail_trigger_event
  event_done: my_read_done_trigger_event

results:
[custom_components.zha_toolkit] Fire my_read_done_trigger_event → {‘zha_toolkit_version’: ‘v0.8.29’, ‘zigpy_version’: ‘0.53.0’, ‘zigpy_rf_version’: ‘0.19.2’, ‘ieee_org’: 50:0b:91:40:00:01:f1:e7, ‘ieee’: ‘50:0b:91:40:00:01:f1:e7’, ‘command’: ‘conf_report’, ‘command_data’: None, ‘start_time’: ‘2023-01-31T01:45:43.213733+00:00’, ‘errors’: [], ‘params’: {‘cluster_id’: 65281, ‘attr_id’: 84, ‘min_interval’: 1, ‘max_interval’: 300, ‘reportable_change’: 1, ‘dir’: 0, ‘tries’: 1, ‘expect_reply’: True, ‘args’: [], ‘event_success’: ‘my_read_success_trigger_event’, ‘event_fail’: ‘my_read_fail_trigger_event’, ‘event_done’: ‘my_read_done_trigger_event’, ‘read_before_write’: True, ‘read_after_write’: True}, ‘success’: True,
‘result_conf’: Configure_Reporting_rsp(status_records=[ConfigureReportingResponseRecord(status=<Status.SUCCESS: 0>)])}

Then I’ve done this:

service: zha_toolkit.conf_report_read
data:
  ieee: 50:0b:91:40:00:01:f1:e7
  cluster: 65281
  attribute: 84
  event_success: my_read_success_trigger_event
  event_fail: my_read_fail_trigger_event
  event_done: my_read_done_trigger_event

results:
2023-01-30 20:51:14.808 DEBUG (MainThread) [custom_components.zha_toolkit] Fire my_read_done_trigger_event → {‘zha_toolkit_version’: ‘v0.8.29’, ‘zigpy_version’: ‘0.53.0’, ‘zigpy_rf_version’: ‘0.19.2’, ‘ieee_org’: 50:0b:91:40:00:01:f1:e7, ‘ieee’: ‘50:0b:91:40:00:01:f1:e7’, ‘command’: ‘conf_report_read’, ‘command_data’: None, ‘start_time’: ‘2023-01-31T01:51:14.727627+00:00’, ‘errors’: [], ‘params’: {‘cluster_id’: 65281, ‘attr_id’: 84, ‘dir’: 0, ‘tries’: 1, ‘expect_reply’: True, ‘args’: [], ‘event_success’: ‘my_read_success_trigger_event’, ‘event_fail’: ‘my_read_fail_trigger_event’, ‘event_done’: ‘my_read_done_trigger_event’, ‘read_before_write’: True, ‘read_after_write’: True}, ‘success’: True,
‘result_conf’: [{‘cluster’: ‘SinopĂ© Technologies Manufacturer specific’, ‘cluster_id’: ‘0xFF01’, ‘ep’: 1, ‘attr_id’: ‘0x0054’, ‘direction’: <ReportingDirection.SendReports: 0>, ‘status’: <Status.SUCCESS: 0>, ‘type’: ‘0x30’, ‘min_interval’: (1,), ‘max_interval’: (300,), ‘attr’: ‘actionReport’}]}

Still no reporting. Do I need to bind the cluster 0xff01 (65281) to the gateway?
Also what is ‘direction’: <ReportingDirection.SendReports: 0>