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: auto-fallback to no supervision for start/stopLevelChange #1178

Merged
merged 2 commits into from
Dec 2, 2020

Conversation

AlCalzone
Copy link
Member

In #648 we changed start/stopLevelChange to use Supervision if it is supported. However this seems to cause problems with some devices.

With this PR we try a supervised command first. If that yields "No support", we remember that and fall back to an unsupervised command.

Side note: it might make sense to generalize this approach.

@AlCalzone AlCalzone self-assigned this Dec 1, 2020
@AlCalzone
Copy link
Member Author

@robertsLando @ODINServ this might fix the issue in zwave-js/zwave-js-ui#40 (review) - wanna give it a try?

@robertsLando
Copy link
Member

@ODINServ You should use the zwavejs2mqtt master with this branch of zwavejs

@ODINServ
Copy link

ODINServ commented Dec 1, 2020

Alright I don't have more time now, I'll try tomorrow

@@ -98,6 +99,14 @@ function getCurrentValueValueID(endpoint: number): ValueID {
};
}

/** Returns the ValueID used to remember whether a node supports supervision on the start/stop level change commands*/
export function getSuperviseStartStopLevelChangeValueId(): ValueID {
Copy link
Member

Choose a reason for hiding this comment

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

@AlCalzone Is this internal right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yeah

Copy link
Member

Choose a reason for hiding this comment

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

@AlCalzone I mean the valueId will not be crated right? It's an internal valueid? Does it need @internal ?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is one of the weirder parts of value IDs. The function won't be exported now. The valueID is marked internal in the CC constructor (registerValue, boolean parameter). One of the many aspects to be considered in #552

Copy link
Member

Choose a reason for hiding this comment

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

Not 100% clear to me but ok I trust you 😆

Copy link
Member

@robertsLando robertsLando left a comment

Choose a reason for hiding this comment

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

LGTM

@AlCalzone
Copy link
Member Author

Ok I'll wait for @ODINServ's test and then merge if it works.

@ODINServ
Copy link

ODINServ commented Dec 2, 2020

Ok I'll wait for @ODINServ's test and then merge if it works.

Hey,
I think i am doing something wrong it cannot find the module:

Here is what i did:
@mqtt

  • git checkout master
  • git pull
  • npm install
  • npm run build

@node-zwave-js

  • git checkout master
  • git pull
  • git checkout startstoplevelchange-test-supervision
  • npm install
  • npm run build
  • cd packages/zwave-js
  • npm link

(( No errors ))

@mqtt

  • npm link zwave-js
    (( output ))
$ npm link zwave-js

up to date, audited 2471 packages in 3s

1 package is looking for funding
  run `npm fund` for details

found 0 vulnerabilities
  • npm start
npm start

> zwavejs2mqtt@0.0.0 start
> node bin/www

Error: Cannot find module '@zwave-js/core'
Require stack:
- /home/user/zwave/zwavejs2mqtt/lib/ZwaveClient.js
- /home/user/zwave/zwavejs2mqtt/node_modules/app-root-path/lib/app-root-path.js
- /home/user/zwave/zwavejs2mqtt/node_modules/app-root-path/index.js
- /home/user/zwave/zwavejs2mqtt/bin/www
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:15)
    at Function.Module._load (node:internal/modules/cjs/loader:763:27)
    at Module.require (node:internal/modules/cjs/loader:991:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/home/user/zwave/zwavejs2mqtt/lib/ZwaveClient.js:12:44)
    at Module._compile (node:internal/modules/cjs/loader:1102:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
    at Module.load (node:internal/modules/cjs/loader:967:32)
    at Function.Module._load (node:internal/modules/cjs/loader:807:14)
    at Module.require (node:internal/modules/cjs/loader:991:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at require (/home/user/zwave/zwavejs2mqtt/node_modules/app-root-path/lib/app-root-path.js:14:11)
    at Object.<anonymous> (/home/user/zwave/zwavejs2mqtt/app.js:10:21)
    at Module._compile (node:internal/modules/cjs/loader:1102:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
    at Module.load (node:internal/modules/cjs/loader:967:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/user/zwave/zwavejs2mqtt/lib/ZwaveClient.js',
    '/home/user/zwave/zwavejs2mqtt/node_modules/app-root-path/lib/app-root-path.js',
    '/home/user/zwave/zwavejs2mqtt/node_modules/app-root-path/index.js',
    '/home/user/zwave/zwavejs2mqtt/bin/www'
  ]
}

Any clues ? i can revert to a snapshot of my vm and get it working but what am i doing wrong ?

@robertsLando
Copy link
Member

robertsLando commented Dec 2, 2020

Try to run : npx lerna exec -- npm link instead of npm link in zwave-js repo

zwave-js is using workspaces that is only supported by npm@7, but I saw that npm link seems is't working well so the lerna way should work (it's like running npm link for each subfolder of packages folder)

@ODINServ
Copy link

ODINServ commented Dec 2, 2020

$npm --version
7.0.14

@zwave-js

npx lerna exec -- npm link
results in lots of permission denied

So is did sudo npx lerna exec -- sudo npm link

But then:

[user@user-kvm zwavejs2mqtt]$ sudo npm link

added 1 package, and audited 2 packages in 449ms

found 0 vulnerabilities
[user@user-kvm zwavejs2mqtt]$ npm start

> zwavejs2mqtt@0.0.0 start
> node bin/www

Error: Cannot find module '@zwave-js/core'
Require stack:
- /home/user/zwave/zwavejs2mqtt/lib/ZwaveClient.js
- /home/user/zwave/zwavejs2mqtt/node_modules/app-root-path/lib/app-root-path.js
- /home/user/zwave/zwavejs2mqtt/node_modules/app-root-path/index.js
- /home/user/zwave/zwavejs2mqtt/bin/www
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:15)
    at Function.Module._load (node:internal/modules/cjs/loader:763:27)
    at Module.require (node:internal/modules/cjs/loader:991:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (/home/user/zwave/zwavejs2mqtt/lib/ZwaveClient.js:12:44)
    at Module._compile (node:internal/modules/cjs/loader:1102:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
    at Module.load (node:internal/modules/cjs/loader:967:32)
    at Function.Module._load (node:internal/modules/cjs/loader:807:14)
    at Module.require (node:internal/modules/cjs/loader:991:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at require (/home/user/zwave/zwavejs2mqtt/node_modules/app-root-path/lib/app-root-path.js:14:11)
    at Object.<anonymous> (/home/user/zwave/zwavejs2mqtt/app.js:10:21)
    at Module._compile (node:internal/modules/cjs/loader:1102:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
    at Module.load (node:internal/modules/cjs/loader:967:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/user/zwave/zwavejs2mqtt/lib/ZwaveClient.js',
    '/home/user/zwave/zwavejs2mqtt/node_modules/app-root-path/lib/app-root-path.js',
    '/home/user/zwave/zwavejs2mqtt/node_modules/app-root-path/index.js',
    '/home/user/zwave/zwavejs2mqtt/bin/www'
  ]
}

@robertsLando
Copy link
Member

robertsLando commented Dec 2, 2020

@ODINServ npm link that must be npm link zwave-js when running on zwavejs2mqtt folder

Zwavejs:

npx lerna exec -- npm link

Zwavejs2mqtt:

npm link zwave-js
npm link @zwave-js/core

@AlCalzone
Copy link
Member Author

Error: Cannot find module '@zwave-js/core'

@robertsLando doesn't @ODINServ also have to npm link @zwave-js/core in the zwavejs2mqtt repo?

@robertsLando
Copy link
Member

@AlCalzone Yes I have edited my comment

@ODINServ
Copy link

ODINServ commented Dec 2, 2020

That was it indeed :) but now my break is over, doing the actual test at lunch time.

@robertsLando
Copy link
Member

@AlCalzone IMO npm link should link all workspaces but seems it's not.

@AlCalzone
Copy link
Member Author

IMO npm link should link all workspaces but seems it's not.

I'll need to do some more testing with that. Judging from the command description, it should indeed.

@ODINServ
Copy link

ODINServ commented Dec 2, 2020

That was it indeed :) but now my break is over, doing the actual test at lunch time.

Well, that failed.

It still works! 💪 😄

Logs: zwave-js/zwave-js-ui#30 (comment)

@robertsLando
Copy link
Member

Ok I think we can merge this now @AlCalzone :)

@AlCalzone
Copy link
Member Author

perfect!

@AlCalzone AlCalzone merged commit 6ddf3bc into master Dec 2, 2020
@AlCalzone AlCalzone deleted the startstoplevelchange-test-supervision branch December 2, 2020 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants