Fetch Frigate snapshots through Roku HTTP client

This commit is contained in:
OpenClaw
2026-04-19 00:22:00 +00:00
parent d189ec9045
commit c2c3cccd8f
2 changed files with 37 additions and 3 deletions

View File

@@ -37,7 +37,8 @@ sub loadConfig()
end if
cameras = config.cameras
m.status.text = cameras.count().toStr() + " cameras loaded, snapshot-first prototype"
m.status.text = cameras.count().toStr() + " cameras loaded, fetching snapshots..."
loadedCount = 0
for i = 0 to m.cameraNodes.count() - 1
poster = m.cameraPosters[i]
@@ -55,13 +56,25 @@ sub loadConfig()
label = label + chr(10) + "Frigate ID: " + camera.frigateCamera
end if
poster.uri = buildSnapshotUrl(config, camera)
node.text = label
snapshotUrl = buildSnapshotUrl(config, camera)
targetPath = "tmp:/" + camera.id + ".jpg"
result = fetchSnapshot(snapshotUrl, targetPath)
if result.success then
poster.uri = targetPath
loadedCount = loadedCount + 1
node.text = label
else
poster.uri = ""
node.text = label + chr(10) + "Snapshot failed (" + result.code.toStr() + ")"
end if
else
poster.uri = ""
node.text = "Empty slot"
end if
end for
m.status.text = loadedCount.toStr() + " of " + cameras.count().toStr() + " snapshots loaded"
end sub
function buildSnapshotUrl(config as Object, camera as Object) as String
@@ -88,3 +101,24 @@ function buildSnapshotUrl(config as Object, camera as Object) as String
return baseUrl + path
end function
function fetchSnapshot(url as String, filePath as String) as Object
result = {
success: false
code: 0
}
if url = "" then
return result
end if
transfer = CreateObject("roUrlTransfer")
transfer.SetCertificatesFile("common:/certs/ca-bundle.crt")
transfer.InitClientCertificates()
transfer.SetUrl(url)
result.success = transfer.GetToFile(filePath)
result.code = transfer.GetResponseCode()
return result
end function