I like to use the LUA script to go to a url (webcam) and save the jpg at that page to a file.
How can I access Web URL's in LUA and than save it ?
Get web-page and save jpg
Moderator: leecollings
-
- Posts: 272
- Joined: Sunday 11 May 2014 11:09
- Target OS: Windows
- Domoticz version: 2023.1+
- Location: NL
- Contact:
Re: Get web-page and save jpg
Most likely you cam has an url to get a snapshot.
in my case this could be http://ip:port/snapshot.jpg (foscam)
but if you add them to Domoticz, you can use domoticz to get the picture
What i use for sending picture on doorbel to telegram :
I use functions for easy reusing codeparts anywhere, Hope you can use some part of it for your purpose
in my case this could be http://ip:port/snapshot.jpg (foscam)
but if you add them to Domoticz, you can use domoticz to get the picture

What i use for sending picture on doorbel to telegram :
Code: Select all
function os.capture(cmd, raw) -- os.command uitvoeren en resultaat daarvan lezen in string
if (dbug == true) then print("Os.Capture") end
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
if raw then return s end
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
return s
end
Code: Select all
function GetCam(idx,naam,save)
if (dbug == true) then print("GetCam") end
local Cam = 'idx='..idx..'" -OutFile "cam/'..naam..'.jpg"'
commando = 'powershell Invoke-WebRequest -Uri "http://IP:Port/camsnapshot.jpg?'..Cam
os.execute(commando)
if (save) then
Cam = 'idx='..idx..'" -OutFile "cam/'..naam..now..'.jpg"'
commando = 'powershell Invoke-WebRequest -Uri "http://IP:Port/camsnapshot.jpg?'..Cam
os.execute(commando)
SendText('Beeld opgeslagen '..naam..now)
end
Code: Select all
function SendCam(naam)
if (dbug == true) then print("SendCam") end
commando = 'curl -s https://api.telegram.org/'..apikey..'/sendPhoto -F chat_id='..chat_id..' -F photo=@cam/'..naam..'.jpg'
result = os.capture(commando)
if (not(string.find(result, '"ok"'))) then print(result) end
end
Code: Select all
if (string.find(UtTekst, "CAM1")) then
if (string.find(UtTekst, "SAVE")) then save=true else save=false end
GetCam("1","garage",save)
SendCam("garage")
Gedaan = "ok"
I use functions for easy reusing codeparts anywhere, Hope you can use some part of it for your purpose
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
Who is online
Users browsing this forum: No registered users and 1 guest