@switchbot/homebridge-switchbot 5.1.0-beta.5 → 5.1.0-beta.7

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.
@@ -11,10 +11,29 @@
11
11
  <body>
12
12
 
13
13
  <h1>🤖 SwitchBot Configuration</h1>
14
- <div style="margin-bottom: 12px;">
15
- <button id="legacyViewBtn" onclick="enableLegacyView()" style="font-size: 12px; padding: 4px 10px;">Legacy View</button>
16
- <button id="dynamicViewBtn" onclick="disableLegacyView()" style="font-size: 12px; padding: 4px 10px; display: none;">Dynamic View</button>
14
+
15
+ <!-- ...existing code... -->
16
+
17
+ <!-- Centered legacy view button at the bottom -->
18
+ <div class="centered-toggle-btn">
19
+ <button id="legacyViewBtn">Legacy View</button>
20
+ <button id="dynamicViewBtn" style="display: none;">Dynamic View</button>
17
21
  </div>
22
+ <style>
23
+ .centered-toggle-btn {
24
+ display: flex;
25
+ flex-direction: row;
26
+ justify-content: center;
27
+ align-items: center;
28
+ margin-top: 32px;
29
+ margin-bottom: 12px;
30
+ gap: 12px;
31
+ }
32
+ #legacyViewBtn, #dynamicViewBtn {
33
+ font-size: 12px;
34
+ padding: 4px 10px;
35
+ }
36
+ </style>
18
37
 
19
38
  <div id="dynamicUiContainer">
20
39
 
@@ -243,7 +262,7 @@
243
262
  </div>
244
263
  </div>
245
264
 
246
- <script type="module" src="js/app.js?v=ca5ec0b0"></script>
265
+ <script type="module" src="js/app.js?v=c130b117"></script>
247
266
  <script type="module" src="js/advanced-settings.js?v=031779bb"></script>
248
267
  <script type="module" src="js/legacy-view.js"></script>
249
268
  </body>
@@ -3808,6 +3808,26 @@ async function saveCredentials2() {
3808
3808
  // src/homebridge-ui/public/js/app.ts
3809
3809
  init_devices();
3810
3810
  init_discovery();
3811
+ async function ensureSwitchBotConfigBlock() {
3812
+ try {
3813
+ if (typeof homebridge.getPluginConfig !== "function" || typeof homebridge.updatePluginConfig !== "function") {
3814
+ return;
3815
+ }
3816
+ let configArr = await homebridge.getPluginConfig();
3817
+ if (!Array.isArray(configArr)) {
3818
+ configArr = [];
3819
+ }
3820
+ const idx = configArr.findIndex((c) => (c.platform || c.name || "").toLowerCase().includes("switchbot"));
3821
+ if (idx === -1) {
3822
+ configArr.push({ platform: "SwitchBot" });
3823
+ await homebridge.updatePluginConfig(configArr);
3824
+ if (typeof homebridge.savePluginConfig === "function") {
3825
+ await homebridge.savePluginConfig();
3826
+ }
3827
+ }
3828
+ } catch (_e) {
3829
+ }
3830
+ }
3811
3831
  window.loadCredentialStatus = loadCredentialStatus;
3812
3832
  window.saveCredentials = saveCredentials2;
3813
3833
  window.discoverDevices = discoverDevices2;
@@ -3822,6 +3842,7 @@ async function checkV4Config() {
3822
3842
  }
3823
3843
  }
3824
3844
  async function init() {
3845
+ await ensureSwitchBotConfigBlock();
3825
3846
  await checkV4Config();
3826
3847
  await loadCredentialStatus();
3827
3848
  await initializeDiscoverySettings();