homebridge-cync-app 0.1.3 → 0.1.6

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.
@@ -3,119 +3,180 @@
3
3
  <img
4
4
  src="icon.png"
5
5
  alt="Cync App Icon"
6
- style="width: 96px; height: 96px; border-radius: 5px;"
6
+ style="width:96px;height:96px;border-radius:5px;"
7
7
  />
8
8
  </div>
9
- <div class="card card-body">
10
- <div id="options" class="card-body my-3 w-75 mx-auto">
11
- <div class="alert alert-warning" role="alert">
12
- It is recommended to create a second Cync account and share your home
13
- between accounts to avoid issues with Cync servers and the official Cync App.
14
- </div>
15
-
16
- <form id="authForm" class="form-horizontal">
17
- <div id="codeDiv" class="card-body my-3 w-75 mx-auto">
18
- <div class="mb-3">
19
- <label class="form-label" for="emailAddress">Cync Email Address</label>
20
- <input class="form-control" type="email" id="emailAddress" placeholder="name@example.com" />
21
- </div>
22
-
23
- <button type="button" class="btn btn-secondary text-center" id="requestCode">
24
- Request 2FA Code
25
- </button>
26
- </div>
27
-
28
- <div id="authDiv" class="card-body my-3 w-75 mx-auto">
29
- <div class="mb-3">
30
- <label class="form-label" for="password">Cync Password</label>
31
- <input class="form-control" type="password" id="password" />
32
- </div>
33
-
34
- <div class="mb-3">
35
- <label class="form-label" for="mfaCode">2FA Code</label>
36
- <input class="form-control" type="text" id="mfaCode" />
37
- </div>
38
-
39
- <button type="button" class="btn btn-primary text-center" id="login">
40
- Login
41
- </button>
42
- </div>
43
- </form>
44
- </div>
9
+
10
+ <div class="card mb-3">
11
+ <div class="card-body">
12
+ <h3 class="card-title">Homebridge Cync App</h3>
13
+ <p class="card-text">
14
+ Enter your Cync Username, Password, and 6 digit verification code emailed to you by Cync.
15
+ To obtain a fresh code, use the <strong>Request Verification Code</strong> button, then click the Homebridge
16
+ <strong>Save</strong> button at the bottom once you’ve entered the code.
17
+ </p>
18
+ </div>
19
+ </div>
20
+
21
+ <div class="card mb-3">
22
+ <div class="card-body">
23
+ <h5 class="card-title">Cync Cloud Credentials</h5>
24
+
25
+ <div class="mb-3">
26
+ <label for="cyncEmail" class="form-label">Email</label>
27
+ <input type="email" id="cyncEmail" class="form-control" autocomplete="username">
28
+ </div>
29
+
30
+ <div class="mb-3">
31
+ <label for="cyncPassword" class="form-label">Password</label>
32
+ <input type="password" id="cyncPassword" class="form-control" autocomplete="current-password">
33
+ </div>
34
+
35
+ <div class="d-flex flex-wrap gap-2 mb-3">
36
+ <button id="cyncRequestOtpBtn" class="btn btn-secondary">
37
+ Request Verification Code
38
+ </button>
39
+ <button id="cyncSignOutBtn" class="btn btn-outline-danger">
40
+ Sign Out
41
+ </button>
42
+ <span id="cyncStatus" class="align-self-center text-muted ms-2"></span>
43
+ </div>
44
+
45
+ <div class="mb-3">
46
+ <label for="cyncOtp" class="form-label">Verification Code (OTP)</label>
47
+ <input type="text" id="cyncOtp" class="form-control" autocomplete="one-time-code">
48
+ </div>
49
+ </div>
50
+ </div>
45
51
  </div>
46
52
 
47
53
  <script>
48
- homebridge.addEventListener('ready', async () => {
49
- const pluginConfig = await homebridge.getPluginConfig();
50
-
51
- if (pluginConfig[0]) {
52
- const cfg = pluginConfig[0];
53
- document.getElementById('emailAddress').value =
54
- cfg.username || cfg.email || '';
55
- }
56
-
57
- document
58
- .getElementById('requestCode')
59
- .addEventListener('click', () => {
60
- document.getElementById('mfaCode').value = '';
61
-
62
- const emailAddress =
63
- document.getElementById('emailAddress').value || '';
64
- if (!emailAddress) {
65
- homebridge.toast.error('Please enter your Cync email address.');
66
- return;
67
- }
68
-
69
- homebridge
70
- .request('/requestCode', { emailAddress })
71
- .then(() => {
72
- homebridge.toast.info(
73
- `Please check your ${emailAddress} inbox for your 2FA code.`,
74
- );
75
- })
76
- .catch((err) => {
77
- homebridge.toast.error(
78
- `Failed to request 2FA code: ${String(err)}`,
79
- );
80
- });
81
- });
82
-
83
- document.getElementById('login').addEventListener('click', () => {
84
- const payload = {
85
- emailAddress: document.getElementById('emailAddress').value || '',
86
- password: document.getElementById('password').value || '',
87
- mfaCode: document.getElementById('mfaCode').value || '',
88
- };
89
-
90
- if (!payload.emailAddress || !payload.password || !payload.mfaCode) {
91
- homebridge.toast.error(
92
- 'Please enter email, password, and 2FA code.',
93
- );
94
- return;
95
- }
96
-
97
- homebridge
98
- .request('/login', payload)
99
- .then(async (config) => {
100
- if (config && config.error) {
101
- homebridge.toast.error(config.error);
102
- document.getElementById('password').value = '';
103
- document.getElementById('mfaCode').value = '';
104
- return;
105
- }
106
-
107
- await homebridge.updatePluginConfig([config]);
108
- homebridge.toast.success(
109
- 'You have successfully authenticated with Cync!',
110
- );
111
- await homebridge.savePluginConfig();
112
- homebridge.closeSettings();
113
- })
114
- .catch((err) => {
115
- homebridge.toast.error(
116
- `Login failed: ${String(err)}`,
117
- );
118
- });
119
- });
120
- });
54
+ homebridge.addEventListener('ready', async () => {
55
+ const emailInput = document.getElementById('cyncEmail');
56
+ const passwordInput = document.getElementById('cyncPassword');
57
+ const otpInput = document.getElementById('cyncOtp');
58
+ const requestOtpBtn = document.getElementById('cyncRequestOtpBtn');
59
+ const signOutBtn = document.getElementById('cyncSignOutBtn');
60
+ const statusEl = document.getElementById('cyncStatus');
61
+
62
+ let pluginConfig = await homebridge.getPluginConfig();
63
+ let cfg = pluginConfig[0] || {};
64
+
65
+ // Helper to update in-memory pluginConfig (persisted when user clicks Save in HB)
66
+ async function updateConfig(partial) {
67
+ cfg = { ...cfg, ...partial };
68
+ pluginConfig = [cfg];
69
+ await homebridge.updatePluginConfig(pluginConfig);
70
+ }
71
+
72
+ function setLockedState(locked) {
73
+ emailInput.disabled = locked;
74
+ passwordInput.disabled = locked;
75
+ otpInput.disabled = locked;
76
+ requestOtpBtn.disabled = locked;
77
+ // Sign Out remains enabled so the user can clear things
78
+ }
79
+
80
+ // Load from config.json into UI
81
+ emailInput.value = cfg.username || '';
82
+ passwordInput.value = cfg.password || '';
83
+ otpInput.value = cfg.twoFactor || '';
84
+
85
+ // Check token status and lock fields if a token exists
86
+ try {
87
+ const status = await homebridge.request('/status');
88
+ if (status && status.ok && status.hasToken) {
89
+ setLockedState(true);
90
+ statusEl.textContent = 'Signed in. Click Sign Out to change credentials.';
91
+ }
92
+ } catch (e) {
93
+ console.error('[cync-ui] /status request failed:', e);
94
+ }
95
+
96
+ // Request OTP email via server.js
97
+ requestOtpBtn.addEventListener('click', async () => {
98
+ const email = emailInput.value.trim();
99
+ const password = passwordInput.value; // do not trim
100
+
101
+ if (!email || !password) {
102
+ homebridge.toast.warning('Enter email and password first.', 'Missing Credentials');
103
+ return;
104
+ }
105
+
106
+ homebridge.showSpinner();
107
+ statusEl.textContent = 'Requesting verification code…';
108
+
109
+ try {
110
+ // Persist latest credentials BEFORE requesting OTP
111
+ await updateConfig({
112
+ username: email,
113
+ password,
114
+ });
115
+
116
+ const res = await homebridge.request('/request-otp', { email });
117
+
118
+ if (res && res.ok) {
119
+ statusEl.textContent = 'Code requested. Check your email.';
120
+ homebridge.toast.success('Verification code sent.', 'OTP Requested');
121
+ } else {
122
+ statusEl.textContent = 'Request may have failed. Check logs.';
123
+ homebridge.toast.warning('Unexpected response requesting code.', 'OTP Request');
124
+ }
125
+ } catch (err) {
126
+ console.error('[cync-ui] Failed to request OTP:', err);
127
+ statusEl.textContent = 'OTP request failed. See logs.';
128
+ homebridge.toast.error('Failed to request 2FA code.', 'Error');
129
+ } finally {
130
+ homebridge.hideSpinner();
131
+ }
132
+ });
133
+
134
+ // OTP field updates config; Homebridge Save persists it
135
+ otpInput.addEventListener('change', async () => {
136
+ try {
137
+ await updateConfig({
138
+ username: emailInput.value.trim(),
139
+ password: passwordInput.value,
140
+ twoFactor: otpInput.value.trim(),
141
+ });
142
+ statusEl.textContent = 'Verification code updated. Click Save.';
143
+ } catch (e) {
144
+ console.error('[cync-ui] Failed to update OTP in config:', e);
145
+ statusEl.textContent = 'Failed to update verification code.';
146
+ }
147
+ });
148
+
149
+ // Sign Out: clear token + unlock fields
150
+ signOutBtn.addEventListener('click', async () => {
151
+ homebridge.showSpinner();
152
+ statusEl.textContent = 'Signing out…';
153
+
154
+ try {
155
+ await homebridge.request('/sign-out');
156
+
157
+ // Clear UI fields
158
+ emailInput.value = '';
159
+ passwordInput.value = '';
160
+ otpInput.value = '';
161
+
162
+ // Clear config (in memory) and unlock inputs
163
+ await updateConfig({
164
+ username: '',
165
+ password: '',
166
+ twoFactor: '',
167
+ });
168
+
169
+ setLockedState(false);
170
+
171
+ statusEl.textContent = 'Signed out. Click Save to apply.';
172
+ homebridge.toast.success('Signed out. Click Save to apply.', 'Signed Out');
173
+ } catch (e) {
174
+ console.error('[cync-ui] Sign-out failed:', e);
175
+ statusEl.textContent = 'Sign-out failed.';
176
+ homebridge.toast.error('Failed to sign out.', 'Error');
177
+ } finally {
178
+ homebridge.hideSpinner();
179
+ }
180
+ });
181
+ });
121
182
  </script>
@@ -1,97 +1,62 @@
1
1
  // homebridge-ui/server.js
2
2
  import { HomebridgePluginUiServer } from '@homebridge/plugin-ui-utils';
3
- import fetch from 'node-fetch';
3
+ import { ConfigClient } from '../dist/cync/config-client.js';
4
+ import { CyncTokenStore } from '../dist/cync/token-store.js';
4
5
 
5
- class PluginUiServer extends HomebridgePluginUiServer {
6
+ class CyncUiServer extends HomebridgePluginUiServer {
6
7
  constructor() {
7
8
  super();
8
9
 
9
- this.onRequest('/requestCode', this.handleRequestCode.bind(this));
10
- this.onRequest('/login', this.handleLogin.bind(this));
10
+ this.configClient = new ConfigClient({
11
+ debug: (...a) => console.debug('[cync-ui-config]', ...a),
12
+ info: (...a) => console.info('[cync-ui-config]', ...a),
13
+ warn: (...a) => console.warn('[cync-ui-config]', ...a),
14
+ error: (...a) => console.error('[cync-ui-config]', ...a),
15
+ });
16
+
17
+ this.tokenStore = new CyncTokenStore(this.homebridgeStoragePath);
18
+
19
+ this.onRequest('/request-otp', this.handleRequestOtp.bind(this));
20
+ this.onRequest('/sign-out', this.handleSignOut.bind(this));
21
+ this.onRequest('/status', this.handleStatus.bind(this));
11
22
 
12
- // Tell Homebridge UI that we’re ready
13
23
  this.ready();
14
24
  }
15
25
 
16
- // Request a 2FA code via email
17
- async handleRequestCode(payload) {
18
- const email = (payload?.emailAddress || '').trim();
26
+ async handleRequestOtp(payload) {
27
+ const email = typeof payload?.email === 'string' ? payload.email.trim() : '';
19
28
  if (!email) {
20
- throw new Error('Email address is required to request a 2FA code.');
29
+ return { ok: false, error: 'Missing email' };
21
30
  }
22
31
 
23
- const requestBody = {
24
- corp_id: '1007d2ad150c4000',
25
- email,
26
- local_lang: 'en-us',
27
- };
28
-
29
- await fetch(
30
- 'https://api.gelighting.com/v2/two_factor/email/verifycode',
31
- {
32
- method: 'POST',
33
- body: JSON.stringify(requestBody),
34
- headers: { 'Content-Type': 'application/json' },
35
- },
36
- );
32
+ await this.configClient.sendTwoFactorCode(email);
33
+ return { ok: true };
37
34
  }
38
35
 
39
- // Validate email + password + 2FA against Cync and return platform config
40
- async handleLogin(payload) {
41
- const email = (payload?.emailAddress || '').trim();
42
- const password = (payload?.password || '').trim();
43
- const mfaCode = (payload?.mfaCode || '').trim();
44
-
45
- if (!email || !password || !mfaCode) {
46
- return {
47
- error: 'Email, password, and 2FA code are required.',
48
- };
49
- }
50
-
51
- const requestBody = {
52
- corp_id: '1007d2ad150c4000',
53
- email,
54
- password,
55
- two_factor: mfaCode,
56
- resource: 'abcdefghijk',
57
- };
36
+ // Delete token file
37
+ async handleSignOut() {
38
+ await this.tokenStore.clear();
39
+ return { ok: true };
40
+ }
58
41
 
42
+ // Report whether a token exists
43
+ async handleStatus() {
59
44
  try {
60
- const response = await fetch(
61
- 'https://api.gelighting.com/v2/user_auth/two_factor',
62
- {
63
- method: 'POST',
64
- body: JSON.stringify(requestBody),
65
- headers: { 'Content-Type': 'application/json' },
66
- },
67
- );
68
-
69
- const data = await response.json();
70
- if (data && data.error) {
71
- return {
72
- error:
73
- 'Login failed. Please check your password and 2FA code.',
74
- };
45
+ const token = await this.tokenStore.load();
46
+ if (!token) {
47
+ return { ok: true, hasToken: false };
75
48
  }
76
- } catch (err) {
77
- console.error('[cync-ui] Login request failed:', err);
78
49
  return {
79
- error:
80
- 'Login failed due to a network or server error. Please try again.',
50
+ ok: true,
51
+ hasToken: true,
52
+ userId: token.userId,
53
+ expiresAt: token.expiresAt ?? null,
81
54
  };
55
+ } catch {
56
+ // On error, just say "no token"
57
+ return { ok: true, hasToken: false };
82
58
  }
83
-
84
- // At this point, Cync accepted the credentials.
85
- // Return the platform config that your platform.ts expects.
86
- return {
87
- platform: 'CyncAppPlatform',
88
- name: 'Cync App',
89
- username: email,
90
- password,
91
- twoFactor: mfaCode,
92
- };
93
59
  }
94
60
  }
95
61
 
96
- // Start the instance
97
- (() => new PluginUiServer())();
62
+ (() => new CyncUiServer())();
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "homebridge-cync-app",
3
3
  "displayName": "Homebridge Cync App",
4
4
  "type": "module",
5
- "version": "0.1.3",
5
+ "version": "0.1.6",
6
6
  "private": false,
7
7
  "description": "Homebridge plugin that integrates your GE Cync account (via the Cync app/API) and exposes all supported devices: plugs, lights, switches, etc",
8
8
  "author": "Dustin Newell",
@@ -19,21 +19,20 @@
19
19
  "homebridge-plugin",
20
20
  "homebridge",
21
21
  "cync",
22
- "ge",
23
22
  "ge cync",
24
- "ge-lighting",
25
23
  "smart plug",
26
24
  "smart lights",
27
25
  "C by GE"
28
26
  ],
29
27
  "main": "dist/index.js",
30
- "publishConfig": {
31
- "access": "public"
32
- },
33
28
  "homebridge": {
34
29
  "pluginType": "platform",
35
30
  "platform": "CyncAppPlatform"
36
31
  },
32
+ "funding": {
33
+ "type" : "paypal",
34
+ "url" : "https://paypal.me/DustinNewell"
35
+ },
37
36
  "engines": {
38
37
  "node": "^20.18.0 || ^22.10.0 || ^24.0.0",
39
38
  "homebridge": "^1.8.0 || ^2.0.0-beta.0"
@@ -45,9 +44,7 @@
45
44
  "watch": "npm run build && npm link && nodemon"
46
45
  },
47
46
  "dependencies": {
48
- "homebridge-lib": "^7.1.12",
49
- "node-fetch": "^3.3.2",
50
- "@homebridge/plugin-ui-utils": "^1.0.0"
47
+ "@homebridge/plugin-ui-utils": "^2.1.2"
51
48
  },
52
49
  "devDependencies": {
53
50
  "@eslint/js": "^9.39.1",
@@ -42,7 +42,12 @@ export class CyncClient {
42
42
  private switchIdToHomeId: Record<number, string> = {};
43
43
 
44
44
  // Credentials from config.json, used to drive 2FA bootstrap.
45
- private readonly loginConfig: { email: string; password: string; twoFactor?: string };
45
+ //
46
+ // Canonical keys (must match platform + config):
47
+ // - username: login identifier (email address used in Cync app)
48
+ // - password: account password
49
+ // - twoFactor: 6-digit OTP, optional; when present we complete 2FA on restart.
50
+ private readonly loginConfig: { username: string; password: string; twoFactor?: string };
46
51
 
47
52
  // Optional LAN update hook for the platform
48
53
  private lanUpdateHandler: ((update: unknown) => void) | null = null;
@@ -70,7 +75,7 @@ export class CyncClient {
70
75
  constructor(
71
76
  configClient: ConfigClient,
72
77
  tcpClient: TcpClient,
73
- loginConfig: { email: string; password: string; twoFactor?: string },
78
+ loginConfig: { username: string; password: string; twoFactor?: string },
74
79
  storagePath: string,
75
80
  logger?: CyncLogger,
76
81
  ) {
@@ -80,7 +85,18 @@ export class CyncClient {
80
85
 
81
86
  this.loginConfig = loginConfig;
82
87
  this.tokenStore = new CyncTokenStore(storagePath);
88
+
89
+ // One-time sanity log so we can see exactly what was passed in from platform/config.
90
+ this.log.debug(
91
+ 'CyncClient: constructed with loginConfig=%o',
92
+ {
93
+ username: loginConfig.username,
94
+ hasPassword: !!loginConfig.password,
95
+ twoFactor: loginConfig.twoFactor,
96
+ },
97
+ );
83
98
  }
99
+
84
100
  // ### 🧩 LAN Login Code Builder
85
101
  private buildLanLoginCode(authorize: string, userId: number): Uint8Array {
86
102
  const authorizeBytes = Buffer.from(authorize, 'ascii');
@@ -133,17 +149,20 @@ export class CyncClient {
133
149
  }
134
150
 
135
151
  // 2) No stored token – run 2FA bootstrap
136
- const { email, password, twoFactor } = this.loginConfig;
152
+ const { username, password, twoFactor } = this.loginConfig;
137
153
 
138
- if (!email || !password) {
139
- this.log.error('CyncClient: email and password are required to obtain a new token.');
154
+ if (!username || !password) {
155
+ this.log.error('CyncClient: username and password are required to obtain a new token.');
140
156
  return false;
141
157
  }
142
158
 
143
- if (!twoFactor || String(twoFactor).trim() === '') {
159
+ const trimmedCode = typeof twoFactor === 'string' ? twoFactor.trim() : '';
160
+ const hasTwoFactor = trimmedCode.length > 0;
161
+
162
+ if (!hasTwoFactor) {
144
163
  // No 2FA code – request one
145
- this.log.info('Cync: starting 2FA handshake for %s', email);
146
- await this.requestTwoFactorCode(email);
164
+ this.log.info('Cync: starting 2FA handshake for %s', username);
165
+ await this.requestTwoFactorCode(username);
147
166
  this.log.info(
148
167
  'Cync: 2FA code sent to your email. Enter the code as "twoFactor" in the plugin config and restart Homebridge to complete login.',
149
168
  );
@@ -151,11 +170,11 @@ export class CyncClient {
151
170
  }
152
171
 
153
172
  // We have a 2FA code – complete login and persist token
154
- this.log.info('Cync: completing 2FA login for %s', email);
173
+ this.log.info('Cync: completing 2FA login for %s', username);
155
174
  const loginResult = await this.completeTwoFactorLogin(
156
- email,
175
+ username,
157
176
  password,
158
- String(twoFactor).trim(),
177
+ trimmedCode,
159
178
  );
160
179
 
161
180
  // Build LAN login code
@@ -191,25 +210,22 @@ export class CyncClient {
191
210
  this.applyAccessToken(tokenData);
192
211
 
193
212
  this.log.info('Cync login successful; userId=%s (token stored)', tokenData.userId);
194
- this.log.info(
195
- 'Cync: 2FA login complete and a token has been stored. You may now clear the "twoFactor" code from the plugin config; ' +
196
- 'it will only be needed again if the stored token expires or is removed.',
197
- );
198
213
  return true;
199
214
  }
200
215
 
201
216
 
202
217
  /**
203
- * Internal helper: request a 2FA email code using existing authenticate().
204
- */
205
- private async requestTwoFactorCode(email: string): Promise<void> {
206
- await this.authenticate(email);
218
+ * Internal helper: request a 2FA email code using existing authenticate().
219
+ * Accepts the same username value we store in loginConfig (email address for Cync).
220
+ */
221
+ private async requestTwoFactorCode(username: string): Promise<void> {
222
+ await this.authenticate(username);
207
223
  }
208
224
 
209
225
  /**
210
- * Internal helper: complete 2FA login using existing submitTwoFactor().
211
- * This converts CyncLoginSession into the richer shape we want for token storage.
212
- */
226
+ * Internal helper: complete 2FA login using existing submitTwoFactor().
227
+ * This converts CyncLoginSession into the richer shape we want for token storage.
228
+ */
213
229
  private async completeTwoFactorLogin(
214
230
  email: string,
215
231
  password: string,
@@ -222,12 +238,15 @@ export class CyncClient {
222
238
  }
223
239
  > {
224
240
  const session = await this.submitTwoFactor(email, password, code);
241
+
225
242
  // Extract authorize field from session.raw (Cync returns it)
226
243
  const raw = session.raw as Record<string, unknown>;
227
244
  const authorize = typeof raw?.authorize === 'string' ? raw.authorize : undefined;
228
245
 
229
246
  if (!authorize) {
230
- throw new Error('CyncClient: missing "authorize" field from login response; LAN login cannot be generated.');
247
+ throw new Error(
248
+ 'CyncClient: missing "authorize" field from login response; LAN login cannot be generated.',
249
+ );
231
250
  }
232
251
 
233
252
  const s = session as unknown as SessionWithPossibleTokens;
@@ -320,11 +339,11 @@ export class CyncClient {
320
339
  * in the same process, so it works across Homebridge restarts.
321
340
  */
322
341
  public async submitTwoFactor(
323
- email: string,
342
+ username: string,
324
343
  password: string,
325
344
  code: string,
326
345
  ): Promise<CyncLoginSession> {
327
- const trimmedEmail = email.trim();
346
+ const trimmedEmail = username.trim();
328
347
  const trimmedCode = code.trim();
329
348
 
330
349
  this.log.info('CyncClient: completing 2FA login for %s', trimmedEmail);
@@ -351,7 +370,6 @@ export class CyncClient {
351
370
  return session;
352
371
  }
353
372
 
354
-
355
373
  /**
356
374
  * Fetch and cache the cloud configuration (meshes/devices) for the logged-in user.
357
375
  * Also builds HA-style LAN topology mappings:
@@ -409,6 +427,26 @@ export class CyncClient {
409
427
  bulbsArray[0] ? Object.keys(bulbsArray[0] as Record<string, unknown>) : [],
410
428
  );
411
429
 
430
+ // ### 🧩 Bulb Capability Debug: log each bulb so we can classify plugs vs lights
431
+ bulbsArray.forEach((bulb, index) => {
432
+ const record = bulb as Record<string, unknown>;
433
+
434
+ this.log.debug(
435
+ 'CyncClient: bulb #%d for mesh %s → %o',
436
+ index,
437
+ meshName,
438
+ {
439
+ displayName: record.displayName,
440
+ deviceID: record.deviceID ?? record.deviceId,
441
+ deviceType: record.deviceType,
442
+ loadSelection: record.loadSelection,
443
+ defaultBrightness: record.defaultBrightness,
444
+ lightRingColor: record.lightRingColor,
445
+ raw: record,
446
+ },
447
+ );
448
+ });
449
+
412
450
  type RawDevice = Record<string, unknown>;
413
451
  const rawDevices = bulbsArray as unknown[];
414
452