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 Request HS zu w4k
#1
Hello everyone

I would like to retrieve or write the internal address from a home server via http.
Read http and write to virtual group address

read
https://192.168.2.113/endpoints/call?key...XX&pw=XXXX

Write
https://192.168.2.113/endpoints/call?key...XX&pw=XXXX


maybe someone can help me?
Reply
#2
Use this. The result / error will be visible in the Logs tab.
Code:
http = require('socket.http')
url = 'https://192.168.2.113/endpoints/call?key=CO@100_0_1&method=get&user=XXXX&pw=XXXX'
res, err = http.request(url)
log(res, err)
Reply
#3
thanks works,
then I should actually get this value on the bus

http = require('socket.http')
url = 'https://192.168.2.113/endpoints/call?key=CO@100_0_1&method=get&user=xxx&pw=xxx'
res, err = http.request(url)
log(res, err)

value = data
grp.checkwrite('32/1/2', value)
Reply
#4
Code:
grp.checkwrite('32/1/2', res)
Reply
#5
no sends 0
Reply
#6
What do you get in Logs?
Reply
#7
test 15.05.2023 10:52:17
* arg: 1
  * string: {"request": {"method": "get", "key": "CO@100_0_1"}, "code": 0, "type": "call", "data": {"value": 22.0}}
* arg: 2
  * number: 200
Reply
#8
Code:
http = require('socket.http')
json = require('json')

url = 'https://192.168.2.113/endpoints/call?key=CO@100_0_1&method=get&user=XXXX&pw=XXXX'
res, err = http.request(url)

res = json.pdecode(res)
grp.checkwrite('32/1/2', res.data.value)
Reply
#9
works, thanks. to send do I have to turn the sript around?
Reply
#10
Use an event script for writing:
Code:
http = require('socket.http')
value = event.getvalue()

url = 'https://192.168.2.113/endpoints/call?key=CO@100_0_1&method=set&value=' .. value .. '&user=XXXX&pw=XXXX'
res, err = http.request(url)
log(res, err)

log() call is just for debugging, remove it if script is working correctly.
Reply
#11
Thanks for the support
Reply


Forum Jump: