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(s) server as REST api?
#1
Hello, this seems very obvious but I can't seem to find any information on this. I see the setting where I can enable the http and https service and I have enabled them.
Now I have some Shelly Sensors (in the same network as the LM) that I can configure to send a GET request to a URL when certain tresholds are exceeded.

I thought this together with the http service would allow me to set an object in the LM via URL. But I can't find anywhere how the HTTP server is supposed to work.

Is this even possible?
Reply
#2
See this: https://openrb.com/docs/remote-new.htm
Reply
#3
(03.02.2021, 10:31)admin Wrote: See this: https://openrb.com/docs/remote-new.htm

thank you, this works!
Reply
#4
Well, it seemed like it worked when I tested it from the browser. But apparently the browser used the cookie to authenticate.
The sensors are not able to access the http endpoint. Including the username:password doesn't work. Since the http port is not accessible out of my network, is there some way to turn authentication off for http?

If I use this url in an incognito tab in chrome:
http://username:password@192.168.0.10/sc.../3&value=0
I also get an authentication popup.
Reply
#5
Password cannot be disabled. Are you using "remote" username for this?
Reply
#6
That's a shame.
I figured out the sensors are doing something wrong and are locking the login due to 5 failed logon attempts (even though I set the user:password correctly in the url). I think I'll open an issue with the manufacturer and config them to go via IFTTT atm.
Reply
#7
There's a solution with .lp file that will work without login/password, I'll post an example later.
Reply
#8
Example for writing to group addresses without password.
You have to enable FTP server in System Config, connect via FTP by using apps username and upload write.lp file into public directory.
write.lp file contents:
Code:
<?
require('apps')
addr = getvar('addr') or ''
value = getvar('value') or ''
value = json.pdecode(value)
if type(value) ~= nil then
  grp.write(addr, value)
end

Example URLs:
http://LM_IP/public/write.lp?addr=1/1/1&value=1 - write 1/ON to 1/1/1
http://LM_IP/public/write.lp?addr=32/1/1&value=123 - write 123 to 32/1/1
Reply
#9
(08.02.2021, 07:20)admin Wrote: Example for writing to group addresses without password.
You have to enable FTP server in System Config, connect via FTP by using apps username and upload write.lp file into public directory.
write.lp file contents:
Code:
<?
require('apps')
addr = getvar('addr') or ''
value = getvar('value') or ''
value = json.pdecode(value)
if type(value) ~= nil then
  grp.write(addr, value)
end

Example URLs:
http://LM_IP/public/write.lp?addr=1/1/1&value=1 - write 1/ON to 1/1/1
http://LM_IP/public/write.lp?addr=32/1/1&value=123 - write 123 to 32/1/1

Hi,
Is it possible to do the same for read and return the result ?
Reply
#10
http://LM_IP/public/read.lp?addr=1/1/1
Code:
<?
require('apps')
addr = getvar('addr') or ''
value = grp.getvalue(addr)
if type(value) == 'table' then
  value = json.encode(value)
end
print(value)
Reply


Forum Jump: