Language

Home Assistant ยท price and CO2

No dedicated Home Assistant integration is required here

A normal REST sensor is enough to consume price, CO2 and best-window data. The public summary endpoint already returns the fields most automations actually need.

Start free, plan further when needed

The Home Assistant setup remains available without an API key for up to 48 hours. If you want to plan larger loads across several days, you can try Private Pro with up to 120 hours free for 14 days.

Key point

The API is already usable directly from Home Assistant, scripts and other automations. The missing piece was clear documentation, not a custom integration.

API migration

New integrations should now use https://api.energypriceforecast.eu/api/v1/.... Some older project URLs still work for existing setups, but they should no longer be treated as the reference path for new integrations.

Recommended endpoint

For Home Assistant, /api/v1/home-assistant/summary is the simplest entry point. It returns not just raw values, but already computed windows for cheapest, greenest and combined use.

https://api.energypriceforecast.eu/api/v1/home-assistant/summary?country=de&hours=48&window_hours=4
Priceflat.current_price and flat.cheapest_window_*.
CO2flat.current_co2_g_kwh and flat.greenest_window_*.
Combinedflat.combined_window_* for the price/CO2 compromise.

Quick start for copy and paste

Yes, this is intentionally designed so a normal Home Assistant setup is enough. The easiest path is: paste the YAML block, adjust the market, reload Home Assistant.

  1. Paste the YAML block below into configuration.yaml or into a package file that Home Assistant already loads.
  2. Only change the country parameter. For Denmark, always use dk1 or dk2.
  3. Reload or restart Home Assistant.
  4. Check Developer Tools to confirm that the new sensors return values.
Beginner-friendlyThe example deliberately uses simple flat fields instead of complex templates, so it stays copy-paste friendly.
What you need to changeUsually only country. The rest can stay unchanged.
What should appear afterwardsAt least one current-price sensor and one cheapest-window sensor.

REST sensor example

This example polls Germany every 15 minutes. For other markets, only the country parameter changes.

rest:
  - resource: "https://api.energypriceforecast.eu/api/v1/home-assistant/summary?country=de&hours=48&window_hours=4"
    scan_interval: 900
    sensor:
      - name: "EnergyPriceForecast current price"
        value_template: "{{ value_json.flat.current_price }}"
        unit_of_measurement: "EUR/kWh"

      - name: "EnergyPriceForecast current CO2 intensity"
        value_template: "{{ value_json.flat.current_co2_g_kwh }}"
        unit_of_measurement: "gCO2/kWh"

      - name: "EnergyPriceForecast cheapest window start"
        value_template: "{{ value_json.flat.cheapest_window_start }}"

      - name: "EnergyPriceForecast greenest window start"
        value_template: "{{ value_json.flat.greenest_window_start }}"

After adding the block, reload or restart Home Assistant and verify the sensor values in Developer Tools.

Official field reference for home-assistant/summary

The summary endpoint is intentionally compact. For many automations, the flat block is already enough. If you want more control or custom dashboards, use the more structured price, co2, combined and source blocks as well.

Field Meaning Typical use
flat.current_priceCurrent price in EUR/kWh. For the current slot it automatically uses the best available public source.Simple price sensor for automations.
flat.current_price_sourceSource label of the current price, for example day_ahead.Check whether the value is already official or still forecast-based.
flat.current_co2_g_kwhCurrent CO2 intensity in gCO2/kWh.CO2-based shifting of flexible loads.
flat.cheapest_window_*Start, end and average value of the cheapest time window in the requested horizon.EV charging, boilers, heat pumps.
flat.greenest_window_*Start, end and average value of the lowest-CO2 time window.Low-CO2 scheduling.
flat.combined_window_*Compromise window between price and CO2.When both matter and you do not want to define your own weighting.
price.currentObject with start, end, value, unit and source for the current price slot.Dashboards and more precise state logic.
price.cheapest_window_next_horizonStructured cheapest-window block including duration and source counts.When you want start, end and context together.
co2.currentObject with the current CO2 value and its time window.CO2 display without parsing flat.
co2.greenest_window_next_horizonStructured greenest-window block.Low-CO2 charging or heating logic.
combined.best_window_next_horizonCombined recommendation path with price, CO2 and score values.A single "best now" decision without building your own score.
source.priceMetadata about the price source, including Firestore document, day-ahead provider and counts of available entries.Debugging, monitoring and quality checks.
source.co2Metadata about the CO2 source.Debugging and traceability.
Important about price fieldsThe summary endpoint does not return the full raw series of every price variant. For Home Assistant it mainly returns the current state and already computed windows. For full hourly series, hourly-forecast is the better endpoint.
Current does not mean historical actualflat.current_price is the currently usable public price for the running slot. It can come from the official day-ahead auction or from another released source when the full market result is not available yet.
Retail only for selected marketsThe public retail-forecast endpoint is currently intended only for selected markets. For other markets, the summary deliberately stays on market or base values.

When is summary enough, and when do you need hourly-forecast?

summary is enough for simple automations

If you only need the current price, the current CO2 intensity or the best 4-hour window, home-assistant/summary is the right endpoint. It keeps the YAML short and avoids unnecessary parsing.

hourly-forecast is better for charts and complex templates

If you want to draw your own charts, compute your own scores or separate day-ahead values from model forecast values, use hourly-forecast. That endpoint exposes the hourly series more explicitly.

Public API support matrix

Not every visible market is publicly enabled for every endpoint yet. This matrix makes the current support level explicit instead of relying on guesswork.

Market hourly-forecast home-assistant/summary co2-live Retail end-price forecast
retail-forecast
DEyesyesyesyes
NLyesyesyesyes
BEyesyesyesno
FRyesyesyesno
CZyesyesyesno
ATyesyesyesyes
PLyesyesyesno
FIyesyesyesno
SE1yesyesyesno
SE2yesyesyesno
SE3yesyesyesno
SE4yesyesyesno
DK1yesyesyesyes
DK2yesyesyesyes
NO1yesyesyesyes
NO2yesyesyesyes
NO3yesyesyesyes
NO4yesyesyesyes
NO5yesyesyesyes
DenmarkUse dk1 or dk2. A generic dk request resolves to DK1.
Czech RepublicCZ is now public for price and CO2 in the summary and live CO2 path. Retail end-price forecast is not public yet.
Retail end priceretail-forecast means an estimated end-customer electricity price, not just the wholesale or base market price. It is currently public for DE, NL, DK1, DK2, AT, and NO1 to NO5.

Adapt it to your setup with AI

This prompt helps an AI turn the summary endpoint into a Home Assistant automation for your actual load, deadline and safety rules. It supplements the copy-paste setup above rather than replacing it.

Protect your API key

Never give an AI your real API key. Keep YOUR_API_KEY in the generated result and insert the key locally in Home Assistant.

Show the copyable prompt
Help me build a safe Home Assistant automation using the Energy Price Forecast EU API.

Read the API contract first:
https://energypriceforecast.eu/openapi/integration-api.json

Use /api/v1/home-assistant/summary and do not invent fields. The API uses official day-ahead prices wherever available and forecast values only for the remaining open horizon.

Before writing YAML, ask me no more than these questions, one at a time:
1. Country or bidding zone?
2. Which load should be controlled and which Home Assistant entity switches it?
3. Power, required runtime and latest completion time?
4. Optimise for price, CO2 or both?
5. Free without a key and up to 48 hours, or Private Pro with up to 120 hours?
6. Do I use packages or configuration.yaml?

Rules for your result:
- Free: hours=48 and no Authorization header.
- Private Pro: hours=120 and header Authorization: Bearer YOUR_API_KEY.
- Never ask me to paste the real key into the chat.
- Handle HTTP errors and check meta.api_key_state and meta.allowed_horizon_hours.
- Briefly explain every API property you use.
- Produce complete, correctly indented YAML and state exactly where it belongs.
- Start with a safe test mode using a notification or input_boolean. Put real load switching in a separate, clearly marked step.
- Define safe behaviour for stale, missing or implausible data. An API error must never switch the load on unexpectedly.
- Finish with a checklist: HTTP 200, sensors populated, allowed horizon correct and test mode triggered correctly.

Ask when information is missing. Do not silently assume entity names, tariffs or electrical limits.

Machine-readable foundation: OpenAPI contract for the integration endpoints.

Important notes

Is this an official Home Assistant integration?

No. This is intentionally a simple REST-based path. It is easier to test, easier to reason about and already sufficient for many setups.

Are the API prices my exact household electricity price?

Not automatically. hourly-forecast and the Home Assistant summary start with market/base prices. The exact total price depends on country-specific grid fees, taxes, levies and supplier markup.

What happens for an unsupported country?

The public API now returns an explicit error instead of silently falling back to Germany. That is intentional so automations do not run on wrong data.

What if no values appear after pasting the YAML?

The most common causes are: the YAML was pasted into the wrong place, Home Assistant was not reloaded, the country value is unsupported, or the YAML indentation is broken. Developer Tools and the Home Assistant logs usually show this immediately.