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

feat: long range support [email protected] #3545

Merged
merged 37 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
86a6749
feat: long range support [email protected]
robertsLando Jan 22, 2024
f23f608
feat(ui): add protocol column
robertsLando Jan 22, 2024
ef1af1a
feat: show long rage supported controllers
robertsLando Jan 22, 2024
7fa7a4b
feat(ui): smart start support
robertsLando Jan 22, 2024
5e4520b
feat(ui): add protocol selection on inclusion
robertsLando Jan 22, 2024
cae55aa
fix: revert dialogs manager
robertsLando Jan 22, 2024
6d152a7
fix: review nits
robertsLando Jan 23, 2024
27567b2
fix: hide/show security classes based on protocol
robertsLando Jan 23, 2024
39170cb
fix: hide some props from nodes panel
robertsLando Jan 23, 2024
c2aed1f
fix: skip routes fetch for LR
robertsLando Jan 23, 2024
81b30c1
fix: ensure requested security classes are resetted when changing pro…
robertsLando Jan 23, 2024
69e3991
fix: toggle protocol
robertsLando Jan 23, 2024
e2cb2ed
fix: set protocol when editing provisioning entry
robertsLando Jan 23, 2024
334d3dd
fix: disable provisioning entry when nodeId is defined
robertsLando Jan 23, 2024
8aa6731
fix: initial value of protocol smart start
robertsLando Jan 23, 2024
1adbc4e
fix: use button toggle
robertsLando Jan 23, 2024
2839c28
fix: return empty neighbors for long range nodes
robertsLando Jan 23, 2024
9bcf03a
fix(ui): remove rebuild routes action for long range nodes
robertsLando Jan 23, 2024
dab1cd9
fix: hide missing props
robertsLando Jan 23, 2024
ada2b59
Merge branch 'master' into feat-long-range
robertsLando Jan 23, 2024
2e738b8
fix: add missing deps
robertsLando Jan 23, 2024
6eb69ad
fix(ui): show protocol in panel and fix diagnose
robertsLando Jan 23, 2024
175c339
Merge branch 'master' into feat-long-range
robertsLando Jan 23, 2024
a02686b
fix: create utils methods
robertsLando Jan 23, 2024
371bc44
fix: bump zjs server 1.35.0-beta.1
robertsLando Jan 24, 2024
2a6979d
fix: show `-----` when no statistics available
robertsLando Jan 24, 2024
59ce90e
Merge branch 'master' of https://github.com/zwave-js/zwave-js-ui into…
robertsLando Jan 30, 2024
9b2c563
fix: controller supported protocols
robertsLando Jan 31, 2024
f8f11ea
fix: fw version undefined
robertsLando Jan 31, 2024
0d53b37
Merge branch 'master' of https://github.com/zwave-js/zwave-js-ui into…
robertsLando Feb 2, 2024
19bf575
fix: show protocol icons in line
robertsLando Feb 2, 2024
ab86077
Merge branch 'master' into feat-long-range
robertsLando Feb 6, 2024
bd96733
Merge branch 'master' of https://github.com/zwave-js/zwave-js-ui into…
robertsLando Feb 12, 2024
799296f
Merge branch 'master' into feat-long-range
robertsLando Mar 4, 2024
76cb052
Merge branch 'master' into feat-long-range
robertsLando Mar 5, 2024
950b877
Merge branch 'master' into feat-long-range
robertsLando Mar 27, 2024
5ea2ead
feat: bump [email protected]
robertsLando Apr 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 61 additions & 1 deletion 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 @@ -100,6 +101,7 @@ import {
PartialZWaveOptions,
InclusionUserCallbacks,
InclusionState,
ProvisioningEntryStatus,
} from 'zwave-js'
import { getEnumMemberName, parseQRCodeString } from 'zwave-js/Utils'
import { logsDir, nvmBackupsDir, storeDir } from '../config/app'
Expand Down Expand Up @@ -555,6 +557,8 @@ export type ZUINode = {
}
defaultTransitionDuration?: string
defaultVolume?: number
protocol?: Protocols
supportsLongRange?: boolean
}

export type NodeEvent = {
Expand All @@ -573,6 +577,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 @@ -2028,6 +2036,12 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
throw new DriverNotReadyError()
}

const zwaveNode = this.getNode(nodeId)

if (zwaveNode.protocol === Protocols.ZWaveLongRange) {
return []
}

const neighbors =
await this._driver.controller.getNodeNeighbors(nodeId)
this.logNode(nodeId, 'debug', `Neighbors: ${neighbors.join(', ')}`)
Expand Down Expand Up @@ -2249,6 +2263,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
}

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

// convert security keys to buffer
for (const key in this.cfg.securityKeys) {
Expand All @@ -2263,6 +2278,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 @@ -4973,6 +5004,16 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
throw Error('DSK is required')
}

const isNew = !this.driver.controller.getProvisioningEntry(entry.dsk)

// disable it so user can choose the protocol to use
if (
isNew &&
entry.supportedProtocols?.includes(Protocols.ZWaveLongRange)
) {
entry.status = ProvisioningEntryStatus.Inactive
}

this.driver.controller.provisionSmartStartNode(entry)

return entry
Expand Down Expand Up @@ -5133,6 +5174,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
node.ready = true

if (node.isControllerNode) {
node.supportsLongRange = this.driver.controller.supportsLongRange
this.updateControllerNodeProps(node).catch((error) => {
this.logNode(
zwaveNode,
Expand Down Expand Up @@ -5182,7 +5224,11 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
)
}

if (!zwaveNode.isControllerNode) {
// Long range nodes use a star topology, so they don't have return/priority routes
if (
!zwaveNode.isControllerNode &&
zwaveNode.protocol !== Protocols.ZWaveLongRange
) {
this.getPriorityRoute(zwaveNode.id).catch((error) => {
this.logNode(
zwaveNode,
Expand Down Expand Up @@ -5947,6 +5993,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
node.firmwareCapabilities =
zwaveNode.getFirmwareUpdateCapabilitiesCached()

node.protocol = zwaveNode.protocol
const storedNode = this.storeNodes[nodeId]

if (storedNode) {
Expand Down Expand Up @@ -6012,12 +6059,22 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
} else {
logger.info('RF region is not supported by controller')
}

// when RF region changes, check if long range is supported
if (
this.driver.controller.supportsLongRange !==
node.supportsLongRange
) {
node.supportsLongRange =
this.driver.controller.supportsLongRange
}
}

this.emitNodeUpdate(node, {
powerlevel: node.powerlevel,
measured0dBm: node.measured0dBm,
RFRegion: node.RFRegion,
supportsLongRange: node.supportsLongRange,
})
}

Expand Down Expand Up @@ -6397,6 +6454,7 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
| 'manufacturer'
| 'productDescription'
| 'productLabel'
| 'supportsLongRange'
>
> {
const zuiNode = this.nodes.get(node.id)
Expand Down Expand Up @@ -6433,6 +6491,8 @@ class ZwaveClient extends TypedEventEmitter<ZwaveClientEventCallbacks> {
productLabel: zuiNode?.productLabel,
deviceDatabaseUrl: node.deviceDatabaseUrl,
keepAwake: node.keepAwake,
protocol: node.protocol,
supportsLongRange: zuiNode?.supportsLongRange,
}
}

Expand Down
Loading
Loading