Skip to content

Commit

Permalink
refactor: rename upgradeToLRRegion to preferLRRegion (#6845)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone authored May 13, 2024
1 parent 8b7e331 commit 752b8e5
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
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

0 comments on commit 752b8e5

Please sign in to comment.