Problem reading temperature from ngenic via HTTP GET

I get stuck trying to read the temperature sensors connected to ngenic.
I’ve found the token and room and sensor uuid and get a CURL GET to work on my MAC in terminal.

But I don’t get it how to translate that to a HTTP GET in Homey…
Any suggestions??

curl command
curl -X GET
-H “Authorization: Bearer abcd1234PRIVATETOKENabcd1234”
https://app.ngenic.se/api/v3/tunes/{f3e2e629-8eb9-ec11-997e-e42aac6e0f30}/measurements/{0687242c-75cc-ec11-997e-e42aac6e0f30}/latest?type=temperature_C

response:
{“hasValue”:true,“time”:“2022-09-20T16:25:28 Europe/Stockholm”,“value”:21.5625}%

were “value” is the current temperature.

The problem is it isn’t a proper json file. The quotation marks should be " and not “. A slight problem but that’s the reason it doesn’t work. The json file should be like this:

if you have the option to download a proper json file it will work otherwise you have to adjust the file.

Maybe you have a method to adjust this file on your computer, otherwise it is maybe possible to adjust the file wirh homeyscript

I believe there is still a problem with the GET function…
Since I don’t get a reply in Homey only error… There is something with the syntax of the GET command I think…

Yours is broken too, thanks to this great forum software :stuck_out_tongue:

1 Like

Hahaha, i saw it and added s printscreen so you can see what the problem is🤓

You’re not answering my question here…
@robertklep - Is this something you can help med with?

That’s what the </> button is for :wink:

{
    "hasValue":true,
    "time":"2022-09-20T16:25:28 Europe/Stockholm",
    "value":21.5625
}

@Roger_Levenrot
But not showing what you already have as “get” flow cards is kinda difficult to say what is wrong.

You have to use the “HTTP request flow cards” app, which allows you to extract values from a JSON response (just don’t ask me how to use it :sweat_smile:).

Maybe this can help a little bit

{ "method":"get","protocol":"https:","hostname":"app.ngenic.se","port":443,"path":"/api/v3/tunes/{f3e2e629-8eb9-ec11-997e-e42aac6e0f30}/measurements/{0687242c-75cc-ec11-997e-e42aac6e0f30}","headers":{"authorization":"Bearer XYXYMYTOKENXYXY","content-type":"application/json"}}{"value":
varTemp}

Homey Pro 2022-09-22 14-47-09

Homey Pro 2022-09-22 14-49-03

Working curl command…
Highlighted value in green is the value I am trying to retrieve!

Haven’t used the http app in a while, the build in logic send http card had seperate inputs for URL, body and headers, when I’m at home I can give you an example.

1 Like

You can’t extract content from the responses with the built-in Logic card.

As long as the response is JSON, yes you can, with Homey advance flows it is really easy.

1 Like

this should do it:

URL:

https://app.ngenic.se:443/api/v3/tunes/{f3e2e629-8eb9-ec11-997e-e42aac6e0f30}/measurements/{0687242c-75cc-ec11-997e-e42aac6e0f30}/latest?type=temperature_C

Header:

{ "authorization":"Bearer XYXYMYTOKENXYXY", "content-type":"application/json" }

Edit:
if you want to be safe (if their service is offline for example, kinda forgot to add it into the example flow), you can add another “AND” card between the request and reading the JSON, and see if the “status code” (number) is 200
status 200

1 Like

Hi!
Thanks for helping!
Something wrong with the Header…
Homey Pro 2022-09-23 08-24-15

Please try “Authorization” and “Content-Type” with capital letter. Perhaops the Logic is checking case sentive.

Source: HTTP headers - HTTP | MDN

The issue is that the example is showing the headers in JSON format, while they should be in plain text (with line breaks in between the different headers).

2 Likes

Thank you very much!
Great help!!

Complete solution

HTTP GET request to:
https://app.ngenic.se:443/api/v3/tunes/{tuneUuid}/measurements/{nodeUuid}/latest?type=temperature_C

Headers:
Authorization: Bearer xyxyMYTOKENxyxy

Visit https://developer.ngenic.se on how to retrieve your personal token and “tuneUuid” and “nodeUuid”

Hi i managed to get my Authorization: Bearer, tuneUuid and uuid.
But i dont get how to add it to logic or to HTTP request flow cards.

Can anyone share some exampels from homey?

Thanks!

This works for me!