This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

HTTP PUT image to 2N intercom
#1
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.

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
Reply


Messages In This Thread
HTTP PUT image to 2N intercom - by coolaew - 07.02.2023, 23:57
RE: HTTP PUT image to 2N intercom - by admin - 08.02.2023, 11:21
RE: HTTP PUT image to 2N intercom - by admin - 09.02.2023, 07:58

Forum Jump: