question

tijntert avatar image
tijntert asked

Node RED & Tibber API how to use/find 3 types of prices?

hey y'all,


Im new to NodeRED, but getting there... now I want to use the Tibber API to get some data :D

but, how? mmmhhh...


Can find, show (right side, via debug) some data... but what I want is to know how to use that in a flow...

this for:

* lowest price of the next day. At the moment I can only find all of the next day price, debug.

* highest price of the day

* current price


Could someone please give me a flowExample, so I can see/figure out how to do this?



thx in advance :D

Node-REDapi
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

1 Answer
matt1309 avatar image
matt1309 answered ·

Hi @Tijntert

It's probably easier to watch a few node red guides first. However as a high level guide.

I cant help with Tibber api specifics but i can explain how you use the data in a flow.

Can you provide an example of what the data looks like from Tibber please?





3 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

tijntert avatar image tijntert commented ·

thx :D but also for this, getting there...

and indeed, watch * infinity = know... ;)


example:

const homes = msg.payload.viewer.homes;

if (!homes || homes.length === 0) {

node.error('No homes found in the payload.');

return null;

}


const tomorrowPrices = homes[0].currentSubscription.priceInfo.tomorrow;

if (!tomorrowPrices || tomorrowPrices.length === 0) {

node.error('No prices for tomorrow, yet.');

return null;

}


let lowestPriceLP = Math.min(...tomorrowPrices.map(p => p.total));


if (isNaN(lowestPriceLP)) {

node.error('Lowest price is Not-a-Number.');

return null;

}


// only lowestPriceLP to msg.payload

msg.payload = lowestPriceLP;


return msg;

0 Likes 0 ·
Show more comments