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

HTTP in HC3 scene


Question

Posted

Hello,
can anyone please advise me? I need to send the command "http://192.168.10.88:8765/?doorbell=show" to the scene in lua in HC3, just like I would type it into web browsers and enter.

I write like this, but it doesn't work for me, resp. does not overwrite "? doorbell = show"

 

Please login or register to see this code.

 

when I sent from fibaro, I get an answer:

 

Hello, World

Header
content-length : 4 remote-addr : 192.168.10.6 http-client-ip : 192.168.10.6 host : 192.168.10.88:8765 content-type : application/json cache-control : no-cache accept : application/json user-agent : Boost.Beast/306
----
method = GET
uri = /
Params
NanoHttpd.QUERY_STRING : null

 

when I sent from web browser, I get an answer:

 

Hello, World
Header
referer : http://192.168.10.88:8765/?doorbell remote-addr : 192.168.10.50 http-client-ip : 192.168.10.50 accept-language : cs-CZ,cs;q=0.9,en;q=0.8,sk;q=0.7 host : 192.168.10.88:8765 upgrade-insecure-requests : 1 connection : keep-alive accept-encoding : gzip, deflate user-agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 accept : text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
----
method = GET
uri = /
Params
doorbell : show
NanoHttpd.QUERY_STRING : doorbell=show

 

 

Can anyone please help me and fix lua in the scene?

Thank you

 

 

11 answers to this question

Recommended Posts

  • 0
Posted

You asking json instead of expected (as I can see) xml

and more than you pass json in the body in GET method it’s really LoL ;) 

  • 0
  • Inquirer
  • Posted

    @10dercan you please advise me how it should be spelled correctly.
    I copied the code from another manual, but you can see that it is wrong.
    Thank you

    • 0
    Posted

    Hi @michal_pu

     

    I think with this example, you will get started

     

     

     

    • 0
  • Inquirer
  • Posted

    Hi @SmartHomeEddy

     

    thank you for the sent example, but i don't know how to use it in the scene. If it didn't bother you much, could you help me?

    • 0
    Posted

    IMHO

     

    remove 

    Please login or register to see this code.

    also probably remove 

    Please login or register to see this code.

    • 0
  • Inquirer
  • Posted

    removed, according to the instructions. Actual code:

     

    Please login or register to see this code.

     

    Not working yet.

     

    Fibaro returns the answer:

     

    Hello, World
    Header
    content-length : 0 remote-addr : 192.168.10.6 http-client-ip : 192.168.10.6 host : 192.168.10.88:8765 cache-control : no-cache user-agent : Boost.Beast/306
    ----
    method = GET
    uri = /
    Params
    NanoHttpd.QUERY_STRING : null

     

    web browser, returns the answer:

     

    Hello, World
    Header
    referer : http://192.168.10.88:8765/?doorbell remote-addr : 192.168.10.50 http-client-ip : 192.168.10.50 accept-language : cs-CZ,cs;q=0.9,en;q=0.8,sk;q=0.7 host : 192.168.10.88:8765 upgrade-insecure-requests : 1 connection : keep-alive accept-encoding : gzip, deflate user-agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 accept : text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
    ----
    method = GET
    uri = /
    Params
    doorbell : show
    NanoHttpd.QUERY_STRING : doorbell=show

     

     

     

    • 0
  • Inquirer
  • Posted

    I am sorry to bother you. @10der@SmartHomeEddy Please do you have a working solution?

    • 0
    Posted
    On 2/12/2022 at 9:11 PM, michal_pu said:

    I am sorry to bother you. @10der@SmartHomeEddy Please do you have a working solution?

    Hello.

    I am sorry to bother you.

    i faced a similar problem.
    Did you get a decision?
    here is my code.

    --[[
    %% properties
    45 value
    %% events
    %% globals
    --]]
    local sensor1 = 45
    local temp1
        temp1=fibaro.getValue(sensor1, "value")
     
    local url = 'http://192.168.23.211/awp/MyHome/set_1.html?%22DB_WEB%22.temp_1=11.1'
    --url=url..temp1
    local headers = {
            ["Accept"] = "application/json",
            ["Content-Type"] = 'application/json',
            ["Cache-Control"] = "no-cache"
        }
    local selfhttp = net.HTTPClient({timeout=2000})
     
    selfhttp:request(url, {
        options={
            method = 'post',
            data = json.encode(body),
            headers = headers,
        },
        success = function(response) 
                print(response.status)
                print(response.data)
        end,
        error = function(message)
                print("error:", message)
        end
    })

    I transfer data to Siemens PLC
    Here is the answer

    [14.02.2022] [22:22:27] [DEBUG] [SCENE70]: My Title Outdoor temperature 0.4503021
    Bedroom temperature 20.7

     

    I receive data from plc
    no database entry plc

    • 0
  • Inquirer
  • Posted

    @Dimshem I tried this procedure but it also doesn't work. The result is still the same

    • 0
    Posted

    encode query params please

    it too different with QA

    • 0
    Posted (edited)
    I don't understand your question. 
    Please state differently.
    My code is written in scene. 
    Is it possible to avoid QA? 
    Sorry for my english, i use google translator.
     
     
     
     
    volume_up
     
    183 / 5 000
     

    Результаты перевода

    I don't understand your question. please state differently. please. my code is written in scene. Is it possible to avoid QA? sorry for my english, i use google translator.
    Edited by Dimshem
    I made a mistake

    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...