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)

189111314

Comments

  • viktor said:
    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.

    Viktor thanks for you reaction

    but sorry it isn't working I get the error unexpected token >

  • Leeuw1960 said:
    viktor said:
    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.

    Viktor thanks for you reaction

    but sorry it isn't working I get the error unexpected token >

    Perhapse i think to dificult. When i past The complete url in internet explorer it works. 
  • Leeuw1960 said:
    Leeuw1960 said:
    viktor said:
    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.

    Viktor thanks for you reaction

    but sorry it isn't working I get the error unexpected token >

    Perhapse i think to dificult. When i past The complete url in internet explorer it works. 
    @Leeuw1960 ;
    Aha! That's called a GET request, not a POST.
    For this scenario you must use the HTTP GET JSON card with parameters:
    1: https://my.zipato.com/zipato-web/remoting/attribute/set
    2: {serial:'myserial', apiKey: 'mykey'}

    The json formatted parameters will be converted to the querystring and are added to the url with a questionmark between.
  • Leeuw1960 said:
    Leeuw1960 said:
    viktor said:
    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.

    Viktor thanks for you reaction

    but sorry it isn't working I get the error unexpected token >

    Perhapse i think to dificult. When i past The complete url in internet explorer it works. 
    @Leeuw1960 ;
    Aha! That's called a GET request, not a POST.
    For this scenario you must use the HTTP GET JSON card with parameters:
    1: https://my.zipato.com/zipato-web/remoting/attribute/set
    2: {serial:'myserial', apiKey: 'mykey'}

    The json formatted parameters will be converted to the querystring and are added to the url with a questionmark between.
    Thanks Erik,

    it works indeed i used HTTP GET without the JSON part
  • Is there anybody who send a working http json command with http request flow??
  • posthok said:
    Is there anybody who send a working http json command with http request flow??
    I did :).
    What do you want to achieve ? 
  • posthokposthok Member
    edited December 2016
    Send a color to my hyperion. Hyperion from weejewel does'nt work.
    Could you give me a example?
  • posthok said:
    Send a color to my hyperion. Hyperion from weejewel does'nt work.
    Could you give me a example?
    Hyperion needs websocket commands doesn't it? I made a card for that a while ago in the HTTP app. I guess @Phuturist used this for his hyperion setup. Can you give an example of a request? Or some docs? 
  • posthok said:
    Send a color to my hyperion. Hyperion from weejewel does'nt work.
    Could you give me a example?
    Hyperion needs websocket commands doesn't it? I made a card for that a while ago in the HTTP app. I guess @Phuturist used this for his hyperion setup. Can you give an example of a request? Or some docs? 
    Thanx, i will ask Phuturist on slack.
  • Hi @ErikVanDongen , maybe you can help me:
    Can  i save the value received from a GET response to a BL Variable?
    GET Url is:
    http://<IP Address or mDNS Name>/zrap/chscan/ch1

    And the Response Body:
    <?xml version="1.0" encoding="ASCII" ?>
    <ch2>
    <val>85</val>
    </ch2>

    Can i save the value 85 into a BL variable?

    Thank you
  • viktor said:
    Hi @ErikVanDongen , maybe you can help me:
    Can  i save the value received from a GET response to a BL Variable?
    GET Url is:
    http://<IP Address or mDNS Name>/zrap/chscan/ch1

    And the Response Body:
    <?xml version="1.0" encoding="ASCII" ?>
    <ch2>
    <val>85</val>
    </ch2>

    Can i save the value 85 into a BL variable?

    Thank you


    Yes!
    XML wil be parsed to JSON, and with that we can do a JSONpath query like $.ch2.val 

  • Hi @ErikVanDongen and tnx for your response. Unfortunately i receive "no result from jsonPath". Using the same Url with the Chrome http App is working.
  • I was very happy when the bearer authorization was added to the app some time ago as it adds some extra security.

    But I have run into a scenario where I can't add the extra header to the request (IP camera that can not add extra headers). I would like to avoid having to completely disable this extra layer of security.

    So, I was thinking. Is it possible to have an option that disables the authorization for specific incoming IP addresses or perhaps the complete LAN?
  • Somewhere around page 8 of this thread @ErikVanDongen claimed this couldn't be done (yet):
    https://forum.athom.com/discussion/comment/19759/#Comment_19759
  • Somewhere around page 8 of this thread @ErikVanDongen claimed this couldn't be done (yet):
    https://forum.athom.com/discussion/comment/19759/#Comment_19759
    Thanx, had a talk about it with Erik on Slack. The Homey api does not support the origin IP (yet) so there is no way in knowing where the request came from. Easiest solution for now is to fork the repo and created a trigger card that bypasses the bearer authorization (and use it with care).
  • viktor said:
    Hi @ErikVanDongen and tnx for your response. Unfortunately i receive "no result from jsonPath". Using the same Url with the Chrome http App is working.
    If you run the app from the command line, or with my realtime logpage (https://github.com/irritanterik/homey-realtime-logpage) you can check the results and jsonPath process. Can you share this informaton so we can help debug your issue?
  • Hi @ErikVanDongen and thank you for your help

    Here is the Logpage output, the output is "0" and thats is ok, only the app is giving the 0 as error.
    2016-12-29T20:23:17.189Z	Flow: test	{"test_id":"b85f2d80-1905-469b-9ce8-fa6dc11eed6d","card_uri":"homey:app:com.internet","card_id":"http_get_variable_BetterLogic","card_type":"action","card_index":0,"state":"error","err":"No result from jsonPath"}
    2016-12-29T20:23:17.181Z	HTTP request flow cards	["HTTP Log",{"datetime":"2016-12-29T20:22:56.992Z","message":" --> variable result"}]
    2016-12-29T20:23:17.172Z	HTTP request flow cards	["HTTP Log",{"datetime":"2016-12-29T20:22:56.982Z","message":" --> result from request","data":{"chscan":{"ch2":[{"val":["0"]}]}}}]
    2016-12-29T20:23:17.156Z	HTTP request flow cards	["HTTP Log",{"datetime":"2016-12-29T20:22:56.966Z","message":" --> result is not valid JSON, will try XML now","data":"0"}]
    2016-12-29T20:23:17.120Z	HTTP request flow cards	["HTTP Log",{"datetime":"2016-12-29T20:22:56.918Z","message":"action.http_get_variable_BetterLogic","data":{"args":{"url":"http://192.168.10.25/zrap/chscan/ch2","path":"$.ch2.val","betterVariable":{"name":"get-status-storen-kz-sued","type":"string","value":"","lastChanged":"2016-11-21T21:58:13.000Z","remove":false,"label":""}},"method":"get","urlOptions":{"uri":"http://192.168.10.25/zrap/chscan/ch2","json":false,"timeout":30000}}}]
    2016-12-29T20:23:16.992Z	Flow: test	{"test_id":"b85f2d80-1905-469b-9ce8-fa6dc11eed6d","card_uri":"homey:app:com.internet","card_id":"http_get_variable_BetterLogic","card_type":"action","card_index":0,"state":"running"}
  • @viktor
    Ah, you'll just need a little more complex jsonPath: $.chscan.ch2[0].val[0]
  • Haven't read through the entire topic, so hopefully I'm not going to ask something stupid now :)

    I'm going to try to poll my Foscam for motion alarms.  Don't know if this is possible with this app?
    When I use http://192.168.1.7:9999/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=xxxxxx&pwd=xxxxxx I get this as a response:
    <CGI_Result>
        <result>0</result>
        <IOAlarm>0</IOAlarm>
        <motionDetectAlarm>2</motionDetectAlarm>
        <soundAlarm>0</soundAlarm>
        <record>1</record>
        <sdState>1</sdState>
        <sdFreeSpace>10699792k</sdFreeSpace>
        <sdTotalSpace>16169984k</sdTotalSpace>
        <ntpState>1</ntpState>
        <ddnsState>0</ddnsState>
        <url>http%3A%2F%2Ffb3010.myfoscam.org%3A9999</url>
        <upnpState>1</upnpState>
        <isWifiConnected>1</isWifiConnected>
        <wifiConnectedAP>Fire69</wifiConnectedAP>
        <infraLedState>1</infraLedState>
    </CGI_Result>
    
    Is there any way I could filter out the <motionDetectAlarm>2</motionDetectAlarm> (1 is no alarm, 2 is motion alarm)?
  • Fire69 said:
    Haven't read through the entire topic, so hopefully I'm not going to ask something stupid now :)

    I'm going to try to poll my Foscam for motion alarms.  Don't know if this is possible with this app?
    When I use http://192.168.1.7:9999/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=xxxxxx&pwd=xxxxxx I get this as a response:
    <CGI_Result>
        <result>0</result>
        <IOAlarm>0</IOAlarm>
        <motionDetectAlarm>2</motionDetectAlarm>
        <soundAlarm>0</soundAlarm>
        <record>1</record>
        <sdState>1</sdState>
        <sdFreeSpace>10699792k</sdFreeSpace>
        <sdTotalSpace>16169984k</sdTotalSpace>
        <ntpState>1</ntpState>
        <ddnsState>0</ddnsState>
        <url>http%3A%2F%2Ffb3010.myfoscam.org%3A9999</url>
        <upnpState>1</upnpState>
        <isWifiConnected>1</isWifiConnected>
        <wifiConnectedAP>Fire69</wifiConnectedAP>
        <infraLedState>1</infraLedState>
    </CGI_Result>
    
    Is there any way I could filter out the <motionDetectAlarm>2</motionDetectAlarm> (1 is no alarm, 2 is motion alarm)?
    Yes. 
  • Yes. 
    Well, that's good news  ;)
    I'll search through the topic to see what I can find then :)
  • viktor said:
    Hi @ErikVanDongen , maybe you can help me:
    Can  i save the value received from a GET response to a BL Variable?
    GET Url is:
    http://<IP Address or mDNS Name>/zrap/chscan/ch1

    And the Response Body:
    <?xml version="1.0" encoding="ASCII" ?>
    <ch2>
    <val>85</val>
    </ch2>

    Can i save the value 85 into a BL variable?

    Thank you


    Yes!
    XML wil be parsed to JSON, and with that we can do a JSONpath query like $.ch2.val 

    @Fire69 seems like my problem: path, than $.CGI_Result.motionDetectAlarm than the BL Variable where to store it, and thn you can make a new flows to filter it mayybe?
  • viktor said:
    viktor said:
    Hi @ErikVanDongen , maybe you can help me:
    Can  i save the value received from a GET response to a BL Variable?
    GET Url is:
    http://<IP Address or mDNS Name>/zrap/chscan/ch1

    And the Response Body:
    <?xml version="1.0" encoding="ASCII" ?>
    <ch2>
    <val>85</val>
    </ch2>

    Can i save the value 85 into a BL variable?

    Thank you


    Yes!
    XML wil be parsed to JSON, and with that we can do a JSONpath query like $.ch2.val 

    @Fire69 seems like my problem: path, than $.CGI_Result.motionDetectAlarm than the BL Variable where to store it, and thn you can make a new flows to filter it mayybe

    Thanks! I'll give that a try. Hope I can get it working, don't fully understand it :smiley:
    Was reading through the entire topic, you saved me some time ;)
  • Fire69 said:
    Yes. 
    Well, that's good news  ;)
    I'll search through the topic to see what I can find then :)
    The answer for your implicit question was: Variable Get card with expression  $.CGI_Result.motionDetectAlarm[0]

  • Fire69 said:
    Yes. 
    Well, that's good news  ;)
    I'll search through the topic to see what I can find then :)
    The answer for your implicit question was: Variable Get card with expression  $.CGI_Result.motionDetectAlarm[0]

    Yep, it's working now!
    Thanks again! :)
  • ErikVanDongenErikVanDongen Member
    edited January 2017
    Hi all. I just updated the app to version 1.5.0. I added these community requested functions:
     - POST trigger card
     - POST XML action card
     - JSON path logic cards (condition and action)
     - New: Require authorisation on API calls, but accept white-listed IP-addresses (see settings page)
     - More logging (when run from CLI or with Realtime Logpage)

  • HansieNLHansieNL Member
    edited January 2017
    I installed version 1.5, but my flows activating Domoticz switches don't work anymore. Am I missing something?
    This what I use now: Homey fw 1.1.2 and HTTP Get JSON card "http://domoticz-ip:port/json.htm" and "{type":"command","param":"switchlight","idx":123,"switchcmd":"On"}"
    If I install v 1.3.3 via CLI everything works again.
  • PhuturistPhuturist Member
    edited January 2017
    Hi all. I just updated the app to version 1.5.0. I added these community requested functions:
     - POST trigger card
     - POST XML action card
     - JSON path logic cards (condition and action)
     - New: Require authorisation on API calls, but accept white-listed IP-addresses (see settings page)
     - More logging (when run from CLI or with Realtime Logpage)

    Awesome Erik, once again thanx for fulfilling my request ... :+1:

    [Edit]
    I can confirm the issue of HansieNL. I have GET variable Step 1 flow that is not working anymore. I'm pretty sure it used to work before 1.5.0. The error on the card is "Value not found".
  • After the update this trigger don't work anymore  :(
    http://inlognaam:wachtwoord@ipadres/web/powerstate
    {"newstate":4}

Sign In or Register to comment.