1. Home
  2. Scripting
  3. Live electricity prices

Scripting

Live electricity prices

Heat, charge and switch when power is cheap — start with the guide for your country.

Updated: September 2026

How it works

The device fetches the hourly price itself, over HTTP from a national data source, and decides what to do with it. There is no broker, bridge or server of your own to keep running — but the device does need internet access, and the data source has to be reachable.

Every setup has the same two halves:

  1. Fetch the price. Country-specific, because the number that matters is not the raw spot price.
  2. Act on the price. The same everywhere: compare it against a threshold and switch the output.

The guide for your country covers both, with a script that works as it stands.

Why the raw spot price is the wrong number

This is why there is no single script for the Nordics. Each country has its own source, and the good ones return the delivered price — spot plus tariffs plus taxes — for the customer’s own address.

What is worth controlling

Underfloor heating, hot water and EV charging. They are slow, they store what they make, and nobody notices which hour the energy went in.

Not lighting and not sockets. They are wanted when they are wanted, the saving is pennies, and a light that decides for itself is a complaint.

What to watch out for

  • Fetch once an hour, not every minute. Prices change hourly. More often gains nothing and loads a service somebody else pays for.
  • Decide what happens when the fetch fails. A load must not sit on all night because one lookup timed out. Switch off, hold the last state, fall back to a schedule — but choose, and write it into the script.
  • Set the threshold from the customer’s bill, not from the spot price.
  • Combine with a schedule, and leave a manual override. The schedule decides that the window exists; the price decides when inside it. A cheap-hours rule nobody can interrupt becomes a complaint the first time somebody wants a hot shower at 17:00.

Pick your country

Country Source The price includes
Denmark (in Danish) stromligning.dk Spot price, grid operator tariffs and taxes, looked up from coordinates
Sweden — guide coming soon National spot price by area Spot price by price area
Finland — guide coming soon National spot price Spot price, with VAT handled separately

On Gen3 devices and newer, the price can also be shown as its own tile in the app. That part does go through your Shelly account: the script sends the price on to it. The country guide covers the setup.