Get prices for date

Use this action to retrieve the day-ahead electricity spot prices for a specific date, for Spain, Portugal, or both countries.

The OMIE sensors always reflect the current price. This action lets you fetch the prices for any published date instead, which is useful when you want to look ahead. For example, you can compare tomorrow’s prices or schedule an appliance to run during the cheapest hours.

This action returns its result in a response variable, which you can use in later steps of the same automation or script.

Prices for the next day are published daily at around 13:30 CET/CEST. If you request a date that has not been published yet, the action reports that the prices are not available. Similarly if you request a date that is previous to the date when quarter-hourly prices became available, the action reports that no prices exist for that date and tells you the earliest date you can request.

Using this action from the user interface

If you prefer building automations and scripts visually, Home Assistant walks you through this action step by step. You pick what to target, tweak a few options, and save. No YAML knowledge required.

To get prices from an automation or a script:

  1. Go to Settings > Automations & scenes.
  2. Open an existing automation or script, or select Create automation > Create new automation.
  3. If you’re setting up a new automation, add a trigger in the When section. Scripts don’t need a trigger. They run when something else calls them.
  4. In the Then do section, select Add action.
  5. From the search box, search for and select OMIE - Spain and Portugal electricity prices: Get prices for date.
  6. Select the Date you want, and choose the Countries to get prices for.
  7. In the Response variable field, enter a name to store the data in, such as prices.
  8. Select Save.

Options in the UI

Date (Required)

The date to get the prices for.

Countries (Required)

The countries to get the prices for. Choose Spain, Portugal, or both. Both are selected by default.

Using this action in YAML

If you work directly in YAML, or you want to know exactly what Home Assistant does under the hood, this section has the technical reference. It lists the field names you use in YAML, their types, and which ones are required.

In YAML, refer to this action as omie.get_prices_for_date. Store the result in a response variable so you can use it in later steps:

ActionActions are used in several places in Home Assistant. As part of a script or automation, actions define what is going to happen once a trigger is activated. In scripts, an action is called *sequence*. [Learn more]
action: omie.get_prices_for_date
data:
  date: "2026-07-08"
  countries:
    - es
    - pt
response_variable: prices

This fetches the prices for both Spain and Portugal on the given date.

Options in YAML

date date Required

The date to get the prices for, in YYYY-MM-DD format.

countries list Required

The countries to get the prices for. A list containing es, pt, or both. Defaults to both.

Response data

The response contains a key for each requested country: es for Spain and pt for Portugal. If you request both countries, both keys are present.

Each key holds a list of quarter-hourly intervals. Each interval includes the following fields:

  • start: The start time of the interval, in CET/CEST.
  • end: The end time of the interval, in CET/CEST.
  • price: The electricity spot price for the interval, in €/kWh.

A shortened example of the response looks like this:

es:
  - start: "2026-07-08T00:00:00+02:00"
    end: "2026-07-08T00:15:00+02:00"
    price: 0.03415
  - start: "2026-07-08T00:15:00+02:00"
    end: "2026-07-08T00:30:00+02:00"
    price: 0.03521
pt:
  - start: "2026-07-08T00:00:00+02:00"
    end: "2026-07-08T00:15:00+02:00"
    price: 0.0361
  - start: "2026-07-08T00:15:00+02:00"
    end: "2026-07-08T00:30:00+02:00"
    price: 0.0372

Try it yourself

Ready to test this? Open Settings > Tools > Actions, search for this action, fill in the fields, and select Perform action. You see what happens on your actual entitiesAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] without writing a line of YAML.

Still stuck?

The Home Assistant community is quick to help: join Discord for real-time chat, post on the community forum with the action you’re calling and what you expected to happen, or share on our subreddit /r/homeassistant.

Tip

AI assistants like ChatGPT or Claude can also explain actions or suggest the right one when you describe what you want in plain language.