Hello!
Using a SE spaceLYnk I'm trying to send an image to a 2N IP Verso intercom when the firealarm is activated and remove the image when the fire alarm resets.
The intercom uses HTTPS and Digest authentication.
I've got it working in postman but not from the SpaceLYnk.
I only got the DELETE part working with basic authentication.
I found some threads here about digest authentication and image handling, but I'm not experienced with coding so I was not able to put the code together from what I found to do what I need.
I have saved the image to /img/ which i created in the root of the ftp server logged in as ftp.
Here's a link to the 2N API documentation, part 5.9.2 is about sending images and clearing the display.
https://wiki.2n.com/hip/hapi/latest/en
Using a SE spaceLYnk I'm trying to send an image to a 2N IP Verso intercom when the firealarm is activated and remove the image when the fire alarm resets.
The intercom uses HTTPS and Digest authentication.
I've got it working in postman but not from the SpaceLYnk.
I only got the DELETE part working with basic authentication.
Code:
-- /img/STOP_DNE_241x320.png (I want to use this)
-- /img/fire_241x320.png (Alternate image for testing)
fire = grp.getvalue('32/1/1')
--log(fire)
if fire == true then
log('FIREALARM ACTIVE')
-- Send image to intercom
-- https://10.0.0.230/api/display/image?display=ext1
elseif fire == false then
log('No fire')
-- Delete image from intercom
-- https://10.0.0.230/api/display/image?display=ext1
local https = require("ssl.https")
local ltn12 = require("ltn12")
local response_body = {}
local request_body = ""
local res, code, response_headers, status = https.request{
url = "https://test:test@10.0.0.230/api/display/image?display=ext1",
method = "DELETE",
source = ltn12.source.string(request_body),
sink = ltn12.sink.table(response_body),
protocol = "tlsv1_2"
}.
if code == 200 then
log("Image deleted successfully!")
else
log("Error deleting image: "..code)
end
else
log('ERROR')
end
I found some threads here about digest authentication and image handling, but I'm not experienced with coding so I was not able to put the code together from what I found to do what I need.
I have saved the image to /img/ which i created in the root of the ftp server logged in as ftp.
Here's a link to the 2N API documentation, part 5.9.2 is about sending images and clearing the display.
https://wiki.2n.com/hip/hapi/latest/en