Welcome to Smart Home Forum by FIBARO
Dear Guest,
as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.
As a member you can:
- Start new topics and reply to others
- Follow topics and users to get email updates
- Get your own profile page and make new friends
- Send personal messages
- ... and learn a lot about our system!
Regards,
Smart Home Forum by FIBARO Team

Question
muc 1
Hello,
I want to start a HC2 scene from another HC2, but something is going wrong, I've no idea what.
Perhaps a missing parameter?
Who can help?
1. Try:
dat= json.encode({args={16,18,19,22}})
datLen= tostring(#dat)
print(dat, datLen)
http= net.HTTPClient()
http:request("http://192.168.2.38:80/api/scenes/218/action/start",
{ options= { headers= { ['Authorization'] = "Basic abc...xyz=",
['Content-Type'] = "application/json",
['Connection']= "close",
},
data= dat,
method= 'POST',
timeout= 5000
},
success= function(resp)
print("resp.status:", resp.status, "C-Len:", resp.headers["Content-Length"])
end,
error= function(err) print("Err:", err) end
})
Result:
[DEBUG] 22:49:43: {"args":[16,18,19,22]} 22
[DEBUG] 22:49:43: 2022-02-06 22:49:43.325015 [ debug] error reading from socket: End of file
[DEBUG] 22:49:43:
[DEBUG] 22:49:43: Err: End of file
Great surprise: data are sent !
- - -
with ['Connection']= "Keep-Alive" instead of ..."close":
[DEBUG] 00:51:02: {"args":[16,18,19,22]} 22
[DEBUG] 00:51:05: 2022-02-07 00:51:05.112165 [ debug] Detected chunk with zero size, terminating connection
[DEBUG] 00:51:05:
[DEBUG] 00:51:05: resp.status: 200 C-Len: nil
print(json.encode(resp)) shows:
[DEBUG] 00:51:05: {"data":"","status":200,"headers":{"Cache-Control":"no-cache, no-
store","Transfer-Encoding":"chunked","Server":"nginx\/1.8.0","Content-Type":"application\/json;charset=UTF-8",
"Date":"Sun, 06 Feb 2022 23:51:05 GMT","Connection":"keep-alive"}
data are sent here too!
-----------------------------
2. Try with added line: ['Content-Length'] = datLen,
Result:
[DEBUG] 22:54:09: {"args":[16,18,19,22]} 22
[DEBUG] 22:54:09: resp.status: 400 C-Len: 172
no data sent
with ['Connection']= "Keep-Alive" instead of ..."close" also no data sent
-----------------------------
Thanks in advance!
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.