From 1c0c075e6a6c27b16ac82153c8b2f11ea4fe2c3d Mon Sep 17 00:00:00 2001
From: Dominic Griesel <dominic.griesel@nabucasa.com>
Date: Mon, 13 May 2024 12:56:21 +0200
Subject: [PATCH] refactor: rename `upgradeToLRRegion` to `preferLRRegion`

---
 docs/api/controller.md                             | 2 +-
 docs/api/driver.md                                 | 2 +-
 packages/zwave-js/src/lib/controller/Controller.ts | 6 +++---
 packages/zwave-js/src/lib/driver/ZWaveOptions.ts   | 4 ++--
 test/run.ts                                        | 3 +--
 5 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/docs/api/controller.md b/docs/api/controller.md
index 319a64532380..6175ffd6a163 100644
--- a/docs/api/controller.md
+++ b/docs/api/controller.md
@@ -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
 
diff --git a/docs/api/driver.md b/docs/api/driver.md
index 04700109dd02..7e0338c601b4 100644
--- a/docs/api/driver.md
+++ b/docs/api/driver.md
@@ -944,7 +944,7 @@ interface ZWaveOptions extends ZWaveHostOptions {
 		 *
 		 * Default: true.
 		 */
-		upgradeToLRRegion?: boolean;
+		preferLRRegion?: boolean;
 
 		txPower?: {
 			/** The desired TX power in dBm. */
diff --git a/packages/zwave-js/src/lib/controller/Controller.ts b/packages/zwave-js/src/lib/controller/Controller.ts
index bbf9385ca339..54151c3e69ce 100644
--- a/packages/zwave-js/src/lib/controller/Controller.ts
+++ b/packages/zwave-js/src/lib/controller/Controller.ts
@@ -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);
@@ -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);
diff --git a/packages/zwave-js/src/lib/driver/ZWaveOptions.ts b/packages/zwave-js/src/lib/driver/ZWaveOptions.ts
index 163bb897302b..4630c511558f 100644
--- a/packages/zwave-js/src/lib/driver/ZWaveOptions.ts
+++ b/packages/zwave-js/src/lib/driver/ZWaveOptions.ts
@@ -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. */
diff --git a/test/run.ts b/test/run.ts
index abd96d98904b..8976f4b2921a 100644
--- a/test/run.ts
+++ b/test/run.ts
@@ -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";
@@ -57,7 +56,7 @@ const driver = new Driver(port, {
 		),
 	},
 	rf: {
-		region: RFRegion.USA,
+		preferLRRegion: false,
 	},
 	storage: {
 		cacheDir: path.join(__dirname, "cache"),