Skip to content

Commit

Permalink
feat: long range support [email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando committed Jan 22, 2024
1 parent b9ac2e4 commit 86a6749
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 68 deletions.
25 changes: 25 additions & 0 deletions api/lib/ZwaveClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
ValueMetadataString,
ZWaveDataRate,
ZWaveErrorCodes,
Protocols,
} from '@zwave-js/core'
import { isDocker } from '@zwave-js/shared'
import {
Expand Down Expand Up @@ -541,6 +542,7 @@ export type ZUINode = {
}
defaultTransitionDuration?: string
defaultVolume?: number
protocol?: Protocols
}

export type NodeEvent = {
Expand All @@ -559,6 +561,10 @@ export type ZwaveConfig = {
S2_AccessControl: string
S0_Legacy: string
}>
securityKeysLongRange?: utils.DeepPartial<{
S2_Authenticated: string
S2_AccessControl: string
}>
serverEnabled?: boolean
enableSoftReset?: boolean
deviceConfigPriorityDir?: string
Expand Down Expand Up @@ -2233,6 +2239,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
}

zwaveOptions.securityKeys = {}
zwaveOptions.securityKeysLongRange = {}

// convert security keys to buffer
for (const key in this.cfg.securityKeys) {
Expand All @@ -2247,6 +2254,22 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
}
}

this.cfg.securityKeysLongRange =
this.cfg.securityKeysLongRange || {}

// convert security keys to buffer
for (const key in this.cfg.securityKeysLongRange) {
if (
availableKeys.includes(key) &&
this.cfg.securityKeysLongRange[key].length === 32
) {
zwaveOptions.securityKeysLongRange[key] = Buffer.from(
this.cfg.securityKeysLongRange[key],
'hex',
)
}
}

try {
// init driver here because if connect fails the driver is destroyed
// this could throw so include in the try/catch
Expand Down Expand Up @@ -5900,6 +5923,8 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
node.firmwareCapabilities =
zwaveNode.getFirmwareUpdateCapabilitiesCached()

node.protocol = zwaveNode.protocol

const storedNode = this.storeNodes[nodeId]

if (storedNode) {
Expand Down
94 changes: 47 additions & 47 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 @@ -108,7 +108,7 @@
"vuedraggable": "^2.24.3",
"vuetify": "^2.7.1",
"winston": "^3.11.0",
"zwave-js": "^12.4.1"
"zwave-js": "^12.5.0-beta.1"
},
"devDependencies": {
"@actions/github": "^6.0.0",
Expand Down
12 changes: 8 additions & 4 deletions src/stores/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ const useBaseStore = defineStore('base', {
},
logEnabled: true,
securityKeys: {
S2_Unauthenticated: undefined,
S2_Authenticated: undefined,
S2_AccessControl: undefined,
S0_Legacy: undefined,
S2_Unauthenticated: '',
S2_Authenticated: '',
S2_AccessControl: '',
S0_Legacy: '',
},
securityKeysLongRange: {
S2_Authenticated: '',
S2_AccessControl: '',
},
deviceConfigPriorityDir: '',
logToFile: true,
Expand Down
Loading

0 comments on commit 86a6749

Please sign in to comment.