Get price for date action in Nord Pool (#35682)

* Fix rebase

* Restore example

* startup

* Add note

* Mod trigger template

* Add screenshot

* Fix
This commit is contained in:
G Johansson 2024-12-18 14:02:58 +01:00 committed by GitHub
parent b877b9db5f
commit e712a867bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 105 additions and 0 deletions

View File

@ -96,6 +96,52 @@ The block price sensors are not enabled by default.
| Exchange rate | Integer | The exchange rate between the configure currency and Euro's. |
| Last updated | Datetime | The time when the market prices were last updated. |
## Actions
### Get price for date
The integration entities provide price information only for the current date. Use the "Get price for date" action to retrieve pricing information for any date within the last two months or for tomorrow.
The areas and currency parameters are optional. If omitted, the values configured in the integration will be used.
See [examples](#examples) how to use in a trigger template sensor.
{% configuration_basic %}
Nord Pool configuration entry:
description: Select the Nord Pool configuration entry to target.
Date:
description: Pick the date to fetch prices for (see note about possible dates below).
Areas:
description: Select one market area to create output for. If omitted it will use the areas from the configuration entry.
Currency:
description: Currency to display prices in. EUR is the base currency in Nord Pool prices. If omitted it will use the currency from the configuration entry.
{% endconfiguration_basic %}
{% note %}
The public API only allows us to see past pricing information for up to 2 months.
Tomorrow's prices are typically released around 13:00 CET, and trying to get them before that time will generate an error that needs to be considered in such a case.
{% endnote %}
#### Example action with data
{% raw %}
```yaml
action: nordpool.get_prices_for_date
data:
config_entry: 1234567890a
date: "2024-11-10"
areas:
- SE3
- SE4
currency: SEK
```
{% endraw %}
## Examples
A template sensor to add VAT and fixed cost is useful to get the actual energy cost in the energy dashboard.
@ -138,6 +184,65 @@ template:
{% endraw %}
### Tomorrow's lowest price
Using a trigger template, you can create a template sensor to calculate tomorrow's lowest price which also puts the list of all prices in the attributes of the sensor. All prices are returned in [Currency]/MWh.
{% note %}
You need to replace the `config_entry` with your own Nord Pool config entry id.
Below example will convert the action call response to kWh prices in the selected currency and add all prices for tomorrow as a list in an attribute.
{% endnote %}
{% raw %}
```yaml
template:
- trigger:
- trigger: time_pattern
minutes: /10
- trigger: homeassistant
event: start
action:
- action: nordpool.get_prices_for_date
data:
config_entry: 01JEDAR1YEHJ6DZ376MP24MRDG
date: "{{ now().date() + timedelta(days=1) }}"
areas: SE3
currency: SEK
response_variable: tomorrow_price
sensor:
- name: Tomorrow lowest price
unique_id: se3_tomorrow_low_price
state: >
{% if not tomorrow_price %}
unavailable
{% else %}
{% set data = namespace(prices=[]) %}
{% for state in tomorrow_price['SE3'] %}
{% set data.prices = data.prices + [(state.price / 1000)] %}
{% endfor %}
{{min(data.prices)}}
{% endif %}
attributes:
data: >
{% if not tomorrow_price %}
[]
{% else %}
{% set data = namespace(prices=[]) %}
{% for state in tomorrow_price['SE3'] %}
{% set data.prices = data.prices + [{'start':state.start, 'end':state.end, 'price': state.price/1000}] %}
{% endfor %}
{{data.prices}}
{% endif %}
```
{% endraw %}
<p class='img'>
<img src='/images/integrations/nordpool/nordpool_tomorrow_lowest_price.png' alt='Screenshot: Trigger template: Tomorrow lowest price'>
</p>
### Energy Dashboard
To use the Nordpool integration in the **Energy** dashboard, when configuring grid consumption and production, use the **Use an entity with current price** option.

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB