diff options
| author | Luke Hoersten <[email protected]> | 2026-06-15 08:52:10 -0500 |
|---|---|---|
| committer | Luke Hoersten <[email protected]> | 2026-06-15 08:52:10 -0500 |
| commit | 9acb99ba3f23aebf48c8c82f148f6cd3441d4efa (patch) | |
| tree | 8a59500dea17f3ba4d2ca2272626cfdb6d78a2f1 | |
| parent | 9e21dafedc0eb274cf7e5a4d4c42643fce749e62 (diff) | |
scrypted: render wake/sleep as boolean toggles instead of unrendered buttons
type:"button" Settings get silently dropped by Scrypted's renderer —
they were in the model but never appeared in the UI. Switch both to
type:"boolean" so they show as toggles. The toggle acts as a one-shot
trigger: flipping it on fires the wake/sleep action and the next
getSettings() call returns value:false so it's armed again.
| -rw-r--r-- | scrypted/scrypted-viewport.ts | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/scrypted/scrypted-viewport.ts b/scrypted/scrypted-viewport.ts index 693a2a6..8473c31 100644 --- a/scrypted/scrypted-viewport.ts +++ b/scrypted/scrypted-viewport.ts @@ -190,15 +190,17 @@ class Viewport extends ScryptedDeviceBase implements Settings { group: "Actions", key: "action_wake", title: "Wake now", - description: "POST /state {wake} to the device — turns the panel on and starts streaming the bound camera. Bypasses camera-event triggers.", - type: "button", + description: "Toggle on to POST /state {wake} and start streaming the bound camera. Resets automatically after firing.", + type: "boolean", + value: false, } as any, { group: "Actions", key: "action_sleep", title: "Sleep now", - description: "POST /state {sleep} and stop the active stream.", - type: "button", + description: "Toggle on to POST /state {sleep} and stop the active stream. Resets automatically after firing.", + type: "boolean", + value: false, } as any, ]; @@ -244,6 +246,11 @@ class Viewport extends ScryptedDeviceBase implements Settings { // Manual override from the Scrypted UI. Wake also starts a // stream so the user sees the camera immediately; Sleep // tears down the live ffmpeg and POSTs sleep. + // Boolean acts as a one-shot trigger — fire on truthy then + // re-render with the toggle cleared so it's ready to fire + // again next time. + const truthy = value === true || value === "true"; + if (!truthy) return; if (!this.host) return; if (key === "action_wake") { if (!this.provider.streams.has(this.name) && |
