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

refactor: rename upgradeToLRRegion to preferLRRegion #6845

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion docs/api/controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ export enum RFRegion {
}
```

> [!NOTE] Long Range capable regions are automatically preferred over their non-LR counterparts. This behavior can be disabled by setting the driver option `rf.upgradeToLRRegion` to `false`.
> [!NOTE] Long Range capable regions are automatically preferred over their non-LR counterparts. This behavior can be disabled by setting the driver option `rf.preferLRRegion` to `false`.

> [!ATTENTION] Not all controllers support configuring the RF region. These methods will throw if they are not supported

Expand Down
2 changes: 1 addition & 1 deletion docs/api/driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ interface ZWaveOptions extends ZWaveHostOptions {
*
* Default: true.
*/
upgradeToLRRegion?: boolean;
preferLRRegion?: boolean;

txPower?: {
/** The desired TX power in dBm. */
Expand Down
6 changes: 3 additions & 3 deletions packages/zwave-js/src/lib/controller/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1263,8 +1263,8 @@ export class ZWaveController
if (this.driver.options.rf?.region != undefined) {
desiredRFRegion = this.driver.options.rf.region;
}
// Unless auto-upgrade to LR regions is disabled, try to find a suitable replacement region
if (this.driver.options.rf?.upgradeToLRRegion !== false) {
// Unless preferring LR regions is disabled, try to find a suitable replacement region
if (this.driver.options.rf?.preferLRRegion !== false) {
desiredRFRegion ??= this.rfRegion;
if (desiredRFRegion != undefined) {
desiredRFRegion = this.tryGetLRCapableRegion(desiredRFRegion);
Expand Down Expand Up @@ -6080,7 +6080,7 @@ ${associatedNodes.join(", ")}`,
/** Configure the RF region at the Z-Wave API Module */
public async setRFRegion(region: RFRegion): Promise<boolean> {
// Unless auto-upgrade to LR regions is disabled, try to find a suitable LR replacement region
if (this.driver.options.rf?.upgradeToLRRegion !== false) {
if (this.driver.options.rf?.preferLRRegion !== false) {
region = this.tryGetLRCapableRegion(region);
}
return this.setRFRegionInternal(region, true);
Expand Down
4 changes: 2 additions & 2 deletions packages/zwave-js/src/lib/driver/ZWaveOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,12 @@ export interface ZWaveOptions extends ZWaveHostOptions {
region?: RFRegion;

/**
* Whether LR-capable regions should automatically be chosen over their corresponding non-LR regions, e.g. `USA` -> `USA (Long Range)`.
* Whether LR-capable regions should automatically be preferred over their corresponding non-LR regions, e.g. `USA` -> `USA (Long Range)`.
* This also overrides the `rf.region` setting if the desired region is not LR-capable.
*
* Default: true.
*/
upgradeToLRRegion?: boolean;
preferLRRegion?: boolean;

txPower?: {
/** The desired TX power in dBm. */
Expand Down
3 changes: 1 addition & 2 deletions test/run.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import { RFRegion } from "@zwave-js/core";
import { wait as _wait } from "alcalzone-shared/async";
import path from "node:path";
import "reflect-metadata";
Expand Down Expand Up @@ -57,7 +56,7 @@ const driver = new Driver(port, {
),
},
rf: {
region: RFRegion.USA,
preferLRRegion: false,
},
storage: {
cacheDir: path.join(__dirname, "cache"),
Expand Down
Loading