Skip to content
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

Use device_id instead of config entry id and node id for zwave_js #12658

Merged
merged 5 commits into from
May 19, 2022

Conversation

raman325
Copy link
Contributor

@raman325 raman325 commented May 11, 2022

Proposed change

Instead of using config entry ID and node ID for any device specific WS commands, we now use device_id. This replaces #12642

Fixes #12641
Fixes #12136
Dependent on home-assistant/core#71667

Primary changes:

  • Got rid of dependencies on config entry ID and node ID where possible so we can just pass the device ID into the WS commands which is already available on these pages
  • Updated the network_status WS API command to return the node statuses instead of a list of node IDs so that we can save an API call

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@raman325
Copy link
Contributor Author

The related core PR has been approved

return;
}
showZWaveJSHealNodeDialog(this, {
entry_id: this._entryId,
node_id: this._nodeId,
entry_id: this._entryId!,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need entry_id here, can't we also make that work with device id?

Copy link
Contributor Author

@raman325 raman325 May 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the entry ID is still needed by dialog-zwave_js-heal-node so that it can get the network status here:

const network: ZWaveJSNetwork = await fetchZwaveNetworkStatus(
this.hass!,
this.entry_id!
);
We can pass just the device ID in and derive the entry ID in dialog-zwave_js-heal-node but we currently already have to figure out entry ID in ha-device-actions-zwave_js so that we can add it to the URL, so why recalculate it? Is it necessary to add it to the URL though? I couldn't figure out why we do that, and if it's not necessary, we can just pass the device ID in and only calculate entry ID in the heal node dialog

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another alternative would be to allow fetchZwaveNetworkStatus to accept either an entry ID or a device ID since it's used in both contexts. This could easily be supported in the core

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like the nicest approach

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Want to merge this and do that in a new PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea

bramkragten
bramkragten previously approved these changes May 18, 2022
raman325 and others added 2 commits May 18, 2022 14:45
…wave_js/ha-device-actions-zwave_js.ts

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
…wave_js/ha-device-info-zwave_js.ts

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
@balloob balloob merged commit 5b7b0ea into home-assistant:dev May 19, 2022
@raman325 raman325 deleted the device_id branch May 19, 2022 17:31
@github-actions github-actions bot locked and limited conversation to collaborators May 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants