homebridge-multiple-switch 1.6.0-beta.7 → 1.6.0-beta.9

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/index.js +30 -1
  3. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Changelog
2
2
 
3
- ## [1.6.0-beta.7] - 2026-03-21
3
+ ## [1.6.0-beta.9] - 2026-03-22
4
+
5
+ ### Fixed
6
+ - Homebridge v2 compatibility — plugin now shows green checkmark in v2 readiness check
7
+ - Switch ordering in HomeKit — services are now linked to ServiceLabel with
8
+ ServiceLabelIndex for deterministic ordering (requires re-adding accessory in HomeKit
9
+ if previously cached)
4
10
 
5
11
  ### Changed
6
12
  - Master switch type now defaults to Switch instead of Outlet (both UI and backend)
package/index.js CHANGED
@@ -117,22 +117,40 @@ class MultipleSwitchPlatform {
117
117
  const subtypeServices = accessory.services.filter((s) => s.subtype);
118
118
  subtypeServices.forEach((s) => accessory.removeService(s));
119
119
 
120
+ // Remove existing ServiceLabel if present, then re-add to ensure ordering
121
+ const existingLabel = accessory.services.find(
122
+ (s) => s.UUID === this.Service.ServiceLabel.UUID
123
+ );
124
+ if (existingLabel) accessory.removeService(existingLabel);
125
+
126
+ const labelService = accessory.addService(this.Service.ServiceLabel);
127
+ labelService.setCharacteristic(
128
+ this.Characteristic.ServiceLabelNamespace,
129
+ this.Characteristic.ServiceLabelNamespace.ARABIC_NUMERALS
130
+ );
131
+
132
+ let labelIndex = 1;
133
+ const orderedServices = [];
134
+
120
135
  // 1. Create master switch FIRST if enabled (appears at top in HomeKit)
121
136
  if (hasMaster) {
122
137
  const MasterServiceClass = this.getServiceClass(device.masterSwitchType || 'switch');
123
138
  const masterService = accessory.addService(MasterServiceClass, 'Master', MASTER_SUBTYPE);
124
139
 
125
140
  this.setServiceName(masterService, 'Master');
141
+ masterService.addOptionalCharacteristic(this.Characteristic.ServiceLabelIndex);
142
+ masterService.setCharacteristic(this.Characteristic.ServiceLabelIndex, labelIndex++);
126
143
  this.configureMasterHandler(accessory, masterService, services);
127
144
 
128
145
  services.set(MASTER_SUBTYPE, masterService);
146
+ orderedServices.push(masterService);
129
147
 
130
148
  if (accessory.context.switchStates[MASTER_SUBTYPE] === undefined) {
131
149
  accessory.context.switchStates[MASTER_SUBTYPE] = false;
132
150
  }
133
151
  }
134
152
 
135
- // 2. Create regular switches in order
153
+ // 2. Create regular switches in config order
136
154
  switches.forEach((sw, index) => {
137
155
  const subtype = `switch_${index}`;
138
156
 
@@ -140,15 +158,26 @@ class MultipleSwitchPlatform {
140
158
  const service = accessory.addService(ServiceClass, sw.name, subtype);
141
159
 
142
160
  this.setServiceName(service, sw.name);
161
+ service.addOptionalCharacteristic(this.Characteristic.ServiceLabelIndex);
162
+ service.setCharacteristic(this.Characteristic.ServiceLabelIndex, labelIndex++);
143
163
  this.configureSwitchHandlers(accessory, service, sw, subtype, services);
144
164
 
145
165
  services.set(subtype, service);
166
+ orderedServices.push(service);
146
167
 
147
168
  if (accessory.context.switchStates[subtype] === undefined) {
148
169
  accessory.context.switchStates[subtype] = sw.defaultState || false;
149
170
  }
150
171
  });
151
172
 
173
+ // Link all services to ServiceLabel for HomeKit ordering
174
+ for (const svc of orderedServices) {
175
+ labelService.addLinkedService(svc);
176
+ }
177
+
178
+ // Log service order for debugging
179
+ this.log.info(`[${device.name}] Service order: ${orderedServices.map((s, i) => `${i + 1}. ${s.displayName}`).join(', ')}`);
180
+
152
181
  // Clean up states for removed switches
153
182
  const activeKeys = new Set(services.keys());
154
183
  for (const key of Object.keys(accessory.context.switchStates)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-multiple-switch",
3
- "version": "1.6.0-beta.7",
3
+ "version": "1.6.0-beta.9",
4
4
  "description": "Multiple switch platform for Homebridge",
5
5
  "homepage": "https://github.com/azadaydinli/homebridge-multiple-switch",
6
6
  "main": "index.js",
@@ -31,6 +31,6 @@
31
31
  },
32
32
  "engines": {
33
33
  "node": ">=18.0.0",
34
- "homebridge": ">=1.3.0"
34
+ "homebridge": "^1.3.0 || ^2.0.0-beta.0"
35
35
  }
36
36
  }