rnovacek / homeassistant_cz_energy_spot_prices

Home Assistant integration that provides current Czech electricity spot prices based on OTE.
Apache License 2.0
91 stars 21 forks source link

current_spot_electricity_buy_price evaluated once an hour #59

Open JiriPrchal opened 3 months ago

JiriPrchal commented 3 months ago

The template for buy price i evaluated only once an hour. But the distribution cost can change at any time. For example my template: {{ (value + 0.35 + iif (is_state ('binary_sensor.energy_tariff', 'on'), 0.45043, 0.6443) + 0.21282 + 0.495 + 0.0283) * 1.21 }}

kkoouu commented 3 months ago

This has nothing to do with this integration ... f.e. I'm using automation with trigger on binary_sensor.energy_tariff change to set the correct distribution price ( number helper )

JiriPrchal commented 3 months ago

This has nothing to do with this integration ... f.e. I'm using automation with trigger on binary_sensor.energy_tariff change to set the correct distribution price ( number helper )

Example please. I don't understand why automation. Template sensor (number helper?) evaluates as inputs changes.

kkoouu commented 3 months ago

OK, I got it, you are using a template for buy price in the configuration for this integration. I thought it was a common HA template. Then I have no answer for you, just a workaround tip to calculate it in HA ( not using the integration )

JiriPrchal commented 3 months ago

Yes, this workaround:

template: 
 - sensor:
    - name: "current spot electricity buy price fixed"
      unit_of_measurement: "Kč/kWh"
      icon: "mdi:cash"
      state: "{{ (states ('sensor.current_spot_electricity_price') | float (0) + 0.35 + iif (is_state ('binary_sensor.energy_tariff', 'on'), 0.45043, 0.6443) + 0.21282 + 0.495 + 0.0283) * 1.21 }}"