I have Alliance-Apps OpenDTU and it support cURL command. I hope that I can control this product using Shelly script. How I can send cURL command usingShelly script?
Command what I want use is:
Code
curl --user "user:pwd" http://192.168.x.x/api/limit/config --request POST --data "data={'serial':'1144xxxxxxxx', 'limit_type':1, 'limit_value':50}"
I tried use code like below with my own setups, but it not work and I don't know what I must to do, Can somebody help me how to do that?
Code
function ParseResponse(res, error_code, error_msg, ud) {
if (error_code != 0) {
print("Request error: ", error_code, error_msg);
} else {
if (res.code === 200) {
let response = JSON.parse(res.body);
print(response);
} else {
print('Request failed: ', res.code);
}
}
}
let username = 'xxxx'
let password = 'xxxxxx'
let urlToCall = 'http://' + username + ':' + password + '@192.168.x.xxx/api/limit/config'
let payload = 'data={"serial":"1144xxxxxxxx", "limit_type":1, "limit_value":100}'
Shelly.call("HTTP.POST", { url: urlToCall, body: payload, timeout: 15, ssl_ca: "*" }, ParseResponse);
Alles anzeigen