This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.
Official

[APP] Simple HTTP Connector For Flows (2.0.0)

1810121314

Comments

  • mauriceb said:
    Is it possible to do a POST with the following body: {"notification":{"powerstate":{"powerstate":""}}} and putting the result {"powerstate": {"powerstate": "Standby"}} in a Better Logic variable?

    I tried figuring out the Node HTTP options but do not seem to get it working.
    I just put version 1.3.2 on github with an improvement / bugfix that makes your request possible.

    Example:
    first parameter: {"uri":"http://httpbin.org/post", "method": "post", "protocol": "http:", "json": {"notification":{"powerstate":{"powerstate":5}}}}
    second parameter: $[json][notification][powerstate][powerstate]
    third parameter: a Better Logic variable

    Result for this example:
    5

    Are you able to test this version before I submit it to the app store?
    @ErikVanDongen Reading your response I think my example is not completely clear. I first want to send a POST with this body: {"notification":{"powerstate":{"powerstate":""}}} and in the response I receive this body back {"powerstate": {"powerstate": "Standby"}}.

    What this actually does is requesting the power state of my TV. For clarification I added a screenshot from SoapUI with on the left the request and on the right the response.

    However your example does clear up some questions on how to use the node HTTP options. I also need to talk to a specific port and if I understand it correctly I only need to add the parameter "port":1925.


  • mauriceb said:
    mauriceb said:
    Is it possible to do a POST with the following body: {"notification":{"powerstate":{"powerstate":""}}} and putting the result {"powerstate": {"powerstate": "Standby"}} in a Better Logic variable?

    I tried figuring out the Node HTTP options but do not seem to get it working.
    I just put version 1.3.2 on github with an improvement / bugfix that makes your request possible.

    Example:
    first parameter: {"uri":"http://httpbin.org/post", "method": "post", "protocol": "http:", "json": {"notification":{"powerstate":{"powerstate":5}}}}
    second parameter: $[json][notification][powerstate][powerstate]
    third parameter: a Better Logic variable

    Result for this example:
    5

    Are you able to test this version before I submit it to the app store?
    @ErikVanDongen Reading your response I think my example is not completely clear. I first want to send a POST with this body: {"notification":{"powerstate":{"powerstate":""}}} and in the response I receive this body back {"powerstate": {"powerstate": "Standby"}}.

    What this actually does is requesting the power state of my TV. For clarification I added a screenshot from SoapUI with on the left the request and on the right the response.

    However your example does clear up some questions on how to use the node HTTP options. I also need to talk to a specific port and if I understand it correctly I only need to add the parameter "port":1925.


    My example is exactly based on your scenario. Just be sure you use the *latest version from github* (not available in the app store atm). Based on your SoapUI screenshot I expect you must use this parameters on the card:

    First parameter: {"protocol": "http:", "hostname": "192.168.128.35", "port": 1925, "path":"/5/notifychange", "method": "post", "json": {"notification":{"powerstate":{"powerstate":""}}}}
    Second parameter: $[json][powerstate][powerstate]

    The first parameter executes a post to http://192.168.128.35:1925/5/notifychange with body {"notification":{"powerstate":{"powerstate":""}}}
    The second parameter reads the value in powerstate > powerstate from the returned json result. 

  • mauriceb said:
    mauriceb said:
    Is it possible to do a POST with the following body: {"notification":{"powerstate":{"powerstate":""}}} and putting the result {"powerstate": {"powerstate": "Standby"}} in a Better Logic variable?

    I tried figuring out the Node HTTP options but do not seem to get it working.
    I just put version 1.3.2 on github with an improvement / bugfix that makes your request possible.

    Example:
    first parameter: {"uri":"http://httpbin.org/post", "method": "post", "protocol": "http:", "json": {"notification":{"powerstate":{"powerstate":5}}}}
    second parameter: $[json][notification][powerstate][powerstate]
    third parameter: a Better Logic variable

    Result for this example:
    5

    Are you able to test this version before I submit it to the app store?
    @ErikVanDongen Reading your response I think my example is not completely clear. I first want to send a POST with this body: {"notification":{"powerstate":{"powerstate":""}}} and in the response I receive this body back {"powerstate": {"powerstate": "Standby"}}.

    What this actually does is requesting the power state of my TV. For clarification I added a screenshot from SoapUI with on the left the request and on the right the response.

    However your example does clear up some questions on how to use the node HTTP options. I also need to talk to a specific port and if I understand it correctly I only need to add the parameter "port":1925.


    My example is exactly based on your scenario. Just be sure you use the *latest version from github* (not available in the app store atm). Based on your SoapUI screenshot I expect you must use this parameters on the card:

    First parameter: {"protocol": "http:", "hostname": "192.168.128.35", "port": 1925, "path":"/5/notifychange", "method": "post", "json": {"notification":{"powerstate":{"powerstate":""}}}}
    Second parameter: $[json][powerstate][powerstate]

    The first parameter executes a post to http://192.168.128.35:1925/5/notifychange with body {"notification":{"powerstate":{"powerstate":""}}}
    The second parameter reads the value in powerstate > powerstate from the returned json result. 

    @ErikVanDongen I installed the version from Github and updated the card. It does run without returning an error but the value set in the Better Logic parameter is being updated to "undefined". I did a reboot with the same result.

    Is there a way I can debug the steps?
  • @mauriceb you can run the app with command `athom project --run` and check the console output.
    Other option is to use my Realtime Homey Logger:

    If you paste the realtime log lines of the HTTP app with this tool I can help you debugging.

  • @ErikVanDongen Send you pm.
  • mauricebmauriceb Member
    edited July 2016
    mauriceb said:
    mauriceb said:
    Is it possible to do a POST with the following body: {"notification":{"powerstate":{"powerstate":""}}} and putting the result {"powerstate": {"powerstate": "Standby"}} in a Better Logic variable?

    I tried figuring out the Node HTTP options but do not seem to get it working.
    I just put version 1.3.2 on github with an improvement / bugfix that makes your request possible.

    Example:
    first parameter: {"uri":"http://httpbin.org/post", "method": "post", "protocol": "http:", "json": {"notification":{"powerstate":{"powerstate":5}}}}
    second parameter: $[json][notification][powerstate][powerstate]
    third parameter: a Better Logic variable

    Result for this example:
    5

    Are you able to test this version before I submit it to the app store?
    @ErikVanDongen Reading your response I think my example is not completely clear. I first want to send a POST with this body: {"notification":{"powerstate":{"powerstate":""}}} and in the response I receive this body back {"powerstate": {"powerstate": "Standby"}}.

    What this actually does is requesting the power state of my TV. For clarification I added a screenshot from SoapUI with on the left the request and on the right the response.

    However your example does clear up some questions on how to use the node HTTP options. I also need to talk to a specific port and if I understand it correctly I only need to add the parameter "port":1925.


    My example is exactly based on your scenario. Just be sure you use the *latest version from github* (not available in the app store atm). Based on your SoapUI screenshot I expect you must use this parameters on the card:

    First parameter: {"protocol": "http:", "hostname": "192.168.128.35", "port": 1925, "path":"/5/notifychange", "method": "post", "json": {"notification":{"powerstate":{"powerstate":""}}}}
    Second parameter: $[json][powerstate][powerstate]

    The first parameter executes a post to http://192.168.128.35:1925/5/notifychange with body {"notification":{"powerstate":{"powerstate":""}}}
    The second parameter reads the value in powerstate > powerstate from the returned json result. 

    @ErikVanDongen Changing the second parameter to $[powerstate][powerstate] did the trick. Thanks a lot for your help!
  • I installed the GitHub version (1.3.2) this evening to see if it fixes the issue with saving special characters in a BetterLogic variable. It looks like this issue has not been fixed. Below are details of the http request I'm trying to save, perhaps this helps troubleshoot.

    URL: http://api.wunderground.com/api/<<key>>/conditions/forecast/lang:NL/q/pws:IGRONING72.json
    JSON: $.[forecast][txt_forecast][forecastday][2][fcttext_metric]

    Result that should be saved: "Zich in de middag ontwikkelende regen. Maximaal 19C. Wind uit het ZW van 15 tot 30 km/u. Kans op regen 90%. Regenval ongeveer ~ 6 mm. Lokaal zware regenbuien mogelijk."
  • casedacaseda Member
    edited July 2016
    I'm trying to set several variables with the http app (from weather underground).
    But it starts a connection to the api for every variable it is getting.
    I tried to limit the amount of pulls with the option:
    "headers": {"Connection": "keep-alive"}
    But it still keeps reopening the connection.
    Or it is giving me an "Cannot read property 'indexOf' of undefined" error, which i can't figure out what is wrong.
    codes i tried:

    {"url": "http://api.wunderground.com/api/<<API_KEY>>/conditions/lang:NL/q/NL/Winterswijk.json", "headers": {"Content-Type": "application/json", "Connection": "keep-alive"}}
    {"hostname": "http://api.wunderground.com" "path": "/api/<<API_KEY>>/conditions/lang:NL/q/NL/Winterswijk.json", "headers": {"Content-Type": "application/json", "Connection": "keep-alive"}}

    Or is it just not possible what i'm trying to achieve?
    Since it re-triggers the request with every [THEN] Card

    Or is there a way to keep using the entire JSON page with just one request and set several variables with that?
  • caseda said:
    I'm trying to set several variables with the http app (from weather underground).
    But it starts a connection to the api for every variable it is getting.
    I tried to limit the amount of pulls with the option:
    "headers": {"Connection": "keep-alive"}
    But it still keeps reopening the connection.
    Or it is giving me an "Cannot read property 'indexOf' of undefined" error, which i can't figure out what is wrong.
    codes i tried:

    {"url": "http://api.wunderground.com/api/<<API_KEY>>/conditions/lang:NL/q/NL/Winterswijk.json", "headers": {"Content-Type": "application/json", "Connection": "keep-alive"}}
    {"hostname": "http://api.wunderground.com" "path": "/api/<<API_KEY>>/conditions/lang:NL/q/NL/Winterswijk.json", "headers": {"Content-Type": "application/json", "Connection": "keep-alive"}}

    Or is it just not possible what i'm trying to achieve?
    Since it re-triggers the request with every [THEN] Card

    Or is there a way to keep using the entire JSON page with just one request and set several variables with that?


    So the question is, is it possible to pull multiple JSON's out of one request and punt them in multiple Better Logical variables?


    Don't Know the answer but it would be great when it became possible.



  • I use the websocket send card to open my garage door. Works very nice! Is it possible to make a websocket receive card (for the when column) to check the door status?  
  • MarkSwiftMarkSwift Member
    edited August 2016
    Update: Got the variables working. Fantastic!

    @ErikVanDongen
    , is it possible to have numerical better logic variables as an option, as I need to trigger some of my flows on the variable numerical value...

    Guys,

    I was wondering if someone could help me. I'm trying to pull some basic data from my Bloomsky API.

    The instructions are:
    Use HTTP header "Authorization: your_api_key" and initiate a GET request at https://api.bloomsky.com/api/skydata/?unit=intl

    The result is some nice JSON. I'd like to pull the table Data - Temperature / Humidity / UVIndex into variables (See screenshot). Can someone help me achieve this? I'd really appreciate it!
  • @MarkSwift Added numeric BetterLogic variable support this night! 
  • Kosmonout said:
    I use the websocket send card to open my garage door. Works very nice! Is it possible to make a websocket receive card (for the when column) to check the door status?  
    Everything is possible!
    Do you have documentation of this device / api? I must create a dummy service first for testing the card and determine how to support this feature somewhat generic. Will you be available for testing this (using github downloads and CLI installation on your Homey)?
  • So the question is, is it possible to pull multiple JSON's out of one request and punt them in multiple Better Logical variables?

    Don't Know the answer but it would be great when it became possible.

    This will not be supported with the HTTP App. It requires more extended flow card configurations (more / expandable fields and settings) and that is not supported by Athom. I don't expect functions like this in the next months.
    Because flow cards have no knowledge of each other keep-alive mechanisms would be very hard to accomplish.
  • So the question is, is it possible to pull multiple JSON's out of one request and punt them in multiple Better Logical variables?

    Don't Know the answer but it would be great when it became possible.

    This will not be supported with the HTTP App. It requires more extended flow card configurations (more / expandable fields and settings) and that is not supported by Athom. I don't expect functions like this in the next months.
    Because flow cards have no knowledge of each other keep-alive mechanisms would be very hard to accomplish.
    too bad, not even a way like putting the entire json into a variable/the inner storage? instead of just one value
  • caseda said:
    So the question is, is it possible to pull multiple JSON's out of one request and punt them in multiple Better Logical variables?

    Don't Know the answer but it would be great when it became possible.

    This will not be supported with the HTTP App. It requires more extended flow card configurations (more / expandable fields and settings) and that is not supported by Athom. I don't expect functions like this in the next months.
    Because flow cards have no knowledge of each other keep-alive mechanisms would be very hard to accomplish.
    too bad, not even a way like putting the entire json into a variable/the inner storage? instead of just one value
    Storing the entire response / or JSONpath located json object would be possible, but how would you extract the values from that string?
  • Storing the entire response / or JSONpath located json object would be possible, but how would you extract the values from that string?
    instead of a getting via url, get from variable.? or is it not possible the other way around (get from, instead of put in)
    after that its the same as getting it from a url
  • caseda said:
    Storing the entire response / or JSONpath located json object would be possible, but how would you extract the values from that string?
    instead of a getting via url, get from variable.? or is it not possible the other way around (get from, instead of put in)
    after that its the same as getting it from a url
    I am not aware of logic supported by Homey where you can get a specific substring from a larger string. Can you give an example?
  • casedacaseda Member
    edited August 2016


    I was thinking a little bit like this,
    Variable Full JSON = where you get the variable with the full json
    JSONpath = well.. the json path to the value
    Variable Value = the singel value gotten from the full json

    But yeah, it is a string, so it will be needed to "parse" it.
    But i don't know if that is supported in the node.js version homey is using
  • Version 1.3.3 is now published in the app store. Number typed Better Logic variables support is now added to the Better Logic variable.
  • caseda said:


    I was thinking a little bit like this,
    Variable Full JSON = where you get the variable with the full json
    JSONpath = well.. the json path to the value
    Variable Value = the singel value gotten from the full json

    But yeah, it is a string, so it will be needed to "parse" it.
    But i don't know if that is supported in the node.js version homey is using
    Ok I understand what you want. I just don't think a 'read Better Logic variable and set another Better Logic variable based on JSONpath result' is something the HTTP App should support.
    Maybe the BetterLogic developer want to adopt this function in his app?
  • Trying to control one StriimLight with Post json but always getting error 412.

    http://192.168.10.1:34000/Light/Capability/SwitchPower.json 
    {"state":"true"} for On, {"state":"false"} for Off

    Someone having tipps how to make it?

    Tnx
  • viktor said:
    Trying to control one StriimLight with Post json but always getting error 412.

    http://192.168.10.1:34000/Light/Capability/SwitchPower.json 
    {"state":"true"} for On, {"state":"false"} for Off

    Someone having tipps how to make it?

    Tnx
    Do you have a link to documentation of the StriimLight json API?
    You can try leave the quotes around "true" and "false".
  • Hi @ErikVanDongen ;

    I find out all this with the Web Interface of the Striim device and investigating. Using the Post App in Chrome is working, but not from Homey.

    I will try tonight without quotes

    Tnx
  • Hey @ErikVanDongen you are a genius, without quotes around true and false is working perfect.

    Now even starting and playing music presets is working perfect: http://192.168.10.1:34000/Player/PlayPreset.json and then {"id":1} for the first preset and so on.

    Thank you
  • I was wondering if it is possible to post XML data using this app? My Sony TV can be controlled by sending a bit of XML to a URL on the TV (see also http://www.openremote.org/display/forums/Sony+TV+HTTP+control)
  • Niek said:
    I was wondering if it is possible to post XML data using this app? My Sony TV can be controlled by sending a bit of XML to a URL on the TV (see also http://www.openremote.org/display/forums/Sony+TV+HTTP+control)
    Hi Niek,

    At the moment this is not possible. Can you post a feature request via an issue on my github? https://github.com/irritanterik/homey-http-request-actions/issues
    I wil refactor some code in the app later this year, will look to your request then.
  • snijplanksnijplank Member
    edited November 2016
    any way to get around this stupid google engine 'bug'?

    Any url with &para gets parsed: look at the &para part:
    http://10.0.0.16/json.htm?type=command¶m=switchlight&idx70&switchcmd=Off




  • i want to post the link here below as plain tekst, how can i do that.?

    https://my.zipato.com/zipato-web/remoting/attribute/set?serial=myserial&apiKey=mykey&state=1

  • Maybe with HTTP Post Form?

    URL: https://my.zipato.com/zipato-web/remoting/attribute/set?
    then: {"serial":"myserial", "apiKey":"mykey", "state":"1"}

    or

    URL:  https://my.zipato.com/zipato-web/remoting/attribute/set?serial=myserial&apiKey=mykey&
    then: {"state":"1"}

    Not sure if is working.
Sign In or Register to comment.