homebridge-openwrt-control 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -9,6 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  - After update to v0.1.0 the plugin need to be reconfigured!
11
11
 
12
+ ## [0.4.1] - (25.09.2026)
13
+
14
+ ### Changes
15
+
16
+ - fix: Home Assistant radio entities had the same name on routers with two radios of one band (two `Wi-Fi 5 GHz`), radios are now named by band and radio number (`5 GHz Radio 0`, `Restart 5 GHz Radio 0`, `Channel 5 GHz Radio 0`), SSIDs get the radio added when the same network is on two radios of one band (`Dom 5 GHz Radio 2`). Entity ids do not change
17
+ - readme update
18
+
12
19
  ## [0.4.0] - (25.09.2026)
13
20
 
14
21
  ### Changes
package/README.md CHANGED
@@ -154,12 +154,12 @@ With `mqtt.haDiscovery` the router appears in Home Assistant as one device with
154
154
  | Entity | Type | Description |
155
155
  | --- | --- | --- |
156
156
  | `WAN` | binary_sensor (connectivity) | WAN interface up, `Internet` on routers without a `wan` interface |
157
- | `Wi-Fi 2.4 GHz`, `Wi-Fi 5 GHz`... | switch | Radio on/off |
158
- | `<SSID> <band>` | switch | SSID on/off |
159
- | `Restart Wi-Fi <band>` | button (restart) | Radio restart |
157
+ | `2.4 GHz Radio 0`, `5 GHz Radio 1`... | switch | Radio on/off, named by band and radio number |
158
+ | `<SSID> <band>` | switch | SSID on/off, the radio is added (`Dom 5 GHz Radio 2`) when the same network is on two radios of one band |
159
+ | `Restart <band> Radio <n>` | button (restart) | Radio restart |
160
160
  | `Reboot`, `Reload network`, `Reload Wi-Fi` | button | System reboot, network and wireless reload |
161
161
  | `Wi-Fi clients`, `<SSID> <band> clients` | sensor | Connected clients, total and per SSID |
162
- | `Channel <band>`, `TX power <band>` | sensor (diagnostic) | Current radio channel and TX power in dBm |
162
+ | `Channel <band> Radio <n>`, `TX power <band> Radio <n>` | sensor (diagnostic) | Current radio channel and TX power in dBm |
163
163
  | `WAN IP`, `Firmware`, `Last boot`, `Load`, `Memory usage` | sensor (diagnostic) | System information |
164
164
  | `<SSID> <band> QR code` | image | QR code to join the network, only with `mqtt.haWifiQr` |
165
165
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "OpenWrt Control",
3
3
  "name": "homebridge-openwrt-control",
4
- "version": "0.4.0",
4
+ "version": "0.4.1",
5
5
  "description": "Homebridge plugin to control OpenWrt flashed devices.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -164,25 +164,30 @@ class HaDiscovery {
164
164
  button('network_reload', { NetworkReload: true }, { name: 'Reload network', icon: 'mdi:lan-pending', entity_category: 'config' });
165
165
  button('wireless_reload', { WirelessReload: true }, { name: 'Reload Wi-Fi', icon: 'mdi:wifi-refresh', entity_category: 'config' });
166
166
 
167
- // Radios
167
+ // Radios, named by band and radio number (5 GHz Radio 0), tri-band routers have two radios of one band
168
168
  for (const radio of info.wirelessRadios ?? []) {
169
169
  const id = radio.name;
170
170
  const key = this.key(id);
171
- const label = BandLabel[radio.band] ?? id;
171
+ const label = this.radioLabel(radio);
172
172
  const radioInfo = ext.radios?.[id] ?? {};
173
- toggle(`radio_${key}`, id, 'Radio', { name: `Wi-Fi ${label}`, icon: 'mdi:wifi', value_template: `{{ 'ON' if value_json.radios['${id}'].on else 'OFF' }}` });
174
- button(`radio_${key}_restart`, { RadioRestart: { id } }, { name: `Restart Wi-Fi ${label}`, device_class: 'restart', entity_category: 'config' });
173
+ toggle(`radio_${key}`, id, 'Radio', { name: label, icon: 'mdi:wifi', value_template: `{{ 'ON' if value_json.radios['${id}'].on else 'OFF' }}` });
174
+ button(`radio_${key}_restart`, { RadioRestart: { id } }, { name: `Restart ${label}`, device_class: 'restart', entity_category: 'config' });
175
175
  if (this.has(`radio_${key}_channel`, radioInfo.channel != null)) sensor(`radio_${key}_channel`, { name: `Channel ${label}`, icon: 'mdi:access-point', entity_category: 'diagnostic', value_template: state(`.radios['${id}'].channel`) });
176
176
  if (this.has(`radio_${key}_txpower`, radioInfo.txpower != null)) sensor(`radio_${key}_txpower`, { name: `TX power ${label}`, icon: 'mdi:signal', unit_of_measurement: 'dBm', state_class: 'measurement', entity_category: 'diagnostic', value_template: state(`.radios['${id}'].txpower`) });
177
177
  }
178
178
 
179
179
  // SSIDs, the id is the UCI section so renaming the network keeps the entity
180
+ // SSIDs named by network and band (Dom 5 GHz), the radio is added when the same network is on two radios of one band
180
181
  const uci = info.wirelessInfo?.values ?? {};
182
+ const ssidBand = (ssid) => `${ssid.name} ${BandLabel[ssid.band] ?? ssid.radio ?? ''}`.trim();
183
+ const ssidLabels = (info.wirelessSsids ?? []).map(ssidBand);
181
184
  for (const ssid of info.wirelessSsids ?? []) {
182
185
  if (!ssid.section || !ssid.name) continue;
183
186
  const id = ssid.section;
184
187
  const key = this.key(id);
185
- const label = `${ssid.name} ${BandLabel[ssid.band] ?? ssid.radio ?? ''}`.trim();
188
+ const radio = (info.wirelessRadios ?? []).find(r => r.name === ssid.radio);
189
+ const duplicate = ssidLabels.filter(label => label === ssidBand(ssid)).length > 1;
190
+ const label = duplicate && radio ? `${ssid.name} ${this.radioLabel(radio)}` : ssidBand(ssid);
186
191
  toggle(`ssid_${key}`, id, 'Ssid', { name: label, icon: 'mdi:wifi-lock', value_template: `{{ 'ON' if value_json.ssids['${id}'].on else 'OFF' }}` });
187
192
  if (clientsAvailable && (ssid.mode ?? 'ap') === 'ap') sensor(`ssid_${key}_clients`, { name: `${label} clients`, icon: 'mdi:account-multiple', state_class: 'measurement', value_template: state(`.ssids['${id}'].clients`) });
188
193
 
@@ -248,6 +253,14 @@ class HaDiscovery {
248
253
  return qr.createSvgTag({ cellSize: 8, margin: 4, scalable: true });
249
254
  }
250
255
 
256
+ // 5 GHz Radio 0, the number from the radio name (radio0), other names as they are
257
+ radioLabel(radio) {
258
+ const number = String(radio.name).match(/^radio(\d+)$/)?.[1];
259
+ const band = BandLabel[radio.band];
260
+ const name = number !== undefined ? `Radio ${number}` : radio.name;
261
+ return band ? `${band} ${name}` : name;
262
+ }
263
+
251
264
  // Object id part of a radio or UCI section name
252
265
  key(id) {
253
266
  return String(id).replace(/[^a-zA-Z0-9_-]/g, '_');