homebridge-tuya-without-developer-account 1.0.8 → 1.0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.9
4
+
5
+ - Fixed the custom Homebridge settings UI so toggling Adaptive Lighting marks the config as changed and enables **Save Configuration**.
6
+ - Save now performs a final existing-auth check before blocking, so normal configuration-only changes are not prevented when a QR auth token is already saved.
7
+ - Name and AC override UI changes also mark the custom config as dirty more reliably.
8
+
3
9
  ## 1.0.8
4
10
 
5
11
  - Added optional HomeKit Adaptive Lighting support for eligible Tuya lights.
package/README.md CHANGED
@@ -250,6 +250,11 @@ HomeKit stores temperature characteristic metadata in Celsius. Do not enter Fahr
250
250
 
251
251
  ## Adaptive Lighting
252
252
 
253
+
254
+ ### v1.0.9 UI save-state fix
255
+
256
+ Version 1.0.9 fixes the custom settings UI so changing the Adaptive Lighting checkbox immediately enables **Save Configuration**. If QR authentication is already saved, the UI performs a final auth check during save and no longer blocks normal configuration-only changes.
257
+
253
258
  Version 1.0.8 adds optional HomeKit Adaptive Lighting support. Enable it in the Homebridge plugin settings with **Enable Adaptive Lighting for eligible CCT/RGBCW lights**.
254
259
 
255
260
  Adaptive Lighting is applied only to Tuya light accessories that expose both:
@@ -191,6 +191,7 @@
191
191
  let currentConfig = null;
192
192
  let pollTimer = null;
193
193
  let isAuthenticated = false;
194
+ let isDirty = false;
194
195
  let detectedDevices = [];
195
196
 
196
197
  const $ = (id) => document.getElementById(id);
@@ -269,6 +270,11 @@
269
270
  if (homebridge.enableSaveButton) homebridge.enableSaveButton();
270
271
  }
271
272
 
273
+ function markDirty() {
274
+ isDirty = true;
275
+ enableSaving();
276
+ }
277
+
272
278
  function getDeviceName(id) {
273
279
  const device = detectedDevices.find((item) => item.id === id);
274
280
  return device ? device.name : '';
@@ -417,9 +423,7 @@
417
423
  const name = getDeviceName(id) || id;
418
424
  setAcStatus(`AC override saved in plugin config for ${name}: ${minTemperature}–${maxTemperature} °C, step ${temperatureStep} °C. Click Save Configuration when ready.`, 'success');
419
425
  homebridge.toast.success('AC temperature override added to config.', 'Tuya');
420
- if (isAuthenticated) {
421
- enableSaving();
422
- }
426
+ markDirty();
423
427
  } catch (e) {
424
428
  setAcStatus(e.message || 'Failed to add AC override.', 'danger');
425
429
  }
@@ -453,9 +457,7 @@
453
457
  setAcStatus('Selected AC override was removed from the plugin config. Click Save Configuration when ready.', 'success');
454
458
  homebridge.toast.success('AC temperature override removed from config.', 'Tuya');
455
459
  }
456
- if (isAuthenticated) {
457
- enableSaving();
458
- }
460
+ markDirty();
459
461
  }
460
462
 
461
463
  async function checkAuth(showSuccessToast = false) {
@@ -600,18 +602,24 @@
600
602
  }
601
603
 
602
604
  async function saveConfig() {
603
- if (!isAuthenticated) {
604
- setStatus('Scan and approve the QR code before saving.', 'warning');
605
- return;
606
- }
607
-
608
605
  const userCode = getUserCode();
609
606
  if (!userCode) {
610
607
  setStatus('User Code is required before saving.', 'warning');
608
+ homebridge.toast.error('User Code is required before saving.', 'Tuya');
611
609
  return;
612
610
  }
613
611
 
614
612
  try {
613
+ if (!isAuthenticated) {
614
+ // Do a last auth check here. This prevents normal configuration-only changes
615
+ // such as Adaptive Lighting from being blocked when the token already exists
616
+ // but this UI session has not marked itself authenticated yet.
617
+ const auth = await homebridge.request('/auth/status', { userCode });
618
+ isAuthenticated = !!auth.authenticated;
619
+ if (!isAuthenticated) {
620
+ throw new Error('Scan and approve the QR code, or click Check Existing Auth, before saving.');
621
+ }
622
+ }
615
623
  homebridge.showSpinner();
616
624
  $('tuyaNodevSave').disabled = true;
617
625
 
@@ -649,11 +657,13 @@
649
657
 
650
658
  if (saveTimedOut && verified) {
651
659
  const message = 'Configuration appears to be saved, but Homebridge UI did not return a save confirmation. Close this settings window and restart Homebridge.';
660
+ isDirty = false;
652
661
  homebridge.toast.success(message, 'Tuya');
653
662
  setStatus(message, 'success');
654
663
  return;
655
664
  }
656
665
 
666
+ isDirty = false;
657
667
  homebridge.toast.success('Configuration saved. Restart Homebridge to load devices.', 'Tuya');
658
668
  setStatus('Configuration saved. Restart Homebridge to load devices.', 'success');
659
669
  } catch (e) {
@@ -661,7 +671,7 @@
661
671
  homebridge.toast.error(e.message || 'Failed to save configuration.', 'Tuya');
662
672
  } finally {
663
673
  homebridge.hideSpinner();
664
- if (isAuthenticated) {
674
+ if (isAuthenticated || isDirty) {
665
675
  $('tuyaNodevSave').disabled = false;
666
676
  }
667
677
  }
@@ -699,10 +709,14 @@
699
709
  $('tuyaNodevCheck').addEventListener('click', () => checkAuth(true));
700
710
  $('tuyaNodevClear').addEventListener('click', clearAuth);
701
711
  $('tuyaNodevSave').addEventListener('click', saveConfig);
702
- $('tuyaNodevName').addEventListener('input', syncConfigToUi);
712
+ $('tuyaNodevName').addEventListener('input', async () => {
713
+ await syncConfigToUi();
714
+ markDirty();
715
+ });
703
716
  $('tuyaNodevAdaptiveLighting').addEventListener('change', async () => {
704
717
  await syncConfigToUi();
705
- if (isAuthenticated) enableSaving();
718
+ markDirty();
719
+ setStatus('Adaptive Lighting setting changed. Click Save Configuration when ready.', 'info');
706
720
  });
707
721
  $('tuyaNodevUserCode').addEventListener('input', () => {
708
722
  isAuthenticated = false;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "homebridge-tuya-without-developer-account",
3
3
  "displayName": "Tuya without developer account for Homebridge",
4
- "version": "1.0.8",
4
+ "version": "1.0.9",
5
5
  "description": "Homebridge plugin for Tuya and Smart Life devices using QR cloud authentication without a Tuya IoT developer account.",
6
6
  "license": "MIT",
7
7
  "author": "Kosztyk",