hass-entso-e icon indicating copy to clipboard operation
hass-entso-e copied to clipboard

Add `get_energy_prices` service call

Open TheFes opened this issue 11 months ago • 3 comments

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

TheFes avatar Mar 15 '24 12:03 TheFes

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?

Roeland54 avatar Sep 11 '24 18:09 Roeland54

Nice, I will test!

TheFes avatar Sep 12 '24 07:09 TheFes

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).

TheFes avatar Sep 12 '24 08:09 TheFes