How to get tibber power from API as a variable

Hello,
i need help to get current power from the tibber api every “x” minutes to check, if the bridge has a connection to tibber.
The current power should be set as a variable. If the value isn’t true (no connection), the value should be “0”.

I have connection to tibber with the HomeyScript (i know my Token and my Home-ID):
const accessToken = “zyx”;

fetch(‘https://api.tibber.com/v1-beta/gql’, {
method: ‘POST’,
headers: {
‘Content-Type’: ‘application/json’,
‘Authorization’: Bearer ${accessToken}

But I only have a connection for price info, name, location … but no connection for current power and I’m not able (at the moment) to set the value as a variable…

The tibber API-Explorer gives me this at GraphiQL:
subscription{
liveMeasurement(homeId:“xyz”){
timestamp
power
accumulatedConsumption
accumulatedCost
currency
minPower
averagePower
maxPower
}
}

How can i get the power as a variable?
Is it possible to get this information with the logik-card “Make a ‘Method’ …”

Thanks a lot! Greating Osty

Hi @Ostys ,
I have no clue, how to get it via tibber api - I use the Tibber App and created two devices, the tibber device and the pulse device.
The actual power and consumption since midnight I get from the pulse device.
Tibber devices on Homey

Thanks @DirkH for your answer.

My problem is that the bridge lost the connection 2 time within 7 days and i had to pay for the high-price-hours …
Do you have an idea how to monitor the bridge connection?

Thanks again.

Hi @Ostys ,
probably such a test could work. I do not want to test it as long as my Pulse works fine.


You may check the error in any advanced flow and do a push notification or other message to you.
I lost my Pulse once. And it is bad enough that you need to amend all cards referring to the Pulse and to check carefully about the parameters.

Hi @DirkH ,

thanks for your idea. But that won’t work. When the Bridge is offline, the pulse shows the last value… for hours like here:

Same at the consumption… the consumption ist standing still:
Screenshot 2023-12-11 173053

I thought that homey is getting these values directly from the pulse and not over the bridge from the tibber backend / tibber API.

But that’s the basis to get the solution …
I’ll set a variable every time and do a comparison to the value at the moment … if it’s different, everything is fine. Are both values the same, the brigde is offline.

I’ll create a flow now, will test it and post it here (if it works).

See you later!
Osty

@DirkH : Besten Dank nochmals für den Ansatz und viel Grüße aus dem Münsterland :wink: Hab Deine Flow-Cards in deutsch gesehen.

Think, something like this could work:

Although the test for the power is not necessary. But nice to have …

It’s also possible with a standard-flow and the homey bridge:

My first tests were fine …

Hi @Ostys ,
What do you think of this solution? Usually Pulse delivers another power value several times every minute. So when there is no change for some time, either you have a blackout (battery backup works) or you lost somewhere the connection to Pulse, either by tibber or by Homey. I had these chart on my tibber smartphone app for some time, but when the connection was re-established the charts in the tibber smarthome app were corrected. So it may be an issue in between tibber and not between tibber and homey.


I am not sure if I understand Chronograph correct - so I did not get a message yet.

Schöne Grüße aus dem Raum Trier

1 Like

Hi @DirkH ,
i also don’t know what the chronograph is doing.

With your solution you only start the flow if the consumption changed. But i need an action if the consumption didn’t change. And you can only use this card to start a flow, not as an “AND” - card.

The flow is also running several times a minute. It starts every time, the consumption and the power-variable changed. I’m trying to reduce the CPU load as much as possible. It’s not needed at the moment but who knows what is coming the next years …

My flow is still working fine. Yesterday another test was positiv.

@DirkH , you have given me the starting point for the solution that I am happy with. Thanks a lot for your help.

I’ll close my question in a few hours. Have a good day and stay healthy.

Osty

Hi @Ostys ,
My flow starts, when the consumption changes, but does nothing else but setting the timer to ring after 3 minutes. If there is a new change in consumption the timer will be restarted and nothing happens. Only when there is no change for 3 minutes, the timer expires and the second part gives me a hint to watch.
I guess that is exactly what you want.

1 Like

Yes @DirkH , you’re right. That’s really the solution i needed.
I’m sure that it’s also working.

So, it’s another good solution for the “problem”. Thanks a lot for your help!

Osty

My take on this.


Hi @To_Lou ,
what kind of smart meter do you have? It’s not the Tibber Pulse, is it?

thx

Yes, but feeding data into PBTH Energy app. That’s what matters to me.