Attribute "Price" for power in SA or DH


Getting there…


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.


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


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


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


@ady624 reverted, and now it works.


@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.


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


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


Here is an example of accessing the data, you will need to use that $[0] mess I posted earlier inside an expression to access the data:

You can assign $[0], $[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 $ 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. because it looks for a variable with the name 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:


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


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


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?


I don’t think there’s currently a way to assign to an array variable in the way that you want to. Ideally you would set TibberPrHr = some array and then be able to access TibberPrHr[0] TibberPrHr[1] etc. like you can on the data in $response. Instead you would have to use a loop to set the values individually which probably gets too complex.

There are a couple possible ways to deal with that kind of data but it depends what your goal is for using the variable – does the variable serve as a snapshot of the pricing data that you want to reference later, are you keeping tracking of price over time in the array, will it always be the same number of items (like one price for each hour of the day), etc.


So, after following all the advice given here, I now have a piston that can get electricity prices for each hour of the day and put that into a variable. It is displayed like this:

|+94ms|║║Sending external web request to:|
|+244ms|║║Executed virtual command httpRequest (160ms)|
|+251ms|║║[0.3744, 0.3733, 0.3734, 0.3682, 0.3734, 0.3805, 0.3935, 0.3961, 0.3959, 0.3956, 0.3986, 0.3999, 0.3994, 0.3981, 0.3997, 0.4008, 0.4065, 0.4062, 0.4009, 0.3965, 0.3919, 0.3882, 0.3781, 0.3733]|

However, I do not know how to put these different price points into different variables (grouped as: 01:00-02:00 = 0.3986).

Now what I ultimately want to do is to lower house heating during high price points IF electric prices goes down the next hour (or the next after that). This would reduce cost per kw. This could also be used as a means to charge your electric car during “the cheapest hours in the night”. I am uncertain as to how the logic would be set up within webCoRE in order to achieve this. Any tips is greatly appreciated!