Problem reading temperature from ngenic via HTTP GET

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!

Hi its not working for me, se below pictures.

First when i add the condition to check the value is 200 it give me false.

If i skipp the AND card and go stright to analyse i get “Unexpected end of JSON input”
image

When i compare your pictures with mine its identical! Can someone help me out?

Thanks!

It’s there for a reason, namely to check if the server turns an “okay” response, which apparently it doesn’t. We don’t know why. Log the status code to a notification, perhaps it provides a clue.

The status code i get is 401

That’s an authorization error, so probably something to do with the token you’re passing.

Thanks!

It’s finaly working, not sure what was wrong but i created a new token and now it seems to work!