Attribute "Price" for power in SA or DH


#14

I’m not sure you understand the implications of writing a SA/DH just to get data from an API. I also don’t think the power company / API provider will care what platform you are pulling their data into UNLESS you are doing it for commercial gain.

In any event, good luck!


#15

this would be fairly easy to do assuming you already know your rate code if the power companies provide an api to poll for the reading and rate data.


#16

So @jeffh0821 is this something I could do as a GET (Total) ? as long as i got the token?
Major ditance away from my line of work :wink:
Give me an router, firewall, switch and we will talk about it… hehe

{
viewer {
homes {
currentSubscription{
priceInfo{
current{
total
energy
tax
startsAt
}
}
}
}
}
}


#17

Based on that data after doing the GET request you would access the total value using an expression based on $response.*, like this:

$response.data.viewer.homes[0].currentSubscription.priceInfo.current.total

#18

Thx a bunch @ipaterson closing up to something here
Got a demo token to play with, and think i am near goal.
This in curl om my mac works:
curl
-H “Authorization: Bearer d1007ead2dc84a2b82f0de19451c5fb22112f7ae11d19bf2bedb224a003ff74a”
-H “Content-Type: application/json”
-X POST
-d ‘{ “query”: “{viewer {homes {currentSubscription {priceInfo {current {total energy tax startsAt }}}}}}” }’ https://api.tibber.com/v1-beta/gql

And tring to make a piston with the folowing as input.
Cant seme to save this as a variable, some syntax error.
The piston is NO share, Yeah i know, but this i a demo thingy :slight_smile:
This is the input i cant save:
Data : { “query”: “{viewer {homes {currentSubscription {priceInfo {current {total energy tax startsAt }}}}}}” }
Any idea?

Piston under.


#19

It looks like you will need a string variable named query with the value \{viewer \{homes \{currentSubscription \{priceInfo \{current \{total energy tax startsAt \}\}\}\}\}\} where the backslashes stop webCoRE from trying to pick out expressions. You can provide that query variable in the data for the request, then the token (including “Bearer”) in the authorization header input.

Also highly recommend censoring your post if that’s a permanent token.


#20

YOU DA MAN!!!
Works.
I am realy thankfull.
And yeah, I would never share anything with my own info.
I got a demo token from the vendor to test things, but anonymous piston kinda removed my url so i might have errors in that also.
Next up to get values into different variables.
Once again, thank you!!!
:snowman:


#21

Getting there…
03


#22

Hehe @ipaterson
Upgraded to the new build today.
And it stopped working.
Did you notice any changes on latest build?
@ady624 might want to know also.


#23

Ok, will have to look at that deeper. The list is a boolean, argh


#24

@ady624 I’m not very familiar with groovy, does findAll( !!it ) need curly braces to make that arg a closure rather than boolean?


#25

Was my intention to start digging into this tonight.
Not my cup of tea, but it seemes Adrian suspect something broke in last build.
:snowman:


#26

@ady624 reverted, and now it works.
F.Y.I
:snowman_with_snow:


#27

@ady624 yep this needs to be changed to for(variable in variables.findAll{ !!it }) { to avoid the exception; current version breaks any web request that uses variables.


#28

Shoot, yeah, curly braces are required, not () - my mistake… republished the app under the same version (not forcing everyone to update). Sorry :smiley:


#29

So if i understand this right.
My web call gets an array?
Do you by any case have an example on how you fill the array, and how to acces them?
Yeah laugh along :slight_smile:
Mine did not work :smiley: haha


#30

Here is an example of accessing the data, you will need to use that $response.data.viewer.homes[0].currentSubscription.priceInfo.current.total mess I posted earlier inside an expression to access the data:

You can assign $response.data.viewer.homes[0].currentSubscription.priceInfo.current.total, $response.data.viewer.homes[0].currentSubscription.priceInfo.current.startsAt, etc. to variables so that you don’t need to type the whole thing in multiple places.

I don’t think you will be able to assign any of the higher level $response data like $response.data.viewer.homes to a variable. There is some special sauce to support accessing those properties of $response and it does not apply to normal variables. For example, you can assign it to a dynamic current variable, but then you can’t use that variable like an array (e.g. current.tax) because it looks for a variable with the name current.tax rather than a variable current with item tax. You also can’t assign it to a dynamic[] current list variable because there is no way to assign entire lists, can only assign a value at a specific index:


#31

You are hereby my hero.
I started fooling around with a string, thinking, convert to decimal later.
This solved this at once.


#32

Sorry - real life took over for a bit. Looks like you made excellent progress. And without a SA/DH! Congratulations!


#33

Yeah things starts to work out.
On thing i just cant seeme to sort out is now to get a array to give med decimals.
Tried different ways, but end up geting strings.
Any clue to this?