-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: implement retrieving sw_build_id attribute from Basic cluster #23
base: master
Are you sure you want to change the base?
Conversation
const config = this._config; | ||
const root = this.shadowRoot; | ||
|
||
if (!this.initialized) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is temporary to avoid hammering the zigbee devices with actual cluster attribute requests as set hass(hass)
is invoked very often.
(e) => new DataRowZHA({ attributes: e }, config.strict) | ||
); | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: