Possible to use JSON respons from a CURL command as a variable?

Hi!

I wonder if it is possible to do the following… I have a CURL command which retrieves some JSON data:

curl -f -k -H 'Accept: application/json' -H 'Authorization: Bearer MyTokenHere -X GET https://envoy.local/api/v1/production

This gets this response (from my solar panels):

{
  "wattHoursToday": xxx,
  "wattHoursSevenDays": yyy,
  "wattHoursLifetime": zzz,
  "wattsNow": abc
}

Now I’d like to have the ‘abc’ number as a variable to use in other flows…

I’m a bit lost cause this is all new to me, but maybe someone can point me in the right direction?

1 Like

Something like this?

1 Like

Thanks!

Almost works… I get a response "failed, reason: self signed certificate’

With the cURL command, I can use -k to ignore this, no idea if this is possible in Homey?

rejectUnauthorized: false ensures self signed is allowed

You can try it with HomeyScript if you have that installed. There is a Flow card that can run a code snippet and return a text token.

Hard when this is no longer available under Homey Pro 2023

You should tell the developer of the app.

Just use logical en use GET then put in the URL https://envoy.local/api/v1/production header Accept: application/json
Authorization: “Bearer Mytokenhere”
Cache-Control: no-cache
Host: bearer
Accept-Encoding: gzip, deflate, br
Connection: keep-alive

Don’t you need to add a variable in the body ?

A body in a GET request doesn’t make a lot of sense. Also, don’t use that particular Accept-Encoding header since Homey’s Logic card cannot handle compressed responses.