Add snapshot-first Frigate camera wall

This commit is contained in:
OpenClaw
2026-04-18 23:36:00 +00:00
parent 0f6b700ed2
commit 16464bc938
6 changed files with 87 additions and 18 deletions

View File

@@ -2,6 +2,12 @@ sub init()
m.top.setFocus(true)
m.backend = m.top.findNode("backend")
m.status = m.top.findNode("status")
m.cameraPosters = [
m.top.findNode("poster1"),
m.top.findNode("poster2"),
m.top.findNode("poster3"),
m.top.findNode("poster4")
]
m.cameraNodes = [
m.top.findNode("cam1"),
m.top.findNode("cam2"),
@@ -31,9 +37,10 @@ sub loadConfig()
end if
cameras = config.cameras
m.status.text = cameras.count().toStr() + " cameras loaded from static config"
m.status.text = cameras.count().toStr() + " cameras loaded, snapshot-first prototype"
for i = 0 to m.cameraNodes.count() - 1
poster = m.cameraPosters[i]
node = m.cameraNodes[i]
if i < cameras.count() then
@@ -48,9 +55,36 @@ sub loadConfig()
label = label + chr(10) + "Frigate ID: " + camera.frigateCamera
end if
poster.uri = buildSnapshotUrl(config, camera)
node.text = label
else
poster.uri = ""
node.text = "Empty slot"
end if
end for
end sub
function buildSnapshotUrl(config as Object, camera as Object) as String
if not config.doesExist("backend") or not config.backend.doesExist("baseUrl") then
return ""
end if
baseUrl = config.backend.baseUrl
path = ""
if camera.doesExist("snapshotPath") then
path = camera.snapshotPath
else if camera.doesExist("frigateCamera") then
path = "/api/" + camera.frigateCamera + "/latest.jpg"
else
return ""
end if
if right(baseUrl, 1) = "/" and left(path, 1) = "/" then
return left(baseUrl, len(baseUrl) - 1) + path
else if right(baseUrl, 1) <> "/" and left(path, 1) <> "/" then
return baseUrl + "/" + path
end if
return baseUrl + path
end function

View File

@@ -36,35 +36,59 @@
text="Loading camera config..."
font="font:MediumSystemFont"
color="0x8B949EFF" />
<Label
id="cam1"
<Poster
id="poster1"
translation="[80, 360]"
width="760"
height="120"
height="300"
loadDisplayMode="scaleToFit" />
<Label
id="cam1"
translation="[80, 675]"
width="760"
height="70"
text="Cam slot 1"
font="font:MediumSystemFont"
color="0xFFFFFFFF" />
<Label
id="cam2"
<Poster
id="poster2"
translation="[980, 360]"
width="760"
height="120"
height="300"
loadDisplayMode="scaleToFit" />
<Label
id="cam2"
translation="[980, 675]"
width="760"
height="70"
text="Cam slot 2"
font="font:MediumSystemFont"
color="0xFFFFFFFF" />
<Poster
id="poster3"
translation="[80, 760]"
width="760"
height="300"
loadDisplayMode="scaleToFit" />
<Label
id="cam3"
translation="[80, 580]"
translation="[80, 1015]"
width="760"
height="120"
height="50"
text="Cam slot 3"
font="font:MediumSystemFont"
color="0xFFFFFFFF" />
<Poster
id="poster4"
translation="[980, 760]"
width="760"
height="300"
loadDisplayMode="scaleToFit" />
<Label
id="cam4"
translation="[980, 580]"
translation="[980, 1015]"
width="760"
height="120"
height="50"
text="Cam slot 4"
font="font:MediumSystemFont"
color="0xFFFFFFFF" />