From 616dc8287342cb09d74e189550ad87edf43a2351 Mon Sep 17 00:00:00 2001 From: 1bobby-git <66291955+1bobby-git@users.noreply.github.com> Date: Tue, 10 Nov 2026 15:37:48 +0900 Subject: [PATCH 1/3] fix(bridge): skip detail discovery for devices already complete after restart Detail discovery attempts reset on every browser context start, so each Bridge restart re-opened a SmartThings page for every device (~319 visits for 239 devices), keeping Bridge at 30-40% CPU for about three hours. Controls are restored from the persisted inventory, so devices whose detail controls are already complete no longer need a visit. Camera image devices and incomplete devices are still inspected as before. Co-Authored-By: Claude Opus 5.5 --- bridge/src/browser/device-detail-discovery.ts | 7 ++- .../browser/device-detail-discovery.test.ts | 49 +++++++++++++++---- 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/bridge/src/browser/device-detail-discovery.ts b/bridge/src/browser/device-detail-discovery.ts index 1a982777..d6874ddf 100644 --- a/bridge/src/browser/device-detail-discovery.ts +++ b/bridge/src/browser/device-detail-discovery.ts @@ -106,8 +106,11 @@ export class DeviceDetailDiscovery { #needsInspection(device: BridgeDevice): boolean { const attempts = this.#attempts.get(device.id) ?? 0; if (attempts >= this.#maxAttempts) return false; - if (attempts === 0) return true; - return !discoveryComplete(device) || isCameraImageDevice(device); + // Controls persist across Bridge restarts, so a device whose detail + // controls are already complete needs no page visit. Re-inspecting every + // device on each restart kept Chromium busy for hours. + if (isCameraImageDevice(device)) return true; + return !discoveryComplete(device); } } diff --git a/bridge/tests/browser/device-detail-discovery.test.ts b/bridge/tests/browser/device-detail-discovery.test.ts index 79c511f2..4eff31de 100644 --- a/bridge/tests/browser/device-detail-discovery.test.ts +++ b/bridge/tests/browser/device-detail-discovery.test.ts @@ -38,7 +38,7 @@ describe("DeviceDetailDiscovery", () => { }); }); - test("inspects devices that already have actionable detail controls once per session", async () => { + test("skips devices whose detail controls are already complete, such as after a restart", async () => { const inspectDeviceDetails = vi.fn(async () => undefined); const discovery = new DeviceDetailDiscovery({ inventory: () => actionableControlInventory(), @@ -46,15 +46,22 @@ describe("DeviceDetailDiscovery", () => { canInspect: () => true }); - expect(await discovery.runOne()).toBe("inspected"); expect(await discovery.runOne()).toBe("idle"); - expect(inspectDeviceDetails).toHaveBeenCalledTimes(1); - expect(inspectDeviceDetails).toHaveBeenCalledWith({ - deviceName: "거실창문센서", - locationId: "loc_001", - locationNames: { loc_001: "Home" }, - roomName: "거실" + discovery.reset(); + expect(await discovery.runOne()).toBe("idle"); + expect(inspectDeviceDetails).not.toHaveBeenCalled(); + }); + + test("still inspects camera image devices whose detail controls are complete", async () => { + const inspectDeviceDetails = vi.fn(async () => undefined); + const discovery = new DeviceDetailDiscovery({ + inventory: () => completeCameraInventory(), + inspector: { inspectDeviceDetails }, + canInspect: () => true }); + + expect(await discovery.runOne()).toBe("inspected"); + expect(inspectDeviceDetails).toHaveBeenCalledTimes(1); }); test("does not treat a refresh-only control as completed discovery", async () => { @@ -99,8 +106,8 @@ describe("DeviceDetailDiscovery", () => { canInspect: () => true }); - expect(await discovery.runOne()).toBe("inspected"); expect(await discovery.runOne()).toBe("idle"); + expect(inspectDeviceDetails).not.toHaveBeenCalled(); }); test("prioritizes refresh-worthy value-only devices over generic undiscovered devices", async () => { @@ -187,7 +194,7 @@ describe("DeviceDetailDiscovery", () => { test("enforces max attempts for the per-session detail sweep", async () => { const inspectDeviceDetails = vi.fn(async () => undefined); const discovery = new DeviceDetailDiscovery({ - inventory: () => actionableControlInventory(), + inventory: () => undiscoveredOnlyInventory(), inspector: { inspectDeviceDetails }, canInspect: () => true, maxAttempts: 1 @@ -469,6 +476,28 @@ function actionableControlInventory(): BridgeInventory { }; } +function completeCameraInventory(): BridgeInventory { + const inventory = cameraInventory(); + return { + ...inventory, + devices: inventory.devices.map((device) => ({ + ...device, + controls: [ + ...(device.controls ?? []), + { + id: "camera_power", + kind: "toggle" as const, + label: "Power", + component: "main", + capability: "switch", + attribute: "switch", + command: "on" + } + ] + })) + }; +} + function undiscoveredOnlyInventory(): BridgeInventory { return { ...inventory(), From 3e53cecbb3b5d353660c268102d078c7e6f4ed55 Mon Sep 17 00:00:00 2001 From: 1bobby-git <66291955+1bobby-git@users.noreply.github.com> Date: Tue, 10 Nov 2026 15:46:39 +0900 Subject: [PATCH 2/3] fix(bridge): remember exhausted detail discovery across restarts Devices that stay incomplete after maxAttempts visits were visited twice again on every Bridge restart (80 devices in the 2026-11-10 measurement). Record them in /data/detail-discovery.json (device id, sha256 of the name, time) and skip them for seven days or until the name changes. Camera image devices are never recorded, and preempted visits do not count. A missing or corrupt file only means devices are visited again. Co-Authored-By: Claude Opus 5.5 --- bridge/src/browser/device-detail-discovery.ts | 54 ++++++++++- bridge/src/runtime.ts | 2 + bridge/src/state/detail-discovery-store.ts | 66 +++++++++++++ .../browser/device-detail-discovery.test.ts | 97 +++++++++++++++++++ .../state/detail-discovery-store.test.ts | 60 ++++++++++++ 5 files changed, 278 insertions(+), 1 deletion(-) create mode 100644 bridge/src/state/detail-discovery-store.ts create mode 100644 bridge/tests/state/detail-discovery-store.test.ts diff --git a/bridge/src/browser/device-detail-discovery.ts b/bridge/src/browser/device-detail-discovery.ts index d6874ddf..279da15e 100644 --- a/bridge/src/browser/device-detail-discovery.ts +++ b/bridge/src/browser/device-detail-discovery.ts @@ -1,5 +1,14 @@ +import { createHash } from "node:crypto"; + +import type { + DetailDiscoveryExhaustion, + DetailDiscoveryExhaustionStore +} from "../state/detail-discovery-store.js"; import type { BridgeDevice, BridgeInventory } from "../state/device-store.js"; +/** How long an exhausted, still-incomplete device is left alone across restarts. */ +export const DETAIL_DISCOVERY_EXHAUSTED_RETRY_MS = 7 * 24 * 60 * 60 * 1_000; + interface DeviceDetailInspector { inspectDeviceDetails(input: { deviceName: string; @@ -17,6 +26,8 @@ interface DeviceDetailDiscoveryOptions { canInspect: () => boolean; resolveCameraImageUrl?: (deviceId: string) => string | undefined; maxAttempts?: number; + exhaustionStore?: DetailDiscoveryExhaustionStore; + now?: () => number; } export type DeviceDetailDiscoveryResult = @@ -36,9 +47,19 @@ export class DeviceDetailDiscovery { readonly #maxAttempts: number; #running = false; #lastFailure: DeviceDetailDiscoveryFailure | undefined; + readonly #exhausted: Map; + readonly #now: () => number; constructor(private readonly options: DeviceDetailDiscoveryOptions) { this.#maxAttempts = options.maxAttempts ?? 2; + this.#now = options.now ?? Date.now; + let loaded = new Map(); + try { + loaded = options.exhaustionStore?.load() ?? loaded; + } catch { + // A missing or unreadable ledger only means devices get visited again. + } + this.#exhausted = loaded; } reset(): void { @@ -85,6 +106,7 @@ export class DeviceDetailDiscovery { ...(cameraImageUrl ? { cameraImageUrl } : {}) }); this.#lastFailure = undefined; + this.#recordExhaustion(device); return "inspected"; } catch (error) { if (error instanceof Error && error.message === "detail_discovery_preempted") { @@ -97,6 +119,7 @@ export class DeviceDetailDiscovery { deviceId: device.id, reason: safeFailureReason(error) }; + this.#recordExhaustion(device); return "failed"; } finally { this.#running = false; @@ -110,8 +133,37 @@ export class DeviceDetailDiscovery { // controls are already complete needs no page visit. Re-inspecting every // device on each restart kept Chromium busy for hours. if (isCameraImageDevice(device)) return true; - return !discoveryComplete(device); + if (discoveryComplete(device)) return false; + return !this.#recentlyExhausted(device); } + + #recentlyExhausted(device: BridgeDevice): boolean { + const record = this.#exhausted.get(device.id); + return ( + record !== undefined && + record.nameHash === nameHash(device.name) && + this.#now() - record.exhaustedAtMs < DETAIL_DISCOVERY_EXHAUSTED_RETRY_MS + ); + } + + #recordExhaustion(device: BridgeDevice): void { + // Cameras are visited every session for their image, so they never count. + if (!this.options.exhaustionStore || isCameraImageDevice(device)) return; + if ((this.#attempts.get(device.id) ?? 0) < this.#maxAttempts) return; + this.#exhausted.set(device.id, { + nameHash: nameHash(device.name), + exhaustedAtMs: this.#now() + }); + try { + this.options.exhaustionStore.save(this.#exhausted); + } catch { + // Persisting is best effort; the in-memory ledger still applies. + } + } +} + +function nameHash(name: string): string { + return createHash("sha256").update(name).digest("hex"); } function safeFailureReason(error: unknown): string { diff --git a/bridge/src/runtime.ts b/bridge/src/runtime.ts index 676f5b57..9047f594 100644 --- a/bridge/src/runtime.ts +++ b/bridge/src/runtime.ts @@ -23,6 +23,7 @@ import { SessionMaintenanceGate } from "./browser/session-maintenance.js"; import { BrowserSupervisor } from "./browser/browser-supervisor.js"; import { SmartThingsWebUiCommandExecutor } from "./browser/command-page.js"; import { DeviceDetailDiscovery } from "./browser/device-detail-discovery.js"; +import { FileDetailDiscoveryStore } from "./state/detail-discovery-store.js"; import { AuthenticatedSmartThingsSession } from "./advanced/authenticated-session.js"; import { AdvancedInventoryAdapter } from "./advanced/inventory-adapter.js"; import { AdvancedCommandAdapter } from "./advanced/command-adapter.js"; @@ -550,6 +551,7 @@ export async function createBridgeRuntime(deps: BridgeRuntimeDependencies): Prom inventory: () => devices.snapshot(), inspector: legacyCommandExecutor, resolveCameraImageUrl: (deviceId) => cameraImages.thumbnailRequestUrl(deviceId), + exhaustionStore: new FileDetailDiscoveryStore(paths.dataDir), canInspect: () => { const report = createHealthReport(status.getSnapshot()); return ( diff --git a/bridge/src/state/detail-discovery-store.ts b/bridge/src/state/detail-discovery-store.ts new file mode 100644 index 00000000..cbd98652 --- /dev/null +++ b/bridge/src/state/detail-discovery-store.ts @@ -0,0 +1,66 @@ +import { chmodSync, readFileSync, renameSync, writeFileSync } from "node:fs"; +import { join } from "node:path"; + +export interface DetailDiscoveryExhaustion { + /** sha256 of the device name the exhausted visits used. */ + nameHash: string; + exhaustedAtMs: number; +} + +export interface DetailDiscoveryExhaustionStore { + load(): Map; + save(records: ReadonlyMap): void; +} + +const FILE_NAME = "detail-discovery.json"; + +/** + * Remembers devices whose detail visits ran out without completing their + * controls, so a Bridge restart does not reopen a page for each of them. + */ +export class FileDetailDiscoveryStore implements DetailDiscoveryExhaustionStore { + readonly #path: string; + + constructor(dataDir: string) { + this.#path = join(dataDir, FILE_NAME); + } + + load(): Map { + const records = new Map(); + let parsed: unknown; + try { + parsed = JSON.parse(readFileSync(this.#path, "utf8")); + } catch { + return records; + } + if (!isRecord(parsed) || parsed.schemaVersion !== 1 || !isRecord(parsed.exhausted)) { + return records; + } + for (const [deviceId, value] of Object.entries(parsed.exhausted)) { + if ( + isRecord(value) && + typeof value.nameHash === "string" && + typeof value.exhaustedAtMs === "number" && + Number.isFinite(value.exhaustedAtMs) + ) { + records.set(deviceId, { nameHash: value.nameHash, exhaustedAtMs: value.exhaustedAtMs }); + } + } + return records; + } + + save(records: ReadonlyMap): void { + const temp = `${this.#path}.tmp`; + writeFileSync( + temp, + JSON.stringify({ schemaVersion: 1, exhausted: Object.fromEntries(records) }), + { encoding: "utf8", mode: 0o600 } + ); + renameSync(temp, this.#path); + chmodSync(this.#path, 0o600); + } +} + +function isRecord(value: unknown): value is Record { + return typeof value === "object" && value !== null && !Array.isArray(value); +} diff --git a/bridge/tests/browser/device-detail-discovery.test.ts b/bridge/tests/browser/device-detail-discovery.test.ts index 4eff31de..65744751 100644 --- a/bridge/tests/browser/device-detail-discovery.test.ts +++ b/bridge/tests/browser/device-detail-discovery.test.ts @@ -64,6 +64,93 @@ describe("DeviceDetailDiscovery", () => { expect(inspectDeviceDetails).toHaveBeenCalledTimes(1); }); + test("does not revisit incomplete devices after a restart once their attempts are exhausted", async () => { + const store = memoryStore(); + let nowMs = 1_000; + const inspectDeviceDetails = vi.fn(async () => undefined); + const create = () => + new DeviceDetailDiscovery({ + inventory: () => undiscoveredOnlyInventory(), + inspector: { inspectDeviceDetails }, + canInspect: () => true, + exhaustionStore: store, + now: () => nowMs + }); + + const first = create(); + expect(await first.runOne()).toBe("inspected"); + expect(await first.runOne()).toBe("inspected"); + expect(await first.runOne()).toBe("idle"); + + const restarted = create(); + expect(await restarted.runOne()).toBe("idle"); + restarted.reset(); + expect(await restarted.runOne()).toBe("idle"); + expect(inspectDeviceDetails).toHaveBeenCalledTimes(2); + + nowMs += 7 * 24 * 60 * 60 * 1_000; + expect(await create().runOne()).toBe("inspected"); + }); + + test("revisits an exhausted device when its name changes", async () => { + const store = memoryStore(); + const inspectDeviceDetails = vi.fn(async () => undefined); + let current = undiscoveredOnlyInventory(); + const create = () => + new DeviceDetailDiscovery({ + inventory: () => current, + inspector: { inspectDeviceDetails }, + canInspect: () => true, + exhaustionStore: store, + now: () => 1_000 + }); + + const first = create(); + await first.runOne(); + await first.runOne(); + current = { + ...current, + devices: current.devices.map((device) => ({ ...device, name: "Renamed sensor" })) + }; + expect(await create().runOne()).toBe("inspected"); + }); + + test("does not record a preempted visit as exhausted", async () => { + const store = memoryStore(); + const inspectDeviceDetails = vi.fn(async () => { + throw new Error("detail_discovery_preempted"); + }); + const discovery = new DeviceDetailDiscovery({ + inventory: () => undiscoveredOnlyInventory(), + inspector: { inspectDeviceDetails }, + canInspect: () => true, + maxAttempts: 1, + exhaustionStore: store, + now: () => 1_000 + }); + + expect(await discovery.runOne()).toBe("blocked"); + expect(store.load().size).toBe(0); + }); + + test("keeps inspecting camera image devices after a restart", async () => { + const store = memoryStore(); + const inspectDeviceDetails = vi.fn(async () => undefined); + const create = () => + new DeviceDetailDiscovery({ + inventory: () => cameraInventory(), + inspector: { inspectDeviceDetails }, + canInspect: () => true, + exhaustionStore: store, + now: () => 1_000 + }); + + const first = create(); + await first.runOne(); + await first.runOne(); + expect(await create().runOne()).toBe("inspected"); + }); + test("does not treat a refresh-only control as completed discovery", async () => { const inspectDeviceDetails = vi.fn(async () => undefined); const discovery = new DeviceDetailDiscovery({ @@ -476,6 +563,16 @@ function actionableControlInventory(): BridgeInventory { }; } +function memoryStore() { + let records = new Map(); + return { + load: () => new Map(records), + save: (next: ReadonlyMap) => { + records = new Map(next); + } + }; +} + function completeCameraInventory(): BridgeInventory { const inventory = cameraInventory(); return { diff --git a/bridge/tests/state/detail-discovery-store.test.ts b/bridge/tests/state/detail-discovery-store.test.ts new file mode 100644 index 00000000..cdabc766 --- /dev/null +++ b/bridge/tests/state/detail-discovery-store.test.ts @@ -0,0 +1,60 @@ +import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; + +import { afterEach, describe, expect, test } from "vitest"; + +import { FileDetailDiscoveryStore } from "../../src/state/detail-discovery-store.js"; + +const roots: string[] = []; + +afterEach(() => { + for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }); +}); + +function tempRoot(): string { + const root = mkdtempSync(join(tmpdir(), "stw-detail-discovery-")); + roots.push(root); + return root; +} + +describe("FileDetailDiscoveryStore", () => { + test("keeps exhausted devices across store instances", () => { + const root = tempRoot(); + new FileDetailDiscoveryStore(root).save( + new Map([["dev_1", { nameHash: "abc", exhaustedAtMs: 1_000 }]]) + ); + + expect([...new FileDetailDiscoveryStore(root).load()]).toEqual([ + ["dev_1", { nameHash: "abc", exhaustedAtMs: 1_000 }] + ]); + }); + + test("starts empty when the file is missing or corrupt", () => { + const root = tempRoot(); + expect(new FileDetailDiscoveryStore(root).load().size).toBe(0); + writeFileSync(join(root, "detail-discovery.json"), "{not json"); + expect(new FileDetailDiscoveryStore(root).load().size).toBe(0); + }); + + test("drops malformed records", () => { + const root = tempRoot(); + writeFileSync( + join(root, "detail-discovery.json"), + JSON.stringify({ + schemaVersion: 1, + exhausted: { dev_ok: { nameHash: "x", exhaustedAtMs: 5 }, dev_bad: { nameHash: 1 } } + }) + ); + + expect([...new FileDetailDiscoveryStore(root).load().keys()]).toEqual(["dev_ok"]); + }); + + test("stores only a hash of the device name", () => { + const root = tempRoot(); + new FileDetailDiscoveryStore(root).save( + new Map([["dev_1", { nameHash: "hash-only", exhaustedAtMs: 1 }]]) + ); + expect(readFileSync(join(root, "detail-discovery.json"), "utf8")).not.toContain("거실"); + }); +}); From f2e51c37bfe7a486123b0949fea546605b55a746 Mon Sep 17 00:00:00 2001 From: 1bobby-git <66291955+1bobby-git@users.noreply.github.com> Date: Tue, 10 Nov 2026 17:22:33 +0900 Subject: [PATCH 3/3] chore(release): 1.8.75 Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 8 ++++++++ addon/smartthings_web_bridge/CHANGELOG.md | 8 ++++++++ addon/smartthings_web_bridge/config.yaml | 2 +- bridge/src/runtime.ts | 2 +- bridge/tests/runtime.test.ts | 2 +- custom_components/smartthings_web/manifest.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- protocol/version.json | 2 +- release-notes/1.8.75.md | 14 ++++++++++++++ tests/addon-config.test.ts | 12 ++++++------ tests/protocol-version-contract.test.ts | 6 +++--- 12 files changed, 47 insertions(+), 17 deletions(-) create mode 100644 release-notes/1.8.75.md diff --git a/CHANGELOG.md b/CHANGELOG.md index f5fa7a40..4a7c0e75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 1.8.75 + +- Bridge: Bridge가 시작될 때마다 상세 조회가 모든 기기의 SmartThings 페이지를 다시 열어, 시작 후 약 3시간 동안 Bridge CPU가 30~40%로 높던 문제를 수정했습니다(239대 기준 약 319회 조회). 조회가 끝나면 2~3%로 돌아왔습니다. +- Bridge: 기기 컨트롤은 저장된 인벤토리에서 복원되므로, 상세 컨트롤이 이미 완성된 기기는 다시 조회하지 않습니다. +- Bridge: 2회 조회해도 완성되지 않은 기기는 `/data/detail-discovery.json`(기기 id, 이름의 sha256, 시각)에 기록하고 재시작 후에도 7일 동안 또는 이름이 바뀔 때까지 다시 조회하지 않습니다. 카메라 이미지 기기는 지금처럼 매번 조회합니다. 파일이 없거나 손상되면 다시 조회합니다. +- 이 버전으로 처음 시작할 때는 아직 기록이 없어 미완성 기기를 한 번 더 조회합니다. 효과는 그다음 재시작부터 나타납니다. +- 이 변경은 Bridge 앱 업데이트가 필요합니다. Bridge 앱과 HACS 통합 버전은 1.8.75입니다. 통합 코드는 바뀌지 않았습니다. + ## 1.8.74 - Bridge: 30분 주기 상태 재조정 때마다 Advanced 새로고침 버튼 컨트롤이 사라지던 문제를 수정했습니다. 재조정 스냅샷이 새로고침 버튼을 다시 만든 직후, 명령 카탈로그 반영 단계가 `advanced:`로 시작하는 컨트롤을 모두 지우고 스위치 토글만 되살렸습니다. 이제 카탈로그 반영은 자기가 만드는 스위치 토글만 교체합니다. diff --git a/addon/smartthings_web_bridge/CHANGELOG.md b/addon/smartthings_web_bridge/CHANGELOG.md index de5ba4ea..e6cf6ed1 100644 --- a/addon/smartthings_web_bridge/CHANGELOG.md +++ b/addon/smartthings_web_bridge/CHANGELOG.md @@ -1,3 +1,11 @@ +## 1.8.75 + +- Bridge: Bridge가 시작될 때마다 상세 조회가 모든 기기의 SmartThings 페이지를 다시 열어, 시작 후 약 3시간 동안 Bridge CPU가 30~40%로 높던 문제를 수정했습니다(239대 기준 약 319회 조회). 조회가 끝나면 2~3%로 돌아왔습니다. +- Bridge: 기기 컨트롤은 저장된 인벤토리에서 복원되므로, 상세 컨트롤이 이미 완성된 기기는 다시 조회하지 않습니다. +- Bridge: 2회 조회해도 완성되지 않은 기기는 `/data/detail-discovery.json`(기기 id, 이름의 sha256, 시각)에 기록하고 재시작 후에도 7일 동안 또는 이름이 바뀔 때까지 다시 조회하지 않습니다. 카메라 이미지 기기는 지금처럼 매번 조회합니다. 파일이 없거나 손상되면 다시 조회합니다. +- 이 버전으로 처음 시작할 때는 아직 기록이 없어 미완성 기기를 한 번 더 조회합니다. 효과는 그다음 재시작부터 나타납니다. +- 이 변경은 Bridge 앱 업데이트가 필요합니다. Bridge 앱과 HACS 통합 버전은 1.8.75입니다. 통합 코드는 바뀌지 않았습니다. + ## 1.8.74 - Bridge: 30분 주기 상태 재조정 때마다 Advanced 새로고침 버튼 컨트롤이 사라지던 문제를 수정했습니다. 재조정 스냅샷이 새로고침 버튼을 다시 만든 직후, 명령 카탈로그 반영 단계가 `advanced:`로 시작하는 컨트롤을 모두 지우고 스위치 토글만 되살렸습니다. 이제 카탈로그 반영은 자기가 만드는 스위치 토글만 교체합니다. diff --git a/addon/smartthings_web_bridge/config.yaml b/addon/smartthings_web_bridge/config.yaml index e076c451..2a4d0215 100644 --- a/addon/smartthings_web_bridge/config.yaml +++ b/addon/smartthings_web_bridge/config.yaml @@ -1,7 +1,7 @@ name: SmartThings Web Bridge slug: smartthings_web_bridge description: Headed Chromium bridge for observing SmartThings Web traffic from Home Assistant. -version: 1.8.74 +version: 1.8.75 url: https://github.com/1bobby-git/HA-SmartThings_Web startup: services boot: auto diff --git a/bridge/src/runtime.ts b/bridge/src/runtime.ts index 9047f594..7f781021 100644 --- a/bridge/src/runtime.ts +++ b/bridge/src/runtime.ts @@ -119,7 +119,7 @@ type ObservableContext = BrowserContextLike & { newCDPSession?: (page: BrowserPageLike) => Promise; }; -const bridgeVersion = "1.8.74"; +const bridgeVersion = "1.8.75"; const SESSION_TOUCH_INTERVAL_MS = 5 * 60_000; const DETAIL_DISCOVERY_INTERVAL_MS = 15_000; const PROFILE_MAINTENANCE_REQUIRED_FILE = ".profile-maintenance-required"; diff --git a/bridge/tests/runtime.test.ts b/bridge/tests/runtime.test.ts index be9d1aaf..3bdfe82b 100644 --- a/bridge/tests/runtime.test.ts +++ b/bridge/tests/runtime.test.ts @@ -1013,7 +1013,7 @@ describe("createBridgeRuntime", () => { await runtime.browserStartup; expect(log.info.mock.calls.slice(0, 14)).toEqual([ - ["bridge_init:version:1.8.74:home_monitor_direct"], + ["bridge_init:version:1.8.75:home_monitor_direct"], ["bridge_init:data_paths"], ["bridge_init:data_paths:data_dir"], ["bridge_init:data_paths:profile_dir"], diff --git a/custom_components/smartthings_web/manifest.json b/custom_components/smartthings_web/manifest.json index 455a3a01..3f50cac2 100644 --- a/custom_components/smartthings_web/manifest.json +++ b/custom_components/smartthings_web/manifest.json @@ -10,5 +10,5 @@ "iot_class": "cloud_push", "issue_tracker": "https://github.com/1bobby-git/HA-SmartThings_Web/issues", "requirements": [], - "version": "1.8.74" + "version": "1.8.75" } diff --git a/package-lock.json b/package-lock.json index 300fe3dc..f7e2c62e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ha-smartthings-web", - "version": "1.8.74", + "version": "1.8.75", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ha-smartthings-web", - "version": "1.8.74", + "version": "1.8.75", "license": "MIT", "dependencies": { "playwright-core": "1.65.0" diff --git a/package.json b/package.json index aa5e2746..22411db5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ha-smartthings-web", - "version": "1.8.74", + "version": "1.8.75", "private": true, "type": "module", "packageManager": "npm@11.12.1", diff --git a/protocol/version.json b/protocol/version.json index 97aa4b52..b0d8c084 100644 --- a/protocol/version.json +++ b/protocol/version.json @@ -1,5 +1,5 @@ { - "bridge_version": "1.8.74", + "bridge_version": "1.8.75", "protocol_version": 6, "playwright_version": "1.65.0", "expected_chromium_version": "158.0.8127.18", diff --git a/release-notes/1.8.75.md b/release-notes/1.8.75.md new file mode 100644 index 00000000..2ebc6cfd --- /dev/null +++ b/release-notes/1.8.75.md @@ -0,0 +1,14 @@ +# 1.8.75 + +Bridge가 시작될 때마다 몇 시간 동안 CPU를 많이 쓰던 문제를 수정했습니다. + +- 원인: 상세 조회(detail discovery)가 15초마다 기기 하나씩 SmartThings 페이지를 여는데, 시도 기록이 Bridge 시작마다 초기화되어 모든 기기를 다시 열었습니다. 기기 239대 기준 약 319회, 약 3시간 동안 Bridge CPU가 30~40%였습니다. +- 상세 컨트롤이 이미 완성된 기기는 다시 조회하지 않습니다(컨트롤은 저장된 인벤토리에서 복원됩니다). +- 2회 조회해도 완성되지 않은 기기는 `/data/detail-discovery.json`에 기록하고 7일 동안 또는 이름이 바뀔 때까지 다시 조회하지 않습니다. 기기 이름은 해시로만 저장합니다. +- 카메라 이미지 기기는 지금처럼 매번 조회합니다. +- 통합 코드는 바뀌지 않았습니다. + +## 업데이트 + +1. Bridge 앱을 1.8.75로 업데이트합니다. 업데이트 중 Bridge가 다시 시작됩니다. 이 버전으로 처음 시작할 때는 미완성 기기를 한 번 더 조회하고, 그다음 재시작부터 조회가 줄어듭니다. +2. HACS 통합도 버전 정렬을 위해 1.8.75로 업데이트합니다. 통합 코드 변경은 없으므로 Home Assistant 재시작은 필요 없습니다. diff --git a/tests/addon-config.test.ts b/tests/addon-config.test.ts index 473dd83f..e7ac302f 100644 --- a/tests/addon-config.test.ts +++ b/tests/addon-config.test.ts @@ -10,22 +10,22 @@ const standaloneDockerfile = () => readText("docker/Dockerfile"); const composeConfig = () => YAML.parse(readText("docker/compose.example.yaml")) as Record; describe("Home Assistant add-on metadata", () => { - test("packages the Bridge resync control and type fix as version 1.8.74", () => { + test("packages the Bridge restart detail discovery fix as version 1.8.75", () => { const config = addonConfig(); const packageMetadata = JSON.parse(readText("package.json")) as Record; const protocolMetadata = JSON.parse(readText("protocol/version.json")) as Record; const runtime = readText("bridge/src/runtime.ts"); const changelog = readText("addon/smartthings_web_bridge/CHANGELOG.md"); - expect(config.version).toBe("1.8.74"); + expect(config.version).toBe("1.8.75"); expect(config.homeassistant_api).toBe(true); expect(config.hassio_api).toBe(true); expect(config.discovery).toEqual(["smartthings_web"]); - expect(packageMetadata.version).toBe("1.8.74"); - expect(protocolMetadata.bridge_version).toBe("1.8.74"); + expect(packageMetadata.version).toBe("1.8.75"); + expect(protocolMetadata.bridge_version).toBe("1.8.75"); expect(protocolMetadata.protocol_version).toBe(6); - expect(runtime).toContain('const bridgeVersion = "1.8.74";'); - expect(changelog).toContain("## 1.8.74"); + expect(runtime).toContain('const bridgeVersion = "1.8.75";'); + expect(changelog).toContain("## 1.8.75"); expect(changelog).toContain("## 1.8.38"); expect(changelog).toContain("## 1.8.37"); expect(changelog).toContain("## 1.8.12"); diff --git a/tests/protocol-version-contract.test.ts b/tests/protocol-version-contract.test.ts index 19441ec3..aefe81e3 100644 --- a/tests/protocol-version-contract.test.ts +++ b/tests/protocol-version-contract.test.ts @@ -12,9 +12,9 @@ import { import { bootstrapDataPaths } from "../bridge/src/security/data-paths.js"; describe("protocol version contract", () => { - test("keeps integration 1.8.74 compatible with Bridge 1.8.74 and protocol 6", () => { - const expectedBridgeVersion = "1.8.74"; - const expectedIntegrationVersion = "1.8.74"; + test("keeps integration 1.8.75 compatible with Bridge 1.8.75 and protocol 6", () => { + const expectedBridgeVersion = "1.8.75"; + const expectedIntegrationVersion = "1.8.75"; const packageJson = JSON.parse(readFileSync("package.json", "utf8")) as { version?: string }; const packageLock = JSON.parse(readFileSync("package-lock.json", "utf8")) as { version?: string;