How update variable using API

I would like to update the value of a variable (on a specified time), using info from weatherapi.com api.

URL to make request would be like http://api.weatherapi.com/v1/current.json?key=350b99ec007341fa...&q=51.976920,6.821056&aqi=no

That would return:

{
    "location": {
        "name": "Vreden",
        "region": "Nordrhein-Westfalen",
        "country": "Germany",
        "lat": 51.98,
        "lon": 6.82,
        "tz_id": "Europe/Amsterdam",
        "localtime_epoch": 1676405375,
        "localtime": "2023-02-14 21:09"
    },
    "current": {
        "condition": {
            
        },
        "cloud": 0,
        "uv": 1.0
    }
}

I would like to assign the value of attribute current->cloud to a variable in a homey flow.

How to do that?

Here some links that will help Link1

Link2

I would like to stick to homey flow logic as much as possible instead of writing scripts, as seems to be the case in those posts.

I thought probably using ‘make a http-request’ block in logic could help, in combination with ‘webhook event received’ block also in logic to trigger the flow. But I get lost in how to properly use those blocks.

Would that be the preferred way to go and if yes any suggestions on how to actually use these blocks? Code / flow examples?

This will do the job i think Link

Thanks. I see that that flow uses the app ‘HTTP request flowkaarten’, which however is only available for Homey Pro, not for Homey bridge. Can things like this also be done without this app?

I thought maybe it can help to extract the value in a script and pass that on to the homey webhook server. But I don’t know if this is necessary and I don’t know how to pass that value. Script would be something like this so far:

<?php
    $curlHandle = curl_init('http://api.weatherapi.com/v1/current.json?key=350b99ec007341fa...&q=51.976920,6.821056&aqi=no');
    curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curlHandle, CURLOPT_HEADER, 1);
    
    $curlResponse = curl_exec($curlHandle);
    $header_size = curl_getinfo($curlHandle, CURLINFO_HEADER_SIZE);
    $header = substr($curlResponse, 0, $header_size);
    $body = substr($curlResponse, $header_size);
    
    $obj = json_decode($body);
    $cloud = $obj->current->cloud;
    curl_close($curlHandle);
    
    $curlHandle = curl_init();
    curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
    // how pass $cloud to homey?
    curl_setopt($curlHandle, CURLOPT_URL, 'https://webhook.homey.app/63c2b40013a.../cloud_update?tag=cloud');
    $content = curl_exec($curlHandle);
    echo $content;

?>

Do you have the default Homey Logic Flowcard: Create a type-request to URL with body etc.?
image

Because you can just use that one:
Set it to GET, fill in the URL with the correct key and i think it whould work.
I get and 403 - Forbidden because of the Key).

The result you can read with the Default homey Logic JSON cards.

Yes i have the default 'create a type-request to URL etc flowcard. However I do not find the JSON card. Where can I find that?

Ah, i see you dont have that on the Cloud.
Can you install HomeyScript?

Not available for Homey Cloud.

And advanced flows?
Because only AF have the json cards i guess.

This is what i see under flows

However I do have the possibility to receive a webhook, just don’t know how to use it to receive a value.

No, i dont mean specific cards, but the flow type. On homey pro we have Advanced Flows, but im not sure Cloud has that.
And without, i don’t see a way to save the response.

Indeed, there’s no Adv. flow available on Homey cloud.

This card is available on Homey C

Not sure how to feed it with the results of the ‘Make HTTP request…’ card in standard flows
(can’t test it, I’ve no premium, so Logics cards are disabled).
Maybe you’ll have to save the returned data in a user string variable

I don’t see that card with his screenshot.

That is correct while it is quite a list:
Peek 2023-02-15 21-14

It doesn’t seem possible (yet), while the result of the GET request card is not available in Homey Cloud so it seems.

As example, I can’t pick a local tag for [Text] here:
Screenshot from 2023-02-15 22-35-54

See post 8 above: I don’t have a long list of logic cards but only six. No JSON among them.