Jump to content

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


  • 0

Errors when a HC2 scene starts a scene in another HC2


Question

Posted

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

  • 0
Posted (edited)

Please check if your Authorization is correct and the user has permissions to run that scene.

in addition I am using these headers and it works just fine

headers={ ["Content-Type"]="application/json;charset=UTF-8",
                                    ["Accept"]="application/json",
                                    ["Authorization"]="Basic vvbnjjknm....."}},
Edited by cag014
  • 0
  • Inquirer
  • Posted

    Hello cag014,

    thank you for your answer.

     

    Authorization is correct, user has permission to run that scene,

    so I added     ;charset=...

    and    ["Accept"]=...

    but nothing changed. (data is received!)

     

    Your sending scene doesn't write something like this ?

    [DEBUG] 14:32:07: 2022-02-08 14:32:07.725228 [ debug] error reading from socket: End of file
    [DEBUG] 14:32:07:
    [DEBUG] 14:32:07: Err: End of file

     

    or when   ['Connection'] = "Keep-Alive"   is added  like this ?

    [DEBUG] 14:36:26: 2022-02-08 14:36:26.459030 [ debug] Detected chunk with zero size, terminating connection
    [DEBUG] 14:36:26:

     

    Is in your receiving scene a command to 'answer' something for the sending scene to have some 'data' to read ?

     

    Thanks!

    • 0
  • Inquirer
  • Posted

    Hello cag014,

     

    one more question:

    there is no need of   ['Content-Length']=  ?

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...