# How to get tibber power from API as a variable

**URL:** <https://community.homey.app/t/how-to-get-tibber-power-from-api-as-a-variable/96797>\
**Category:** Questions & Help\
**Tags:** homeyscript, homey-pro\
**Created:** [December 4, 2023, 5:41pm UTC](https://community.homey.app/t/how-to-get-tibber-power-from-api-as-a-variable/96797 "2023-12-04T17:41:56Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ostys](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ostys/32/71829_2.png) [@Ostys](https://community.homey.app/u/Ostys)\
**Post date:** [December 4, 2023, 5:41pm UTC](https://community.homey.app/t/how-to-get-tibber-power-from-api-as-a-variable/96797/1 "2023-12-04T17:41:56Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![DirkH](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkh/32/78952_2.png) [@DirkH](https://community.homey.app/u/DirkH)\
**Post date:** [December 10, 2023, 3:54pm UTC](https://community.homey.app/t/how-to-get-tibber-power-from-api-as-a-variable/96797/2 "2023-12-10T15:54:32Z")

</div>

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](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/9/5984818fd2e4deaba5bfe2550db76bd9c47ef26f.jpeg)

---

<div class="post-metadata">

**Author:** ![Ostys](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ostys/32/71829_2.png) [@Ostys](https://community.homey.app/u/Ostys)\
**Post date:** [December 10, 2023, 4:50pm UTC](https://community.homey.app/t/how-to-get-tibber-power-from-api-as-a-variable/96797/3 "2023-12-10T16:50:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DirkH](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkh/32/78952_2.png) [@DirkH](https://community.homey.app/u/DirkH)\
**Post date:** [December 11, 2023, 9:57am UTC](https://community.homey.app/t/how-to-get-tibber-power-from-api-as-a-variable/96797/4 "2023-12-11T09:57:34Z")

</div>

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

 ![Prüfe ob Pulse erreichbar](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/e/e/ee99ec08e32611be691d3adb911847cd8d26370b.jpeg)  
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.

---

<div class="post-metadata">

**Author:** ![Ostys](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ostys/32/71829_2.png) [@Ostys](https://community.homey.app/u/Ostys)\
**Post date:** [December 11, 2023, 4:39pm UTC](https://community.homey.app/t/how-to-get-tibber-power-from-api-as-a-variable/96797/5 "2023-12-11T16:39:57Z")

</div>

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:

 ![Screenshot_20231211-112903](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/6/d678b587dabd7ca07ebc498173ec9b126b215fba.png)

Same at the consumption… the consumption ist standing still:  
 ![Screenshot 2023-12-11 173053](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/9/8958e755ab791fb893ae7224f3f5c8397fd63631.png)

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 😉 Hab Deine Flow-Cards in deutsch gesehen.

---

<div class="post-metadata">

**Author:** ![Ostys](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ostys/32/71829_2.png) [@Ostys](https://community.homey.app/u/Ostys)\
**Post date:** [December 11, 2023, 5:12pm UTC](https://community.homey.app/t/how-to-get-tibber-power-from-api-as-a-variable/96797/6 "2023-12-11T17:12:46Z")

</div>

Think, something like this could work:

 ![Screenshot 2023-12-11 180723](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/7/c/7c7329d43941de1cb1e3fa916f4130c2219c608b.png)

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:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/3/1/31e6d327b64fec090b0a2a26dc6fd10206c360a9.png)

My first tests were fine …

---

<div class="post-metadata">

**Author:** ![DirkH](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkh/32/78952_2.png) [@DirkH](https://community.homey.app/u/DirkH)\
**Post date:** [December 12, 2023, 1:26pm UTC](https://community.homey.app/t/how-to-get-tibber-power-from-api-as-a-variable/96797/7 "2023-12-12T13:26:30Z")

</div>

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.

 ![Prüfe ob Pulse aktiv](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/5/f5f011e20147d328d14cf1b218a334c70f2e02bf.jpeg)  
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

---

<div class="post-metadata">

**Author:** ![Ostys](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ostys/32/71829_2.png) [@Ostys](https://community.homey.app/u/Ostys)\
**Post date:** [December 13, 2023, 5:25am UTC](https://community.homey.app/t/how-to-get-tibber-power-from-api-as-a-variable/96797/8 "2023-12-13T05:25:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![DirkH](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkh/32/78952_2.png) [@DirkH](https://community.homey.app/u/DirkH)\
**Post date:** [December 13, 2023, 7:04am UTC](https://community.homey.app/t/how-to-get-tibber-power-from-api-as-a-variable/96797/9 "2023-12-13T07:04:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ostys](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ostys/32/71829_2.png) [@Ostys](https://community.homey.app/u/Ostys)\
**Post date:** [December 13, 2023, 5:21pm UTC](https://community.homey.app/t/how-to-get-tibber-power-from-api-as-a-variable/96797/10 "2023-12-13T17:21:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![To\_Lou](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/to_lou/32/79159_2.png) [@To\_Lou](https://community.homey.app/u/To_Lou)\
**Post date:** [December 14, 2023, 6:30pm UTC](https://community.homey.app/t/how-to-get-tibber-power-from-api-as-a-variable/96797/11 "2023-12-14T18:30:31Z")

</div>

My take on this.

 ![Screenshot_20231214_192539_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/6/9/69ce39d43497604735587087baa88aaaaa51d8c7.jpeg)  
 ![Screenshot_20231214_192555_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/0/f0904417a3e8755612411a9b95c9822bad9a5692.jpeg)

---

<div class="post-metadata">

**Author:** ![Ostys](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ostys/32/71829_2.png) [@Ostys](https://community.homey.app/u/Ostys)\
**Post date:** [December 15, 2023, 1:08pm UTC](https://community.homey.app/t/how-to-get-tibber-power-from-api-as-a-variable/96797/12 "2023-12-15T13:08:39Z")

</div>

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

thx

---

<div class="post-metadata">

**Author:** ![To\_Lou](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/to_lou/32/79159_2.png) [@To\_Lou](https://community.homey.app/u/To_Lou)\
**Post date:** [December 15, 2023, 2:48pm UTC](https://community.homey.app/t/how-to-get-tibber-power-from-api-as-a-variable/96797/13 "2023-12-15T14:48:11Z")

</div>

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