[APP][Pro] HTTP request flow cards - HTTP request triggers, conditions and actions for flows

Simple HTTP Connector For Flows

Check it out the full description in the store : HTTP request flow cards App for Homey | Homey

image

Feedback is welcome!
Happy hacking!

19-sep-2017: Version 2.0.0 is published.
Minor bugfixes and rewrite to SDK v2

02-01-2017: Version 1.5.0 is published. A lot has happened since 1.3.3. I added support for white-listed unauthorized API calls (check the settings page). Also added more JSONpath logic cards, a POST trigger and XML cards.
08-08-2016: Version 1.3.3 is now published. The better logic card now supports Number typed variables.
02-07-2016: Version 1.3.0 is now published. A new action card for setting Better Logic variables is added.
31-05-2016: Version 1.2.1 is now published. It has now a build in timeout on request of 30 seconds. With the geek http options you can set {ā€œurlā€: ā€œhttp://www.athom.comā€, ā€œtimeoutā€: milliseconds} if you want a custom timeout.
04-05-2016: Version 1.2.0 is now published in the app store. It allows disabling the authorization on the API (restart app after settings change) and some geeky stuff with http options.
26-04-2016: Update: version 1.0.0 is now released. It has a breaking change for API users: API calls for flow triggers now require the authorization header.

Support thread for HTTP request flow cards App for Homey | Homey as a continuation of the old forum thread ([APP] Simple HTTP Connector For Flows (2.0.0) ā€” Athom Forum Archive)

Basically what I want to do is using the REST api from DSMR Reader. When doing a ā€˜getā€™ you need to always include an certain (API key) header. With cURL this works just fine, but Iā€™m now trying to let Homey extract a certain value and put it Better Logic. Is it possible to use one of the HTTP Connector cards for this?

According the API documentation you can call either:

cURL:

curl 'http://YOUR-DSMR-URL/api/v2/datalogger/dsmrreading' \
     -H 'X-AUTHKEY: YOUR-API-KEY' | python -m json.tool

Or with requests (Python):

import requests
import json

response = requests.get(
    'http://YOUR-DSMR-URL/api/v2/datalogger/dsmrreading',
    headers={'X-AUTHKEY': 'YOUR-API-KEY'},
)

if response.status_code != 200:
    print('Error: {}'.format(response.text))
else:
    print('Response: {}'.format(json.loads(response.text)))

So the question really is, how can I include a HTTP header?

Take a look at the advanced options.

In your case, try this:

{"method":"get","protocol":"http:","hostname":"YOUR-DSMR-URL","path":"/api/v2/datalogger/dsmrreading","headers":{"X-AUTHKEY":"YOUR-API-KEY"}}
2 Likes

@robertklep You are the best, this worked like a charme! Thumbs up and thank you very much! +1

1 Like

Great app, I use it almost every day.
Just updated Homey to the experimental 2.0 and I canā€™t het me http get requests to work. Is this something known or am I missing something?

Iā€™m not on Homey 2.x yet. Did you get an error on testing the flow?
In the last blog from Athom they write handling web request is now native supported:


Will there still be a need for my app?

Hi Kevin,

Thanks for the prompt reply! I didnā€™t see that Athom got this now added to their own software, I will have a look at that as well.

The response I received was:

{ā€œcodeā€:401,ā€œerrorā€:ā€œnot_logged_inā€,ā€œerror_descriptionā€:ā€œYou need to log in to access this resourceā€}

I think I found why it isnā€™t working, the security is updated so the bearer token is always needed.
Something to check tomorrow.

Whatā€™s your scenario here? Do you want to trigger Homey by a GET request, or do you want to execute a GET request from a flow?

I have the same issue. I want to trigger Homey by a GET request.

When i use the URL with the cloudID i get the message Sorry, this Homey is not connected. The same message then when you try to connect to the old webinterface.

Is it possible that when the Homey is updatet to v2 a new bearer is created? Now i canā€™t find the bearer token anymore.

Any news on this? I really enjoyed connecting my phone with tasker to trigger the homey to start a flow. Now it seems that you cannot connect anymore remotely with http. :frowning:

Making a web request from Homey is different than receiving a request. I have not found any build in solution in homey 2.0 so Iā€™d say your app is still needed. Just seems the whitelist part is not working anymore like mentioned below

{ā€œcodeā€:401,ā€œerrorā€:ā€œnot_logged_inā€,ā€œerror_descriptionā€:ā€œYou need to log in to access this resourceā€}

And I cannot seem to find any token in Homey 2.0

The old bearer token mechanism is not supported with v2. Iā€™m not sure if I will be able to get incomming requests working in a simple way with v2. The blog described a new native function though. I will look at it when v2 is stable enough for production.

I found https://developer.athom.com/docs/apps/tutorial-Webhooks.html which talks about sending requests to Homey. I just hope this is not the alternative since it seems to require the cloud to work :frowning: and it is not something ā€˜mom and dadā€™ could configure (your solution was way easier there).

Very keen to get this working on V2 - at the moment the compatibility is set such that it canā€™t be installed but I gather a lot of it works well on v2 if you already had it installed before upgrade or I assume manually CLI install it.

ā€œThis app is incompatible with your Homey software versionā€

I had the plugin installed before the update to v2 and can confirm that I can send requests from the homey to a device/website.

What doesnā€™t work is the other way around, from a device to homey. The missing part of the existence of a ā€˜bearer keyā€™ in v2 may be the case.

In this topic is some insights how the webhook function (GET) works what might help to trigger a flow outside homey: Webhook GET

The problem lies in the whitelist check indeed. I received errors like:
/api.js:42
if (!onWhitelist(args.req.remoteAddress)) return callback(not on whitelist)
^
TypeError: Cannot read property ā€˜remoteAddressā€™ of undefined
at Object.fn (/api.js:42:33)

I will investigate further as iā€™m now on v2.

args.req doesnā€™t exist anymore, it has been removed for V2 because (paraphrasing Athom) the API can theoretically be used by protocols other than HTTP.

Hey guys, HTTP App whitelist function will be removed in a next V2 compatible version unfortunantly (https://github.com/athombv/homey-apps-sdk-issues/issues/28)