src.nth.io/

summaryrefslogtreecommitdiff
path: root/scrypted
diff options
context:
space:
mode:
authorLuke Hoersten <[email protected]>2026-06-14 19:31:21 -0500
committerLuke Hoersten <[email protected]>2026-06-14 19:31:21 -0500
commitea54684e304a17b981df9a282572de13fb965a60 (patch)
tree38349f9b6fc447b263dc2e691eda97c6d936aae1 /scrypted
parent5676c0b2d22883eed9c2faae1b3fba1679021873 (diff)
scrypted: re-discover children at start so their storage rehydrates on script reload
Diffstat (limited to 'scrypted')
-rw-r--r--scrypted/scrypted-viewport.ts20
1 files changed, 16 insertions, 4 deletions
diff --git a/scrypted/scrypted-viewport.ts b/scrypted/scrypted-viewport.ts
index e29100a..fd846ae 100644
--- a/scrypted/scrypted-viewport.ts
+++ b/scrypted/scrypted-viewport.ts
@@ -221,11 +221,23 @@ class ScryptedViewportProvider extends ScryptedDeviceBase
this.scryptedBase = raw.replace(/\/$/, "");
this.console.log(`Scrypted Viewport up. Callback URL base: ${this.scryptedBase}`);
- // Eagerly instantiate every known child so its registration + camera
- // event subscription happen at plugin load (rather than waiting for
- // some other part of Scrypted to touch the child).
+ // Re-discover every known child so Scrypted reattaches its storage
+ // to the nativeId. Without this, `new Viewport(...)` instantiates
+ // with `this.storage === undefined` and every storage-backed getter
+ // (host / cameraId / orientation / ...) throws on script reload.
+ // Then eagerly instantiate so each child's registration + camera
+ // event subscription happen at plugin load.
for (const nativeId of this.childIds) {
- try { await this.getDevice(nativeId); }
+ try {
+ await deviceManager.onDeviceDiscovered({
+ providerNativeId: this.nativeId,
+ nativeId,
+ name: nativeId, // overridden by Scrypted from its existing record
+ type: ScryptedDeviceType.Sensor,
+ interfaces: [ScryptedInterface.Settings],
+ });
+ await this.getDevice(nativeId);
+ }
catch (e) { this.console.warn(`load child ${nativeId} failed:`, (e as Error).message); }
}