# Script for daily fetching fee data from tibber (ie clock hour of daily max and min)

**URL:** <https://community.homey.app/t/script-for-daily-fetching-fee-data-from-tibber-ie-clock-hour-of-daily-max-and-min/144485>\
**Category:** Questions & Help\
**Tags:** homey-pro\
**Created:** [October 24, 2025, 11:16am UTC](https://community.homey.app/t/script-for-daily-fetching-fee-data-from-tibber-ie-clock-hour-of-daily-max-and-min/144485 "2025-10-24T11:16:44Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harry\_Westerbeek](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harry_westerbeek/32/115221_2.png) [@Harry\_Westerbeek](https://community.homey.app/u/Harry_Westerbeek)\
**Post date:** [October 24, 2025, 11:16am UTC](https://community.homey.app/t/script-for-daily-fetching-fee-data-from-tibber-ie-clock-hour-of-daily-max-and-min/144485/1 "2025-10-24T11:16:45Z")

</div>

Hi,

Asked ChatGPT; came up with something which didn’t work. Anybody around here who has a working script?

Regards,

Harry

---

<div class="post-metadata">

**Author:** ![TonS](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tons/32/48145_2.png) [@TonS](https://community.homey.app/u/TonS)\
**Post date:** [October 25, 2025, 4:14pm UTC](https://community.homey.app/t/script-for-daily-fetching-fee-data-from-tibber-ie-clock-hour-of-daily-max-and-min/144485/3 "2025-10-25T16:14:40Z")

</div>

This script will get the data from Tibber.

The first 3 lines refer to the variables that hold the data, apikey and url.

```auto

const tibberVarId = "138521c4-1eb9-4027-a224-cd9f861fbb3f"; // TibberPriceData
const apiKeyVarId = "25349750-2371-40b4-a635-ce60be3f40be"; // Tibber_api_key
const apiUrlVarId = "dd2ff110-db1e-4126-a960-99770614f905"; // tibber_API_URL

// Get API key and URL from Homey variables
const apiKeyVar = await Homey.logic.getVariable({ id: apiKeyVarId });
const apiUrlVar = await Homey.logic.getVariable({ id: apiUrlVarId });

const tibberApiKey = apiKeyVar.value;
const tibberApiUrl = apiUrlVar.value;

if (!tibberApiKey || !tibberApiUrl) {
  throw new Error("Missing Tibber API key or URL in Homey variables.");
}

// Tibber GraphQL query
const query = {
  query: `{ 
    viewer { 
      homes { 
        currentSubscription { 
          priceInfo (resolution: QUARTER_HOURLY) {
            today { 
              total 
              startsAt 
            } 
          } 
        } 
      } 
    } 
  }`
};

// Fetch data from Tibber
const response = await fetch(tibberApiUrl, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${tibberApiKey}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(query)
});

if (!response.ok) {
  throw new Error(`HTTP error! status: ${response.status}`);
}

const data = await response.json();

// Convert the full result to a string for storage
const tibberPriceData = JSON.stringify(data);

// Update the Homey variable
await Homey.logic.updateVariable({
  id: tibberVarId,
  variable: { value: tibberPriceData }
});

console.log("TibberPriceData variable updated successfully.");

```

---

<div class="post-metadata">

**Author:** ![Harry\_Westerbeek](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harry_westerbeek/32/115221_2.png) [@Harry\_Westerbeek](https://community.homey.app/u/Harry_Westerbeek)\
**Post date:** [October 25, 2025, 5:14pm UTC](https://community.homey.app/t/script-for-daily-fetching-fee-data-from-tibber-ie-clock-hour-of-daily-max-and-min/144485/4 "2025-10-25T17:14:56Z")

</div>

Hi Ton,

Thanks! Will give it a try by coming Monday.

So no specific Tibber account or contract info required?

Can I fetch hourly data by changing `QUARTER\_HOURLY`into``HOURLY`

Regards,

Harry Westerbeek

---

<div class="post-metadata">

**Author:** ![TonS](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tons/32/48145_2.png) [@TonS](https://community.homey.app/u/TonS)\
**Post date:** [October 25, 2025, 5:28pm UTC](https://community.homey.app/t/script-for-daily-fetching-fee-data-from-tibber-ie-clock-hour-of-daily-max-and-min/144485/5 "2025-10-25T17:28:46Z")

</div>

You DO need a Tibber account/contract because you will need to get an API key. ([https://developer.tibber.com](https://developer.tibber.com))

But if you do not have an account why do you then want the Tibber prices?

Use the Homey app PowerByTheHour instead.

---

<div class="post-metadata">

**Author:** ![Harry\_Westerbeek](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harry_westerbeek/32/115221_2.png) [@Harry\_Westerbeek](https://community.homey.app/u/Harry_Westerbeek)\
**Post date:** [October 25, 2025, 5:56pm UTC](https://community.homey.app/t/script-for-daily-fetching-fee-data-from-tibber-ie-clock-hour-of-daily-max-and-min/144485/6 "2025-10-25T17:56:18Z")

</div>

Hi,  
I do have a Tibber account, was not aware of this app. It seems to fulfill my need for price data. With this data I can feed my thermostat flow which is to switch off heatpump (within certain T limits) or on on price peaks and valleys.  
Keep you informed.  
Regards,  
Harry

---

<div class="post-metadata">

**Author:** ![Harry\_Westerbeek](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harry_westerbeek/32/115221_2.png) [@Harry\_Westerbeek](https://community.homey.app/u/Harry_Westerbeek)\
**Post date:** [October 26, 2025, 8:41pm UTC](https://community.homey.app/t/script-for-daily-fetching-fee-data-from-tibber-ie-clock-hour-of-daily-max-and-min/144485/7 "2025-10-26T20:41:28Z")

</div>

Hi Ton,

The app is exacty what I needed.

Thanks for providing this solution.

Regards,

Harry

---

<div class="post-metadata">

**Author:** ![drax](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/drax/32/152287_2.png) [@drax](https://community.homey.app/u/drax)\
**Post date:** [January 19, 2026, 12:34pm UTC](https://community.homey.app/t/script-for-daily-fetching-fee-data-from-tibber-ie-clock-hour-of-daily-max-and-min/144485/8 "2026-01-19T12:34:47Z")

</div>

Hi,

Do I need to change the first three ID’s`?  
I do have a Tibber account but get the following when I run the script:

```auto
⚠️ Error: Not Found: VariableLocal with ID 25349750-2371-40b4-a635-ce60be3f40be
    at ManagerDatabase.findEntry (file:///node_modules/@athombv/homey-local/dist/lib/ManagerDatabaseLocal.mjs:15:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
    at async VariableLocal.findEntry (file:///node_modules/@athombv/homey-core/dist/lib/DatabaseEntry.mjs:214:23)

```

If I need to change, where/how can I find them? Web API Playground?

Regards,  
Andreas

---

<div class="post-metadata">

**Author:** ![drax](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/drax/32/152287_2.png) [@drax](https://community.homey.app/u/drax)\
**Post date:** [January 19, 2026, 12:59pm UTC](https://community.homey.app/t/script-for-daily-fetching-fee-data-from-tibber-ie-clock-hour-of-daily-max-and-min/144485/9 "2026-01-19T12:59:00Z")

</div>

Sorry, I realized that this is Variables that I need to create. I have now created them but now I get:  
⚠ Error: HTTP error! status: 400

I guess something is wrong with my Api-Key.  
My URL is set to: [https://app.tibber.com/v4/gql](https://app.tibber.com/v4/gql)

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [January 19, 2026, 1:31pm UTC](https://community.homey.app/t/script-for-daily-fetching-fee-data-from-tibber-ie-clock-hour-of-daily-max-and-min/144485/10 "2026-01-19T13:31:48Z")

</div>

As the script is not formatted as code, it is full of fancy quotes and -double quotes. These are illegal characters in Homeyscript.  
You’ll need them to replace them by using a text editor and use search and replace.  
If you use windos, use the most basic tool like notepad.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [January 19, 2026, 1:33pm UTC](https://community.homey.app/t/script-for-daily-fetching-fee-data-from-tibber-ie-clock-hour-of-daily-max-and-min/144485/11 "2026-01-19T13:33:07Z")

</div>

Hi Ton,

Would you be so kind to format the script the right way?

> [@\[Tip\] Please use Preformatted Text for Logs and Code Blocks for cleaner posts](https://community.homey.app/t/tip-please-use-preformatted-text-for-logs-and-code-blocks-for-cleaner-posts/149488):
>
> To ensure our community can provide the best help, please use Preformatted Text for all technical content. Why Use Preformatted Text? When you paste logs, configuration files, or code snippets as plain text, Discourse often alters the formatting. This makes it difficult to read and can strip away crucial characters needed to diagnose your issue. If you didn’t create it yourself, like logs or JSONs (interviews) paste it as Preformatted Text! For smaller Code, Logs etc. in context of a topic, b…

---

<div class="post-metadata">

**Author:** ![TonS](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tons/32/48145_2.png) [@TonS](https://community.homey.app/u/TonS)\
**Post date:** [January 19, 2026, 3:02pm UTC](https://community.homey.app/t/script-for-daily-fetching-fee-data-from-tibber-ie-clock-hour-of-daily-max-and-min/144485/12 "2026-01-19T15:02:42Z")

</div>

I have reformatted the script as Peter suggested ( was already afraid I did things wrong in the past when I read the announcement of Dirk yesterday 🙈)

However i also get an error 400 when I use your API-url.  
My URL is set to [https://api.tibber.com/v1-beta/gql](https://api.tibber.com/v1-beta/gql)  
See [Tibber Developer](https://developer.tibber.com/docs/guides/calling-api)

---

<div class="post-metadata">

**Author:** ![drax](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/drax/32/152287_2.png) [@drax](https://community.homey.app/u/drax)\
**Post date:** [January 19, 2026, 8:22pm UTC](https://community.homey.app/t/script-for-daily-fetching-fee-data-from-tibber-ie-clock-hour-of-daily-max-and-min/144485/13 "2026-01-19T20:22:04Z")

</div>

Thank you very much. It works for me using the “v1-beta” API-url.

Unfortunately it seems that I need to use the v4 api for what I am trying to achieve.

I am trying to update the State of Charge (SoC) of my electric car using the API as this Tibber SOC Updater for Home Assistant:

> **[GitHub - Elibart-home/tibber\_soc\_updater: Deze custom component voor Home Assistant maakt...](https://github.com/Elibart-home/tibber_soc_updater)**
>
> Deze custom component voor Home Assistant maakt directe verbinding met de Tibber GraphAPI mogelijk, specifiek gericht op het uitlezen en besturen van elektrische voertuigen. De integratie gebruikt directe authenticatie met je Tibber account, onafhankelijk van de officiële Tibber integratie.

I have successfully updated my SoC on [https://app.tibber.com/playground/](https://app.tibber.com/playground/), however it seems that I need to use v4 and that seems to need OAuth 2.0 for authentication.

---

<div class="post-metadata">

**Author:** ![TonS](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/tons/32/48145_2.png) [@TonS](https://community.homey.app/u/TonS)\
**Post date:** [January 20, 2026, 8:12am UTC](https://community.homey.app/t/script-for-daily-fetching-fee-data-from-tibber-ie-clock-hour-of-daily-max-and-min/144485/14 "2026-01-20T08:12:30Z")

</div>

You can use 2 different URL’s.  
Pricedata is something you typically only fetch once a day. My script stores it in a homey variable.  
You can use that data in your other script.
