# Calling an external service and receiving the Response in a variable?

**URL:** <https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445>\
**Category:** Developers\
**Tags:** app, tools\
**Created:** [April 29, 2019, 4:36pm UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445 "2019-04-29T16:36:27Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![thudelicious](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thudelicious/32/16721_2.png) [@thudelicious](https://community.homey.app/u/thudelicious)\
**Post date:** [February 6, 2020, 9:07pm UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/21 "2020-02-06T21:07:14Z")

</div>

Hi Erik,

I am trying to follow your receipt in order to get the hourly forecast from this site:  
[https://api.met.no/weatherapi/locationforecast/2.0?lat=58.945370&lon=5.573560](https://api.met.no/weatherapi/locationforecast/2.0?lat=58.945370&lon=5.573560)

I would like to store all the parameters (i.e air\_temperature, wind\_speed, ) for the next 12 hours in variables for use in other flows. However, I am struggling to get it to work (I am not very experienced with programming unfortunately). Do you have any ideas how I can make it work?  
How would you store the data in variables for instance? Would you make one air\_temperature variable in better logic for each hour, or is it possible to store all 12 hours in an array?  
Also, when I try to run I get a flow card error in the second step saying value not found. Can you see what I am doing wrong?

Any help would be greatly appreciated 🙂

All the best,  
Eirik

 ![Screenshot 2020-02-06 at 22.08.32](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/1/01a7f071f34922985a8cb466c37dc691fc02261d.jpeg) ![Screenshot 2020-02-06 at 21.53.44](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/7/6/76da6d42aad581a70b90d63c946dced5f5e2d632.jpeg)

---

<div class="post-metadata">

**Author:** ![peltsi51](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peltsi51/32/12564_2.png) [@peltsi51](https://community.homey.app/u/peltsi51)\
**Post date:** [February 7, 2020, 6:43am UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/22 "2020-02-07T06:43:25Z")

</div>

Hi @thudelicious

If you like to have the current hour temperature, the JSONpath expression for that is

$.properties.timeseries[0].data.instant.details.air\_temperature

The next hour is

$.properties.timeseries[1].data.instant.details.air\_temperature

and so on…

There isn’t any array possibility in better logic or Homey variables, so you have to use separate variables. I think in Homey script there are possibility for arrays if you want to dive into that.

In [http://jsonpath.com/](http://jsonpath.com/) you can evaluate the JSONpath syntax by copying your source to the page etc.

---

<div class="post-metadata">

**Author:** ![thudelicious](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thudelicious/32/16721_2.png) [@thudelicious](https://community.homey.app/u/thudelicious)\
**Post date:** [February 7, 2020, 8:08am UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/23 "2020-02-07T08:08:39Z")

</div>

I see! Thank you so much.  
The link was also very useful to check out the syntax 🙂  
I still get an error message when trying to test the flow however, but I am guessing that the card needs some sort of input which should be given from the other card. So when I try to test it I have to give it the input ({“a”:1,“b”:“some text”})? What should I put in here in order to test the card?

Think I will have to look into Homey Script eventually, but as I just got my homey I think I will start with trying to get a better understanding of the flows first 🙂

Thanks again!

---

<div class="post-metadata">

**Author:** ![thudelicious](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/thudelicious/32/16721_2.png) [@thudelicious](https://community.homey.app/u/thudelicious)\
**Post date:** [February 7, 2020, 8:20am UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/24 "2020-02-07T08:20:55Z")

</div>

It seems to be running fine when I checked the variables, so I guess the best way is to verify the JSONpath first.

---

<div class="post-metadata">

**Author:** ![Philipp\_Karl](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/philipp_karl/32/12702_2.png) [@Philipp\_Karl](https://community.homey.app/u/Philipp_Karl)\
**Post date:** [May 3, 2020, 1:24pm UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/25 "2020-05-03T13:24:02Z")

</div>

Hello @Erik,

I would like to add a condition to my sprinkler that if the predicted amount of rain from the national weather service is greater than 0, the sprinkler will not start.

I have the url for the query to the weather service for the next 5 days:

[http://daten.buergernetz.bz.it/services/weather/district/6/bulletin?format=json&lang=de](http://daten.buergernetz.bz.it/services/weather/district/6/bulletin?format=json&lang=de)

This is the result, where I need the value marked in yellow:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/7/d/7d32c9ae605807cc7a72a22fd29fc8a6e6c560c2.png)

I created 2 flows, the first calls the weatherdata, the second should write the betterlogic variable:

[https://homey.app/f/fBxIq7](https://homey.app/f/fBxIq7)

[https://homey.app/f/F9FIq7](https://homey.app/f/F9FIq7)

I also created a betterlogic variable:

 ![Bildschirmfoto 2020-05-03 um 15.20.13](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/3/4/34a5789bc01ec5b4dce64b2c52709ecfa526367d.jpeg)

If i try to test the second flow i always get this error:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/4/0/40e6bc4b2ab49e69d978fed47c0ee8dfe3d15ff1.jpeg)

Thanks a lot

---

<div class="post-metadata">

**Author:** ![Erik](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/erik/32/9865_2.png) [@Erik](https://community.homey.app/u/Erik)\
**Post date:** [May 3, 2020, 1:45pm UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/26 "2020-05-03T13:45:21Z")

</div>

Tip: test your expression with [jsonpath.com](http://jsonpath.com)  
With `$.forecasts[0].rainTo` it should take the rainTo value of the first forecast in the dataset.

---

<div class="post-metadata">

**Author:** ![Philipp\_Karl](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/philipp_karl/32/12702_2.png) [@Philipp\_Karl](https://community.homey.app/u/Philipp_Karl)\
**Post date:** [May 3, 2020, 2:02pm UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/27 "2020-05-03T14:02:39Z")

</div>

i’m getting this error?

![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/6/26a15c63d6530dd797ad8d50a104a38cac891a32.png)

thanks

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [May 3, 2020, 5:30pm UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/28 "2020-05-03T17:30:05Z")

</div>

This is not an Error, this is a Test command.

---

<div class="post-metadata">

**Author:** ![Philipp\_Karl](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/philipp_karl/32/12702_2.png) [@Philipp\_Karl](https://community.homey.app/u/Philipp_Karl)\
**Post date:** [May 3, 2020, 6:52pm UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/29 "2020-05-03T18:52:17Z")

</div>

Hello @erik,

thanks ist works.  
could you help me to extract the variable in yellow?

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/c/1/c1b576da331013025f3fda73ef6070c310816e41.png)

Thanks a lot

---

<div class="post-metadata">

**Author:** ![Philipp\_Karl](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/philipp_karl/32/12702_2.png) [@Philipp\_Karl](https://community.homey.app/u/Philipp_Karl)\
**Post date:** [May 3, 2020, 6:56pm UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/30 "2020-05-03T18:56:15Z")

</div>

Hello,

how can i visualize the extracted variabale to controll if the variable is right?

is there any other way instead of using betterlogic, there are now the logics of homey, i always use them and want to continue using them?

@Erik : do you think to realize this in your app für http requests?

thanks

---

<div class="post-metadata">

**Author:** ![Philipp\_Karl](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/philipp_karl/32/12702_2.png) [@Philipp\_Karl](https://community.homey.app/u/Philipp_Karl)\
**Post date:** [May 3, 2020, 8:23pm UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/31 "2020-05-03T20:23:50Z")

</div>

hello,

for what can i use this? what is trigger for T80?

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/c/e/ced1b7cac1b8a4da20ab9c5ed36f6a9a1365e63e.png)

thanks

---

<div class="post-metadata">

**Author:** ![Erik](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/erik/32/9865_2.png) [@Erik](https://community.homey.app/u/Erik)\
**Post date:** [May 4, 2020, 6:33am UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/32 "2020-05-04T06:33:06Z")

</div>

That would be `$.forecasts[0].symbol.description`  
(agian, its easy to check you jsonpath expression on [jsonpath.com](http://jsonpath.com))

---

<div class="post-metadata">

**Author:** ![Erik](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/erik/32/9865_2.png) [@Erik](https://community.homey.app/u/Erik)\
**Post date:** [May 4, 2020, 6:34am UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/33 "2020-05-04T06:34:19Z")

</div>

I tried to implement native homey variables, but the App toolkit didn’t allowed it (at least it wasn’t a year ago)

---

<div class="post-metadata">

**Author:** ![Philipp\_Karl](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/philipp_karl/32/12702_2.png) [@Philipp\_Karl](https://community.homey.app/u/Philipp_Karl)\
**Post date:** [May 4, 2020, 7:01am UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/34 "2020-05-04T07:01:14Z")

</div>

maybe you could retry? 🙂

---

<div class="post-metadata">

**Author:** ![Erik](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/erik/32/9865_2.png) [@Erik](https://community.homey.app/u/Erik)\
**Post date:** [May 4, 2020, 8:13am UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/35 "2020-05-04T08:13:25Z")

</div>

Unfortunantly nothing has changed, so its still not possible to retreive and set native variables from an app.  
([https://github.com/athombv/homey-apps-sdk-issues/issues/27](https://github.com/athombv/homey-apps-sdk-issues/issues/27))

---

<div class="post-metadata">

**Author:** ![Philipp\_Karl](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/philipp_karl/32/12702_2.png) [@Philipp\_Karl](https://community.homey.app/u/Philipp_Karl)\
**Post date:** [May 4, 2020, 8:33am UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/36 "2020-05-04T08:33:31Z")

</div>

hello @Erik,

if i use the JSONpath for trigger ist possbile to eliminate the betterlogic an wrtite in the standard logics from homey? What ist the trigger for T80?

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/5/b5c4dc71bb78c5fa679363179433b74db23d5c94.png)

thanks a lot and fpr your patience 🙂

---

<div class="post-metadata">

**Author:** ![Philipp\_Karl](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/philipp_karl/32/12702_2.png) [@Philipp\_Karl](https://community.homey.app/u/Philipp_Karl)\
**Post date:** [May 4, 2020, 9:28am UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/37 "2020-05-04T09:28:46Z")

</div>

@Erik or with this variable?

Could this be a solution? I don’t know how to realise that:

[https://homey.app/f/kyw0v7](https://homey.app/f/kyw0v7)

Thanks

---

<div class="post-metadata">

**Author:** ![Erik](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/erik/32/9865_2.png) [@Erik](https://community.homey.app/u/Erik)\
**Post date:** [May 4, 2020, 9:43am UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/38 "2020-05-04T09:43:37Z")

</div>

Looks like the existing condition card _C22_

> Extract and check a specific value from a JSON or XML formatted GET response. This card expects a JSONpath expression.

---

<div class="post-metadata">

**Author:** ![Philipp\_Karl](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/philipp_karl/32/12702_2.png) [@Philipp\_Karl](https://community.homey.app/u/Philipp_Karl)\
**Post date:** [May 4, 2020, 9:59am UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/39 "2020-05-04T09:59:40Z")

</div>

could you help me to test this, i’m not able to isner the correct expressions?

---

<div class="post-metadata">

**Author:** ![Erik](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/erik/32/9865_2.png) [@Erik](https://community.homey.app/u/Erik)\
**Post date:** [May 4, 2020, 10:39am UTC](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445/40 "2020-05-04T10:39:24Z")

</div>

What is the exact condition you want to evaluate?

[Previous page](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445.md?page=1)

[Next page](https://community.homey.app/t/calling-an-external-service-and-receiving-the-response-in-a-variable/12445.md?page=3)
