My battery powered temperature sensors are sleepy devices.
That means that they can receive commands only when they are awake, and they are only awake when they are sending data.
Any command provided to the Zigbee network will generally be forgotten after 5-10 seconds. So if the device does not wake up during that time, the configuration command will “Timeout” and not be repeated.
With the custom_component ‘zha_toolkit’ you can repeat the report configuration as many times as you want with just one service call.
The next service call (sent using Development Tool > Services) configures temperature reporting for a Sonoff sensor to report for every 0.10°C change or at least every 5 minutes and no faster than every 5 seconds.
service: zha_toolkit.execute
data:
ieee: sensor.principal_temperature
command: conf_report
endpoint: 1
cluster: 0x402
attribute: 0
min_interval: 5
max_interval: 300
reportable_change: 10
tries: 100
event_done: zha_done
After launching this, with debug logging enabled for the component, the log shows:
2022-01-26 10:50:18 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] {'cmd_id': None, 'endpoint_id': 1, 'cluster_id': 1026, 'attr_id': 0, 'attr_type': None, 'attr_val': None, 'code': None, 'min_interval': 5, 'max_interval': 300, 'reportable_change': 10, 'dir': 0, 'manf': None, 'tries': 100, 'expect_reply': True, 'args': [], 'state_id': None, 'state_attr': None, 'allow_create': False, 'event_success': None, 'event_fail': None, 'event_done': 'zha_done', 'read_before_write': True, 'read_after_write': True, 'write_if_equal': False}
2022-01-26 10:50:18 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Try configure report(0,5,300,10,None) Try 1/100
2022-01-26 10:50:26 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Try configure report(0,5,300,10,None) Try 2/100
2022-01-26 10:50:34 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Try configure report(0,5,300,10,None) Try 3/100
2022-01-26 10:50:42 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Try configure report(0,5,300,10,None) Try 4/100
2022-01-26 10:50:50 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Try configure report(0,5,300,10,None) Try 5/100
2022-01-26 10:50:58 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Try configure report(0,5,300,10,None) Try 6/100
2022-01-26 10:51:06 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Try configure report(0,5,300,10,None) Try 7/100
2022-01-26 10:51:14 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Try configure report(0,5,300,10,None) Try 8/100
2022-01-26 10:51:22 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Try configure report(0,5,300,10,None) Try 9/100
2022-01-26 10:51:30 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Try configure report(0,5,300,10,None) Try 10/100
2022-01-26 10:51:38 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Try configure report(0,5,300,10,None) Try 11/100
2022-01-26 10:51:46 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Try configure report(0,5,300,10,None) Try 12/100
2022-01-26 10:51:54 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Try configure report(0,5,300,10,None) Try 13/100
2022-01-26 10:52:02 DEBUG (MainThread) [custom_components.zha_toolkit.zcl_attr] Try configure report(0,5,300,10,None) Try 14/100
2022-01-26 10:52:05 INFO (MainThread) [custom_components.zha_toolkit.zcl_attr] Configure report result: [[ConfigureReportingResponseRecord(status=0)]]
2022-01-26 10:52:05 DEBUG (MainThread) [custom_components.zha_toolkit] event_data {'ieee_org': 'sensor.principal_temperature', 'ieee': '00:12:4b:00:23:b3:ed:f5', 'command': 'conf_report', 'start_time': '2022-01-26T09:50:18.604518+00:00', 'errors': [], 'params': {'cmd_id': None, 'endpoint_id': 1, 'cluster_id': 1026, 'attr_id': 0, 'attr_type': None, 'attr_val': None, 'code': None, 'min_interval': 5, 'max_interval': 300, 'reportable_change': 10, 'dir': 0, 'manf': None, 'tries': 100, 'expect_reply': True, 'args': [], 'state_id': None, 'state_attr': None, 'allow_create': False, 'event_success': None, 'event_fail': None, 'event_done': 'zha_done', 'read_before_write': True, 'read_after_write': True, 'write_if_equal': False}, 'success': True, 'result_conf': [[ConfigureReportingResponseRecord(status=0)]]}
2022-01-26 10:52:05 DEBUG (MainThread) [custom_components.zha_toolkit] Fire zha_done -> {'ieee_org': 'sensor.principal_temperature', 'ieee': '00:12:4b:00:23:b3:ed:f5', 'command': 'conf_report', 'start_time': '2022-01-26T09:50:18.604518+00:00', 'errors': [], 'params': {'cmd_id': None, 'endpoint_id': 1, 'cluster_id': 1026, 'attr_id': 0, 'attr_type': None, 'attr_val': None, 'code': None, 'min_interval': 5, 'max_interval': 300, 'reportable_change': 10, 'dir': 0, 'manf': None, 'tries': 100, 'expect_reply': True, 'args': [], 'state_id': None, 'state_attr': None, 'allow_create': False, 'event_success': None, 'event_fail': None, 'event_done': 'zha_done', 'read_before_write': True, 'read_after_write': True, 'write_if_equal': False}, 'success': True, 'result_conf': [[ConfigureReportingResponseRecord(status=0)]]}
So it was set to try 100 times, but it succeeded on the 14th iteration (after about 2 minutes), so it stopped and fired the zha_done event because that is the event name that I chose to notify that the service ended.
The event report (Developer Tools > Events) looked like this:
{
"event_type": "zha_done",
"data": {
"ieee_org": "sensor.principal_temperature",
"ieee": "00:12:4b:00:23:b3:ed:f5",
"command": "conf_report",
"start_time": "2022-01-26T09:50:18.604518+00:00",
"errors": [],
"params": {
"cmd_id": null,
"endpoint_id": 1,
"cluster_id": 1026,
"attr_id": 0,
"attr_type": null,
"attr_val": null,
"code": null,
"min_interval": 5,
"max_interval": 300,
"reportable_change": 10,
"dir": 0,
"manf": null,
"tries": 100,
"expect_reply": true,
"args": [],
"state_id": null,
"state_attr": null,
"allow_create": false,
"event_success": null,
"event_fail": null,
"event_done": "zha_done",
"read_before_write": true,
"read_after_write": true,
"write_if_equal": false
},
"success": true,
"result_conf": [
[
{
"status": 0,
"direction": null,
"attrid": null
}
]
]
},
"origin": "LOCAL",
"time_fired": "2022-01-26T09:52:05.351239+00:00",
"context": {
"id": "aa89fcaddd73684fe31a0c98adaf414f",
"parent_id": null,
"user_id": null
}
}
I now have faster reporting on this sensor while I failed to do it manually quite a few times in the past.
In practice it reports at most every 20 seconds because that is the limit set by the developers.