WIP: implement retrieving sw_build_id attribute from Basic cluster#23
WIP: implement retrieving sw_build_id attribute from Basic cluster#23pdecat wants to merge 1 commit intodmulcahey:masterfrom
Conversation
| const config = this._config; | ||
| const root = this.shadowRoot; | ||
|
|
||
| if (!this.initialized) { |
There was a problem hiding this comment.
This is temporary to avoid hammering the zigbee devices with actual cluster attribute requests as set hass(hass) is invoked very often.
| ); | ||
| raw_rows.forEach((e) => e.get_raw_data(config.columns)); | ||
| const read_sw_build_id = config.columns.filter((col) => col.prop == "sw_build_id"); | ||
| await Promise.allSettled(raw_rows.map(async (e) => { |
There was a problem hiding this comment.
This blocks the rendering of the table until all cluster attribute requests are done (successes and fails).
This is needed as the rendering currently does not accept promises, only actual values.
| await Promise.allSettled(raw_rows.map(async (e) => { | ||
| if (read_sw_build_id && e.device.attributes.available) { | ||
| // retrieving cluster attributes requires additional ws calls | ||
| await hass.callWS({ |
There was a problem hiding this comment.
These hass.callWS() invocations of zha/devices/clusters and zha/devices/clusters/attributes/value types could probably be cached to avoid hammering the zigbee network and devices.
| "endpoint_id": cluster.endpoint_id, | ||
| "cluster_id": cluster.id, | ||
| "cluster_type": "in", | ||
| "attribute": 0x4000, |
There was a problem hiding this comment.
This could be made dynamic to support other attributes.
| ieee: e.device.attributes.ieee | ||
| }).then(async (clusters) => { | ||
| for (const cluster of clusters) { | ||
| if (cluster["type"] == "in" && cluster["name"] == "Basic") { |
There was a problem hiding this comment.
This could be made dynamic to support other clusters.
|
Any more progress with this? Do you need any help finishing it? |
|
Well, it works for me, but I'm unsure there's any hope to see this merged. |
This is marked as WIP as it works but retrieving cluster attributes is slow for unreachable devices (mostly battery powered ones),
and this blocks the rendering of the table.
I'd like to alter the way the table rendering is done to accept Promises from get_raw_data() and update the tables cells asynchronously when the promises are fulfilled.
Submitted early as draft PR to get feedback if something like this would be accepted, and if so to get advice on how to improve this.
Sample configuration for
ui-lovelace.yaml:Resulting output: