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

[cURL] - Help needed with Quickapp


Question

Posted

I've actually looked through every topic with the word cURL in it. And I'm not getting any further.

So I thought I'd open a topic. I would like to create a quickapp that can create the following url:

 

curl -X POST --data "{\"node\":\"achter\", \"position\":10}" --header "Content-Type: application/json" http://192.168.1.134:8000/set

 

Where "10" can be a variable to fill in, or perhaps also with a slider 1 to 100%. I would like to be able to apply this in block scenes eventually.

 

The ultimate goal is to be able to control my somfy blinds from scenes. The url already works.

I can run this on my RPI's CLI. It even works from the CMD line in windows.

 

Hopefully with your help soon also via the HC3.

20 answers to this question

Recommended Posts

  • 0
Posted
1 hour ago, ppeterr said:

I would like to be able to apply this in block scenes eventually.

?

  • 0
  • Inquirer
  • Posted
    17 minutes ago, 10der said:

    ?

     

    Happy to make you smile :)

     

     

    • 0
    Posted

    You can do it by creating QuickApp on PC only.

    Let me know if you interesting how to!?

    • 0
  • Inquirer
  • Posted
    1 hour ago, cag014 said:

    You can do it by creating QuickApp on PC only.

    Let me know if you interesting how to!?

     

     

    Thanks for checking out this thread, I'm definitely interested in a solution!

    • 0
    Posted

    Something like this? A multiLevel switch QA that can be used from scenes.

    Please login or register to see this attachment.

    • 0
  • Inquirer
  • Posted
    7 minutes ago, jgab said:

    Something like this? A multiLevel switch QA that can be used from scenes.

    Please login or register to see this attachment.

     

    This errors, but not sure what is wrong. I think this is a Http request. And it needs to be specific cURL

     

    [09.10.2021] [19:47:16] [TRACE] [QUICKAPP369]: UIEvent: {"deviceId":369,"eventType":"onChanged","elementName":"slider","values":[26]}[09.10.2021] [19:47:16] [DEBUG] [QUICKAPP369]: {"headers":{"Content-Type":"application\/json; charset=utf-8","Date":"Sat, 09 Oct 2021 17:47:16 GMT","Content-Length":"56","Server":"Python\/3.8 aiohttp\/3.7.4.post0","Connection":"close"},"status":200,"data":"{\"result\": \"fail\", \"reason\": \"unsupported request type\"}"}

    • 0
    Posted

    Try adding after 'method = "POST"' the line with 'headers = { ...'

    Please login or register to see this code.

     

    • 0
  • Inquirer
  • Posted

    @jgab  New error. nServer got itself in trouble.

     

    [10.10.2021] [04:51:51] [DEBUG] [QUICKAPP369]: {"headers":{"Server":"Python\/3.8 aiohttp\/3.7.4.post0","Date":"Sun, 10 Oct 2021 02:51:51 GMT","Content-Length":"145","Content-Type":"text\/html; charset=utf-8","Connection":"close"},"status":500,"data":"500 Internal Server Error<\/title><\/head><body>\n<h1>500 Internal Server Error<\/h1>\nServer got itself in trouble\n<\/body><\/html>\n"}

     

    Please login or register to see this code.

     

    • 0
    Posted

    Sorry, too tired - we should include the data too

    Please login or register to see this code.

     

    • Thanks 1
    • 0
  • Inquirer
  • Posted

     

     

    Ow yeah this works @jgab Thanks a lot :) You made my day perfect!

     

    This is a very good start for me to include the Somfy IO in my homecenter, thanks again.

     

    Amazing :)

     

     

    • 0
    Posted (edited)
    6 minutes ago, ppeterr said:

    Ow yeah this works @jgab Thanks a lot :) You made my day perfect!

    This is a very good start for me to include the Somfy IO in my homecenter, thanks again.

    Amazing :)

    If you have a way to get the current value of the somfy device you could include a poll loop to set the QA value the reflect to Somfy value. (if someone changes with the Somfy control)

     

    If you have more than one Somfy device of the type I would recommend to create child devices.

    Edited by jgab
    • 0
  • Inquirer
  • Posted
    7 minutes ago, jgab said:

    If you have a way to get the current value of the somfy device you could include a poll loop to set the QA value the reflect to Somfy value. (if someone changes with the Somfy control)

     

    If you have more than one Somfy device of the type I would recommend to create child devices.

     

    I probably can resoilve those value's pretty easy. The KLF 200 has got a local API. I have to look at the 

    documentation who made the python script that talks to the Somfy to find out which options are possible.

     

    I need some time for that, can i come back to you about that ? 

    • 0
  • Inquirer
  • Posted

    Well that was pretty easy to find out

     

    curl -s http://192.168.1.134:8000/position/achter

     

    That gives me the position it is currently on

     

    {"result": "ok", "device": "achter", "position": 3}

     

     

    • 0
    Posted

    Please login or register to see this code.

    Then your block scenes should be able to trigger on values changing too.

    • 0
    Posted

    Do you have more devices than "acther" of the same type?

    (It would be easy to make the device a variable to tailor the  QA for different devices)

    • 0
  • Inquirer
  • Posted
    57 minutes ago, jgab said:

    Do you have more devices than "acther" of the same type?

    (It would be easy to make the device a variable to tailor the  QA for different devices)

     

    No i only have one sunshade at the back of the house.

    I will try the new code now.

    • 0
  • Inquirer
  • Posted (edited)

    I have applied the code, but before that I tested the following.

     

    When I use the script to set the blinds in position. Then the url "curl -s http://192.168.1.134:8000/position/achter" returns the correct value.

     

    When i use the remote control and change the position, the url to return the position returns the old value. 

    So there is something wrong with requesting the current state. I doesnt have anything to do with your code.

    I think i have to look into the KLF200 API, to see how that works.

     

    The script you made runs just fine :)

     

     

    To make it a little more clear, the url i gave to read the current position.

    Reads the current position of the blinds that was set with the python script.

     

    Lets see if i can find out how to get that from the KLF.

    Edited by ppeterr
    • 0
  • Inquirer
  • Posted

    But well, i think this is just perfect for what i want.

     

    I have a control panel on the wall with some zwave switches. I'll put one there with 8 buttons I think. And then add some scenes to that. 10% open 30% open etc. I can also link it to a rain notification scene, which then sends a push notification to my phone. Which I can then close the blinds with.

     

    PERFECT   :)

    • 0
  • Inquirer
  • Posted (edited)

    @jgab

     

    I've been looking around for a while how I can access the KLF200 API. And that is indeed possible, but not via the script with which I now address the KLF200

    There I can only read the status made by the python script. If I want to read the position of the Somfy , I will have to install a wrapper module on my RP4 that can then read out a few things. How to implement this further in your script. I have no idea. But honestly, I don't see any disadvantages yet  to get the screens in position via the script on the HC3 without current status. It already seems to work fine, even if I set a different position with the original remote control. And after that with the script it works fine. Perhaps I'm missing the option to check in certain scenes what state the screens are in before executing. But I don't see any downside to that now.

     

    For now. Top! thanks.

    Edited by ppeterr
    • 0
  • Inquirer
  • Posted (edited)

     

    @jgab Or anyone else :)

     

    You helped me a lot last year with a piece of code that sends a cURL to an RPI that then uses a python script to control my Somfy Sunscreens . Works perfectly! But now I'm migrating everything to my NAS. I'm running into a problem that I don't understand. I suspect it has nothing to do with your code. Or the HC3. But rather with the way I apply it in a VM. I'm stuck on it, so I thought I'd put it here anyway.

     

    - python script running on the NAS in an Ubuntu VM. Works, and sets up a connection with the hub to control the somfy

     

    Please login or register to see this code.


    - running a cURL syntax from the CLI (this is the same as your code does on the hc3) and on the hc3 it also gives a peer reset)

     

    Please login or register to see this code.

     

    So, this gives a curl 56 error.

     

    I am lost, i dont know where this comes from. Might it be a routing problem ?

     

    The only difference is that is now runs in a VM on my synology nas.

     

    Any help is appreciated!

     

    PS

     

    This is the post with your code, gives the same error as a plain curl syntax (with different IP's now ofcourse)

     

     

    Edited by ppeterr

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