Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Commit

Permalink
[fix] Broken scenes after deprecation with OZW 16
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Jul 9, 2019
1 parent 6fd0373 commit 5a23372
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
29 changes: 14 additions & 15 deletions lib/ZwaveClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -752,22 +752,21 @@ ZwaveClient.prototype.callApi = async function (apiName, ...args) {
var err, result

if (this.connected) {
// check if apiName is a zwave function
// setScene is the only function that is not present in zwave client so
// I need to add it here to allow the call
if (typeof this.client[apiName] === 'function' || apiName === 'setScenes') {
try {
// custom scenes management
// use the custom scene and node/location management
if (apiName.toLowerCase().includes('scene') || apiName === 'setNodeName' || apiName === 'setNodeLocation') {
result = await this[apiName](...args)
} else {
result = this.client[apiName](...args)
}
} catch (e) {
err = e.message
try {
// Check if I need to call a zwave client function or a custom function
var useCustom = typeof this[apiName] === 'function' && (apiName.toLowerCase().includes('scene') || apiName === 'setNodeName' || apiName === 'setNodeLocation')

if (useCustom) {
result = await this[apiName](...args)
// custom scenes and node/location management
} else if (typeof this.client[apiName] === 'function') {
result = this.client[apiName](...args)
} else {
err = 'Unknown API'
}
} else err = 'Unknown API'
} catch (e) {
err = e.message
}
} else err = 'Zwave client not connected'

if (err) {
Expand Down
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"morgan": "~1.9.0",
"mqtt": "^2.15.1",
"nedb": "^1.8.0",
"openzwave-shared": "^1.5.1",
"openzwave-shared": "github:robertsLando/node-openzwave-shared-1#master",
"serialport": "^7.1.3",
"serve-favicon": "^2.4.5",
"socket.io": "^2.2.0",
Expand Down

0 comments on commit 5a23372

Please sign in to comment.