JaccoR / hass-entso-e

Integration for Home Assistant to fetch day ahead energy prices from European countries via ENTSO-e Transparency Platform
Apache License 2.0
185 stars 31 forks source link

Add `get_energy_prices` service call #147

Closed TheFes closed 1 month ago

TheFes commented 7 months ago

Is your feature request related to a problem? Please describe. I am the author of the cheapest_energy_hours macro which can be used to determine eg the best time to turn on your dishwasher. However, if you want to turn it on overnight, you loose today's data at midnight (as it will become yesterdays data then).

Some core integrations, like easyEnergy provide a service call in which you can get the data for the period you want, including historical data.

Describe the solution you'd like Add support for the service call mentioned above

Describe alternatives you've considered Add an additional attribute with the data of yesterday.

Additional context NA

Roeland54 commented 1 month ago

The beta version of v0.5.0 does contain a "get_energy_prices" action. https://github.com/JaccoR/hass-entso-e/releases/tag/v0.5.0-beta1 Can you test and provide feedback?

TheFes commented 1 month ago

Nice, I will test!

TheFes commented 1 month ago

Works great. Tested it using this template sensor:

- trigger:
    - platform: time_pattern
      hours: "/1"
    - platform: homeassistant
      event: start
  action:
    - action: entsoe.get_energy_prices
      data:
        config_entry: 2100acc47af75f6227f0394476b6c322
        start: "{{ today_at() - timedelta(days=1) }}"
        end: "{{ today_at() + timedelta(days=2) }}"
      response_variable: prices
  sensor:
    - unique_id: 96147157-eca9-460c-b4cb-97165594e7a8
      name: ENTSOE prices
      state: "{{ prices.prices | selectattr('timestamp', '<=', now().strftime('%Y-%m-%dT%H:%M:%S+00:00')) | map(attribute='price') | list | last }}"
      attributes:
        prices: "{{ prices.prices }}"

This will give a sensor with a prices attribute with the prices of yesterday, today and tomorrow (if available).

Roeland54 commented 1 month ago

v0.5.0 is released.