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

fix: better node initialization #240

Merged
merged 7 commits into from
Jan 18, 2021
Merged

fix: better node initialization #240

merged 7 commits into from
Jan 18, 2021

Conversation

robertsLando
Copy link
Member

@robertsLando robertsLando commented Jan 14, 2021

Fixes #217
Fixes #256

@robertsLando
Copy link
Member Author

@ahochsteger could you give this a try?

@coveralls
Copy link

coveralls commented Jan 17, 2021

Pull Request Test Coverage Report for Build 493662310

  • 0 of 35 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.04%) to 23.603%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/ZwaveClient.js 0 35 0.0%
Totals Coverage Status
Change from base Build 491605456: -0.04%
Covered Lines: 1957
Relevant Lines: 8470

💛 - Coveralls

@ahochsteger
Copy link
Collaborator

@robertsLando I just tried out this branch with your changes.

Unfortunately it happened again that a battery-powered device (Fibaro Button) results in an "Unknown manufacturer" / "Unknown product", even though zwave-js was able to detect the manufacturer after a "Refresh info":
image

Here are the full logs:
zwavejs2mqtt.log
zwavejs_63428.log

I suspect that the problem lies in the fact that if a battery-powered device cannot be fully initialized, zwave-js will eventually set the node to ready without knowing the manufacturer and product.
When a full "Refresh info" is done at some time later zwave-js correctly updates the missing manufacturer / product data and even zwavejs2mqtt recognizes them but it seems that manufacturer and product are not updated in the UI.

Here are the relevant parts of the logfiles from above:

...
# zwave-js: Ping failed on sleeping device
14:37:15.715 CNTRLR   [Node 013] ping failed: The node is asleep
14:37:15.715 CNTRLR » [Node 013] querying node info...
...
# zwave-js: NodeInfo stage completes (failed):
15:12:22.635 CNTRLR   [Node 013] querying the node info failed
15:12:22.643 CNTRLR   [Node 013] Interview stage completed: NodeInfo
15:12:22.643 CNTRLR   [Node 013] WakeUpCC: doing a complete interview...
15:12:22.644 CNTRLR » [Node 013] retrieving wakeup interval from the device...
...
# Button is pressed on the device:
2021-01-17 15:34:42.494 INFO ZWAVE: Node 13: value added: 113-0-Home Security-Sensor status => 2
2021-01-17 15:34:42.554 INFO ZWAVE: Node 13: metadata updated: 91-0-scene-001
2021-01-17 15:34:42.561 INFO ZWAVE: Node 13: value notification: 91-0-scene-001 0
...
# zwave-js signals that the node is now ready to be used (although no manufacturer id and product id is known):
15:59:30.756 CNTRLR   [Node 013] Interview completed
15:59:30.779 CNTRLR   [Node 013] The node is ready to be used
2021-01-17 15:59:30.542 INFO ZWAVE: Node 13: value added: 132-0-wakeUpInterval => 3600
2021-01-17 15:59:30.542 INFO ZWAVE: Node 13: value added: 132-0-controllerNodeId => 1
2021-01-17 15:59:30.743 INFO ZWAVE: Node 13: value updated: 132-0-wakeUpInterval 3600 => 3600
2021-01-17 15:59:30.745 INFO ZWAVE: Node 13: value updated: 132-0-controllerNodeId 1 => 1
2021-01-17 15:59:30.779 DEBUG GATEWAY: Publishing discovery: {
  type: 'sensor',
  object_id: 'scene_state_001_scene',
  discovery_payload: {
    state_topic: 'zwavejs2mqtt/nodeID_13/91/0/scene/001',
    value_template: '{{ value_json.value}}',
    json_attributes_topic: 'zwavejs2mqtt/nodeID_13/91/0/scene/001',
    device: {
      identifiers: [ 'zwavejs2mqtt_0xcb10ff7c_node13', [length]: 1 ],
      manufacturer: 'Unknown manufacturer undefined',
      model: 'undefined (Unknown product undefined)',
      name: 'nodeID_13',
      sw_version: '1.0.0-beta.0'
    },
    name: 'nodeID_13_scene_state_001_scene',
    unique_id: 'zwavejs2mqtt_0xcb10ff7c_13-91-0-scene-001'
  },
  discoveryTopic: 'sensor/nodeID_13/scene_state_001_scene/config',
  values: [ '91-0-scene-001', [length]: 1 ],
  persistent: false,
  ignoreDiscovery: false
}
2021-01-17 15:59:30.768 INFO ZWAVE: Node 13: value added 13-132-0-wakeUpInterval => 3600
2021-01-17 15:59:30.778 INFO ZWAVE: Node 13: value added 13-132-0-controllerNodeId => 1
# zwavejs2mqtt completes node initialization as "unknown manufacturer/product":
2021-01-17 15:59:30.779 INFO ZWAVE: Node 13 ready: Unknown manufacturer undefined - Unknown product undefined (Unknown)
2021-01-17 15:59:30.780 INFO ZWAVE: Node 13: interview completed, all values are updated
2021-01-17 15:59:31.860 INFO ZWAVE: Node 13 is now asleep
...
# Manually trigger "Refresh info" for node 13 from zwavejs2mqtt and pressing Fibaro button 6x (for wakeup and send node info)
2021-01-17 19:19:29.797 INFO APP: Zwave api call: refreshInfo [ 13, [length]: 1 ]
2021-01-17 19:19:29.836 INFO ZWAVE: Success zwave api call refreshInfo
2021-01-17 19:19:38.790 INFO ZWAVE: Node 13 is now asleep
2021-01-17 19:19:44.271 INFO ZWAVE: Node 13 is now awake
# Here the manufacturerId, productType and productId are correctly updated:
2021-01-17 19:19:45.380 INFO ZWAVE: Node 13: value added: 114-0-manufacturerId => 271
2021-01-17 19:19:45.382 INFO ZWAVE: Node 13: value added: 114-0-productType => 3841
2021-01-17 19:19:45.383 INFO ZWAVE: Node 13: value added: 114-0-productId => 4096
# zwavejs2mqtt does not update manufacturer and product name in the UI and still shows it as "unknown"
...

@robertsLando
Copy link
Member Author

@AlCalzone what I don't understand here is why the ready event is triggered if the node isn't really ready? At least based on the supposition of @ahochsteger seems that when the ready event is triggered we are missing the manufacturer product type and id CCs

@AlCalzone
Copy link
Member

That's it:

# zwave-js: Ping failed on sleeping device
14:37:15.715 CNTRLR   [Node 013] ping failed: The node is asleep
14:37:15.715 CNTRLR » [Node 013] querying node info...
...
# zwave-js: NodeInfo stage completes (failed):
15:12:22.635 CNTRLR   [Node 013] querying the node info failed
15:12:22.643 CNTRLR   [Node 013] Interview stage completed: NodeInfo

Querying the node info fails for some reason, meaning we don't know which CCs are supported.
Because we don't know that, no CCs are queried except WakeUp CC (which is mandatory for Battery-powered devices).
After that, the interview is quickly finished, emitting the "ready" event.

@AlCalzone
Copy link
Member

So with the linked PR, we now abort the interview if requesting the node info fails.

@bdbogjoe
Copy link

bdbogjoe commented Jan 17, 2021

here my logs from linux using npm

zwavejs2mqtt.log
zwavejs_3944233.log

the same devices are well found from raspberry but here there is in logs :
2021-01-17 21:45:12.420 INFO ZWAVE: Node 6 ready: Unknown manufacturer undefined - Unknown product undefined (Unknown)

here the logs from the raspberry using npm:

zwavejs2mqtt.log
zwavejs_5363.log

INFO ZWAVE: Node 6 ready: Fibargroup - FGBS222 (Smart Implant)
INFO ZWAVE: Node 7 ready: Fibargroup - FGS223 (Double Switch 2)

@AlCalzone
Copy link
Member

@bdbogjoe the difference is that log one shows a restart from cache and log two a complete interview, including manufacturer info.
In the first one, that info should already be in the cache, but I can't tell without those files.

@bdbogjoe
Copy link

bdbogjoe commented Jan 17, 2021

here the logs from linux, now works fine with this branch !

zwavejs2mqtt.log
zwavejs_3984622.log

e86a487a.zip

@AlCalzone
Copy link
Member

Hm, probably was a fluke. If the issue persists after a refreshInfo, let me know.

@robertsLando robertsLando merged commit 3724e3f into master Jan 18, 2021
@robertsLando robertsLando deleted the fix-init-node branch January 18, 2021 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants