Skip to content

Add zwave_js WS API command to call node.refresh_info#48564

Merged
MartinHjelmare merged 3 commits intohome-assistant:devfrom
raman325:refresh_node_info
Apr 1, 2021
Merged

Add zwave_js WS API command to call node.refresh_info#48564
MartinHjelmare merged 3 commits intohome-assistant:devfrom
raman325:refresh_node_info

Conversation

@raman325
Copy link
Copy Markdown
Contributor

@raman325 raman325 commented Mar 31, 2021

Proposed change

This command will allow us to build a button to re-interview a node into the UI

CC - @cgarwood

Type of change

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

Example entry for configuration.yaml:

# Example configuration.yaml

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

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

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@probot-home-assistant
Copy link
Copy Markdown

Hey there @home-assistant/z-wave, mind taking a look at this pull request as its been labeled with an integration (zwave_js) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

@cgarwood
Copy link
Copy Markdown
Member

If we're using it to trigger a full re-interview, should we call it reinterview or reinterview_node instead of refresh_info?

@raman325
Copy link
Copy Markdown
Contributor Author

If we're using it to trigger a full re-interview, should we call it reinterview or reinterview_node instead of refresh_info?

Do we want to deviate from the Z-Wave JS API? I was just pulling over what it was called.

@cgarwood
Copy link
Copy Markdown
Member

hmm good question. probably best to match Z-Wave JS API

@raman325
Copy link
Copy Markdown
Contributor Author

This is just backend, maybe in the frontend we can call it Re-Interview to be more friendly to users

Comment thread homeassistant/components/zwave_js/api.py
Comment thread tests/components/zwave_js/test_api.py Outdated
@cgarwood
Copy link
Copy Markdown
Member

cgarwood commented Apr 1, 2021

What all events does Z-Wave JS emit during a re-interview? It would be nice to attach listeners to all or some of them and feed that data back to the frontend (similar to the add and remove node websocket commands)

@MartinHjelmare
Copy link
Copy Markdown
Member

Do we need to check for an existing interview in progress? There's a warning in the docs about this.

https://zwave-js.github.io/node-zwave-js/#/api/node?id=refreshinfo

@raman325
Copy link
Copy Markdown
Contributor Author

raman325 commented Apr 1, 2021

What all events does Z-Wave JS emit during a re-interview? It would be nice to attach listeners to all or some of them and feed that data back to the frontend (similar to the add and remove node websocket commands)

Nothing that I can tell. I just tried doing a re-interview, the only notifications I got were a node ready and interview completed event. I think that means that we are completely blind to the interview process at the moment, although the status is displayed in zwavejs2mqtt so there must be a way to see it

@raman325
Copy link
Copy Markdown
Contributor Author

raman325 commented Apr 1, 2021

Here's a dump of the command to refresh info and the eventual response:

{
  type: 'result',
  success: true,
  messageId: 'refresh-info',
  result: {}
}
{
  type: 'event',
  event: {
    source: 'node',
    event: 'ready',
    nodeId: 4,
    nodeState: {
      nodeId: 4,
      index: 0,
      installerIcon: 1536,
      userIcon: 1536,
      status: 4,
      ready: true,
      isListening: true,
      isRouting: true,
      isSecure: false,
      manufacturerId: 99,
      productId: 12344,
      productType: 18756,
      firmwareVersion: '5.26',
      zwavePlusVersion: 1,
      deviceConfig: [Object],
      label: '14294 / ZW3005',
      neighbors: [Array],
      interviewAttempts: 1,
      interviewStage: 6,
      endpoints: [Array],
      values: [Array],
      isFrequentListening: false,
      maxDataRate: 100000,
      supportedDataRates: [Array],
      protocolVersion: 3,
      supportsBeaming: true,
      supportsSecurity: false,
      nodeType: 1,
      zwavePlusNodeType: 0,
      zwavePlusRoleType: 5,
      deviceClass: [Object],
      commandClasses: [Array]
    }
  }
}
{
  type: 'event',
  event: { source: 'node', event: 'interview completed', nodeId: 4 }
}

@MartinHjelmare
Copy link
Copy Markdown
Member

What all events does Z-Wave JS emit during a re-interview? It would be nice to attach listeners to all or some of them and feed that data back to the frontend (similar to the add and remove node websocket commands)

I think it's this:
https://zwave-js.github.io/node-zwave-js/#/api/node?id=interviewstage

@raman325
Copy link
Copy Markdown
Contributor Author

raman325 commented Apr 1, 2021

What all events does Z-Wave JS emit during a re-interview? It would be nice to attach listeners to all or some of them and feed that data back to the frontend (similar to the add and remove node websocket commands)

I think it's this:
https://zwave-js.github.io/node-zwave-js/#/api/node?id=interviewstage

They aren't exposed as events right now so we'd have to make some changes in zwave-js-server to support this. Specifically from what I can tell we could watch status transitions of the node.ready property and only allow this command to run if the node is in a ready state. If we want to track interview progress, we'd have to add events to node-zwave-js because there is no way to watch the node.interviewStage property as far as I could tell As of now nothing is exposed that we can trigger on

@raman325
Copy link
Copy Markdown
Contributor Author

raman325 commented Apr 1, 2021

I asked Al about this in Discord (link: https://discord.com/channels/330944238910963714/800356888827002880/827243327551176756). Here was his response:
Hmm... if interviewStage is not Completed and you haven't gotten the final interviewFailed event, then an interview is going on. But I'm not sure if it is a good idea to forbid that - we had a situation where battery powered nodes were stuck in ProtocolInfo and the best way out was to re-interview.
Also, zwave-js 7 now correctly aborts the previous interview when a new one is started, so this is less of a concern (except unnecessary re-interview)

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Looks good!

@MartinHjelmare
Copy link
Copy Markdown
Member

@cgarwood is this ok for you to work with for now?

@cgarwood
Copy link
Copy Markdown
Member

cgarwood commented Apr 1, 2021

Ya this will work for now and we can add subscriptions for status updates later when there's more upstream support

@MartinHjelmare MartinHjelmare merged commit ebb369e into home-assistant:dev Apr 1, 2021
@raman325 raman325 deleted the refresh_node_info branch April 2, 2021 00:59
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants