rnovacek / homeassistant_cz_energy_spot_prices Goto Github PK
View Code? Open in Web Editor NEWHome Assistant integration that provides current Czech electricity spot prices based on OTE.
License: Apache License 2.0
Home Assistant integration that provides current Czech electricity spot prices based on OTE.
License: Apache License 2.0
Pls be so kind and check this. Thx
Petr
Logger: homeassistant.helpers.frame
Source: helpers/frame.py:77
First occurred: 19:10:49 (1 occurrences)
Last logged: 19:10:49
Detected integration that called async_setup_platforms instead of awaiting async_forward_entry_setups; this will fail in version 2023.3. Please report issue to the custom integration author for cz_energy_spot_prices using this method at custom_components/cz_energy_spot_prices/init.py, line 31: hass.config_entries.async_setup_platforms(config_entry, ['sensor'])
Ahoj, Dobry den,
Nevím, jestli to děla jen me, ale pravidelně snad každý den obdržím tento timeout. Výpis níže.
Včera jsem přepisoval všechny soubory v adresáři custom components novými a doufal, ze to pomůže. Bohužel je to stejne. V čem muže být problém?
Jinak Dekuji za výborný nástroj k řízení dle spotovych cen.
Logger: custom_components.cz_energy_spot_prices.coordinator
Source: helpers/update_coordinator.py:296
Integration: Czech Energy Spot Prices (documentation, issues)
First occurred: 12:00:10 (1 occurrences)
Last logged: 12:00:10
Timeout fetching Czech Energy Spot Prices data
There are some problems if the current timezone is different than Europe/Prague
.
For example with London timezone, this error occurs:
2023-07-12 13:52:06.736 ERROR (MainThread) [custom_components.cz_energy_spot_prices.coordinator] Unexpected error fetching Czech Energy Spot Prices - 1 data: datetime.datetime(2023, 7, 11, 23, 0, tzinfo=datetime.timezone.utc)
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 213, in _async_update_data
gas=DailySpotRateData(gas_rates, zoneinfo=zoneinfo),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 144, in __init__
self._today = rates[midnight_today]
~~~~~^^^^^^^^^^^^^^^^
KeyError: datetime.datetime(2023, 7, 11, 23, 0, tzinfo=datetime.timezone.utc)
Workaround is to set the timezone to Europe/Prague
.
při změně na DST má podle OTE den jen 23 hodin - https://www.ote-cr.cz/cs/kratkodobe-trhy/elektrina/denni-trh?date=2023-03-26
a integrace jde do chyby:
2023-03-26 19:20:14.383 ERROR (MainThread) [custom_components.cz_energy_spot_prices.coordinator] Unexpected error fetching Czech Energy Spot Prices data: 2
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 239, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 168, in _async_update_data
return SpotRateData(rates, zoneinfo)
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 103, in __init__
for i, hour in enumerate(sorted(self.tomorrow_day.hours_by_dt.values(), key=lambda hour: hour._consecutive_sum_prices[consecutive]), 1):
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 103, in <lambda>
for i, hour in enumerate(sorted(self.tomorrow_day.hours_by_dt.values(), key=lambda hour: hour._consecutive_sum_prices[consecutive]), 1):
KeyError: 2
2023-03-26 19:20:14.825 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up cz_energy_spot_prices platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 239, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 168, in _async_update_data
return SpotRateData(rates, zoneinfo)
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 103, in __init__
for i, hour in enumerate(sorted(self.tomorrow_day.hours_by_dt.values(), key=lambda hour: hour._consecutive_sum_prices[consecutive]), 1):
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 103, in <lambda>
for i, hour in enumerate(sorted(self.tomorrow_day.hours_by_dt.values(), key=lambda hour: hour._consecutive_sum_prices[consecutive]), 1):
KeyError: 2
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 293, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/cz_energy_spot_prices/sensor.py", line 125, in async_setup_entry
await coordinator.async_config_entry_first_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 211, in async_config_entry_first_refresh
raise ex
homeassistant.exceptions.ConfigEntryNotReady: 2
předpokládám, že podobný problém bude na podzim, kdy DST končí a OTE má 25 údajů o cenách
https://www.ote-cr.cz/cs/kratkodobe-trhy/elektrina/denni-trh?date=2022-10-30
Zdravím. Do včerejška tj. 26.3.2023 aplikace načítala ceny z OTE v pořádku. Dnes 27.3.2023 již aktuální ceny nenačetla. Poslední načtený údaj mám 26.3.2023 22:00. Jsem začátečník, takže neumím blíže popsat, kde je problém. Díky.
It seems that the prices are shifted by one hour. It may be a timezone problem, but I have HA currently set Central European Time/Prague+1:00 which should be OK.
Look at the example - OTE and raw data side by side. It shows that the price 1.2CZK/KWh starts at 09:00
Here is the time from HA where it starts at 08:00.
Basically HA shows the price one hour earlier than it should.
Dobrý den,
Napřed bych ctěl poděkovat za vaši práci! Běhá to tak jak má. Jan jsem si všiml že je možnost přidat sensory ceny prodeje a nákupu. Ale nějak mi to nejde. Můžu Vás poprosit o postup? v readme jsem nic nenašel...
Děkuji.
JB.
Zdravím,
updatoval jsem na 0.3.1, ale i přesto se mi data z ote nenačítají. V logu je následující:
2023-03-27 12:37:33.555 ERROR (MainThread) [custom_components.cz_energy_spot_prices.coordinator] Unexpected error fetching Czech Energy Spot Prices data: 2
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 239, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 168, in _async_update_data
return SpotRateData(rates, zoneinfo)
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 99, in __init__
for i, hour in enumerate(sorted(self.today_day.hours_by_dt.values(), key=lambda hour: hour._consecutive_sum_prices[consecutive]), 1):
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 99, in <lambda>
for i, hour in enumerate(sorted(self.today_day.hours_by_dt.values(), key=lambda hour: hour._consecutive_sum_prices[consecutive]), 1):
KeyError: 2
2023-03-27 12:37:33.558 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up cz_energy_spot_prices platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 239, in _async_refresh
self.data = await self._async_update_data()
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 168, in _async_update_data
return SpotRateData(rates, zoneinfo)
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 99, in __init__
for i, hour in enumerate(sorted(self.today_day.hours_by_dt.values(), key=lambda hour: hour._consecutive_sum_prices[consecutive]), 1):
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 99, in <lambda>
for i, hour in enumerate(sorted(self.today_day.hours_by_dt.values(), key=lambda hour: hour._consecutive_sum_prices[consecutive]), 1):
KeyError: 2
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 293, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/cz_energy_spot_prices/sensor.py", line 125, in async_setup_entry
await coordinator.async_config_entry_first_refresh()
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 211, in async_config_entry_first_refresh
raise ex
homeassistant.exceptions.ConfigEntryNotReady: 2
Co s tím? Díky a hezký den :-)
Zdravím,
Integrace je super. Jen jsem si všiml jedné věci. V když v HA používám kartu energie a dob záložky spotřeba že sítě si přidám aktuální cenu v dané hodině, tak to ale počítá o hodinu jinak.
Protože HA tam tu energii za poslední hodinu přidává na začátku další hodiny, ale mezitím už se v senzoru aktuální ceny právě změnila cena na tu další hodinu.
Zatím jsem to vyřešil pomocným sensorem, který se aktualizuje o minutu zpožděně oproti vašemu, aby HA měl ještě tu cenu minulé hodiny.
Jen takový poznatek .
Martin
Zatím jsem na verzi 0.6.0, takže se omlouvám, pokud je to už opravené.
Používám entitu na blok 3 nejlevnějších hodin, ale dělá to občas koniny. Včera ten blok měl 4 hodiny:
A dneska měl jenom 2:
Přičemž je navíc na první pohled zřejmé, že to dnes ani nevybralo ty nejlevnější hodiny. Mezi 02:00-04:00 bylo určitě levněji než mezi 00:00-02:00.
If I want to put entity "sensor.current_spot_electricity_price" into graph on dashboard by use "Statistic Graph" panel, it is not possible to find itself enitity in the list. I searched, that it is done by itself integration, please see here https://www.home-assistant.io/more-info/statistics/. Do you plan to solve this in some way ?
Hello Radek,
today SPOT prices: https://www.ote-cr.cz/cs/kratkodobe-trhy/elektrina/denni-trh?date=2023-05-31
Two cheapest hours block start at 13:00:00 and stop at 14:59:59. Now is 14:15 and block is still off.
Four cheapest hours block start at 11:00:00 and stop at 14:59:59. Time is 14:15 and block is on.
It looks like the blocks are shifted by two hours. Timezone is UTC +2 / Central European Summer Time (CEST).
Attributes of 2_hours_block and 4_hours_block:
Start: 2023-05-31T13:00:00+02:00
Start hour: 13
End: 2023-05-31T14:59:59+02:00
End hour: 14
Min: 1.02354
Max: 1.16939
Mean: 1.096465
icon: mdi:cash-clock
friendly_name: Spot Electricity Is Cheapest 2 Hours Block
Start: 2023-05-31T11:00:00+02:00
Start hour: 11
End: 2023-05-31T14:59:59+02:00
End hour: 14
Min: 1.02354
Max: 2.05585
Mean: 1.352705
icon: mdi:cash-clock
friendly_name: Spot Electricity Is Cheapest 4 Hours Block
Pavel
dobrý den,
těmito dvěma automatizacemi zhruba optimalizuji vybíjení FV baterky v hodiny dne, které jsou spotově dražší:
When Current Spot Electricity Hour Order is >12
ALLOW DIScharge
When Current Spot Electricity Hour Order is <13
DISALLOW DIScharge
Jenže narážím na půlnoční "nesouvislé" řazení hodin druhého dne, které teď vede k tomu, že např. ve v příloze naznačené situaci automatizace od 22 do 24 hodin prvního dne vybíjení zakazuje, i přestože spotové ceny následujících ranních hodin nového dne stále klesají a tak stálo za to, baterku vybíjet.
nešlo by vytvořit nové entity jako např. Electricity Is Cheapest Looking X Hours Forward, Electricity Is Most Expensive Looking X Hours Forward, které by braly v potaz ceny dalšího dne ?
pardon pokud lze věc řešit stávajícími entitami, prosím eventuálně o nasměrování
díky moc
Mám sazbu D25d (oblast CEZ) - v době 0:00 - 6:00 a 19:00 - 21:00 mám distribuci za 180 a jinak za 1766 Kč bez DPH. Je možné nějak pracovat s úpravou importovaných cen, aby to dávalo smylsl? Rozdíl v ceně distribuce je většinou vyšší než rozdíl v ceně silové energie. Podobný problém je se sazbou D27d - elektromobily. Děkuji
Hi Radek, thank you for this integration!
I have had it installed for a couple of weeks and recently I had noticed an oddly low price for an evening, so I analyzed the data and found out the hours and corresponding rates are not being matched to the hour of the day, rather simply to a line order.
Please see screenshot attached. Is this something you are aware of and can be fixed on my part? I have tried removing and re-adding the integration to no avail.
Thank you.
Hi, could you implement also gas data https://www.ote-cr.cz/en/short-term-markets/gas/intra-day-market?date=2023-01-01 ? díky
Hi, I am having issue with cheapest blocks. Sometimes it misses the night. I need to run battery recharge each night + each day (when there is not enough sun). My guess it would be median. And if value is under median, the sensor would go on signaling enable charging (to get over top prices) . Could that be managed or added to sensor set? The idea is to be able to utilize both graph lows, not only the main cheapest block. thanks
Nabízím řešení výpočtu reálných nákupních cen u dvoutarifních sazeb. Výsledkem je graf pro celé známé období spotových cen zohledňující regulovanou část ceny, DPH a další případné poplatky.
Jedná se téměř o klon senzoru current_spot_electricity_price
, avšak s přepočítanými cenami. To znamená, že ceny pro jednotlivé hodiny jsou dostupné jako atributy. Na rozdíl od originálního senzoru jsou všechny ceny sloučeny pod jeden atribut prices
, takže se nemíchají s ostatními atributy, jako je např. friendly_name
. Jako stav senzoru se zobrazuje aktuální cena.
Porovnání grafu reálných cen (nahoře) a originálního grafu (dole)
vt_hours
. Kdo má FVE, ten má hodiny stabilní během celého roku, kdo ne, ten bude muset updatovat podle změn na straně distributora. Zadává se jako pole, kde každé číslo představuje hodinu, kdy je vysoký tarif.price_vt
a price_nt
bez DPH. V mém případě používám ceny v Kč za kWh. Regulované ceny lze najít ve vyúčtování, a protože je část poplatků fixní za měsíc a část se váže na MWh, je třeba si to spočítat podle vaší modelové spotřeby a ceny za jistič. Mně to pro sazbu D57 a jistič 3x 20A vychází price_vt = 1.38
pro vysoký tarif a price_nt = 1.186
pro nízký tarif.vat = 21
, tedy 21 %. - name: "Spot Electricity Buy Prices"
unique_id: spot_electricity_buy_prices
unit_of_measurement: "Kč/kWh"
attributes:
prices: >
{%- set vt_hours = [9, 12, 16, 20] %}
{%- set price_vt = 1.38 %}
{%- set price_nt = 1.186 %}
{%- set vat = 21 %}
{%- set ns = namespace(buy_prices=[]) %}
{%- for key, value in states.sensor.current_spot_electricity_price.attributes.items() %}
{%- if key[:4].isnumeric() %}
{%- set hour = strptime(key, '%Y-%m-%dT%H:%M:%S%z').hour %}
{%- if hour not in vt_hours %}
{%- set addPrice = price_nt %}
{%- else %}
{%- set addPrice = price_vt %}
{%- endif %}
{%- set value = ((value + addPrice) * (1 + vat / 100)) | round(2) %}
{%- set ns.buy_prices = ns.buy_prices + [{key: value}] %}
{%- endif %}
{%- endfor %}
{{ns.buy_prices}}
state: >
{%- set vt_hours = [9, 12, 16, 20] %}
{%- set price_vt = 1.38 %}
{%- set price_nt = 1.186 %}
{%- set vat = 21 %}
{%- set hour_now = now().hour %}
{%- set day_now = now().day %}
{%- for key, value in states.sensor.current_spot_electricity_price.attributes.items() %}
{%- if key[:4].isnumeric() %}
{%- set hour = strptime(key, '%Y-%m-%dT%H:%M:%S%z').hour %}
{%- set day = strptime(key, '%Y-%m-%dT%H:%M:%S%z').day %}
{%- if hour == hour_now and day == day_now %}
{%- if hour not in vt_hours %}
{%- set addPrice = price_nt %}
{%- else %}
{%- set addPrice = price_vt %}
{%- endif -%}
{{ ((value + addPrice) * (1 + vat / 100)) | round(2) }}
{%- endif %}
{%- endif %}
{%- endfor %}
configuration.yaml
, jak je popsáno zde: https://www.home-assistant.io/integrations/templatetemplate:
- sensor:
- name: "Spot Electricity Buy Prices"
(atd...)
template: !include_dir_merge_named template/
V adresáři template
je pak soubor sensor.yaml
a v něm je uvedený kód.
sensor:
- name: "Spot Electricity Buy Prices"
(atd...)
type: custom:apexcharts-card
header:
show: true
show_states: true
colorize_states: true
graph_span: 2d
span:
start: day
now:
show: true
label: Now
series:
- entity: sensor.spot_electricity_buy_prices
float_precision: 2
type: column
color: '#090'
show:
in_header: raw
data_generator: |
return Object.entries(entity.attributes.prices).map(([idx, row]) => {
var date = Object.keys(row)[0];
var price = Object.values(row)[0];
return [new Date(date).getTime(), price];
});
dobrý den, hluboce děkuji za vaši skvěle funkční, užitečnou, rodinný rozpočet šetřící integraci! Jsem lama. Základ YAMLu zvládám jen díky ChatGPT. Rozchodil jsem tak automatizaci tlumení a boostování tepelného čerpadla podle aktuální spotové ceny. A dále automatizaci povolování discharge FVE baterky ve spotově dražších hodinách. Na tohle ale zatím nemám: mořím se s automatizací, která by: když se mezi 00:01 - 5:59 hodinou ranní vyskytuje hodina s cenou (nízkou) X a když se mezi 6:01 - 8:59 hodinou ranní vyskytuje hodina s cenou o více než 2,9 Kč vyšší než cena X, tak se nabije FVE baterka ze sítě za onu nízkou cenu a v onu pozdější ranní hodinu se spotovou cenou o těch více než 2,9 Kč vyšší se začne vybíjet. Lze vubec takovou logiku nasadit do configuration.yaml + automations.yaml nebo by to žádalo nový sensor/y ve vaší integraci?
díky
Ivo
jen pro pobavení přikládám, jak se lama radí s ChatGPT,
je tam asi problém se zamířením na atribut(y) časů/cen v sensor.current_spot_electricity_price
mé pokusné zadání ChatGPT:
I need help with home assistant configuration.yaml and automations.yaml:
I have a sensor with the following attributes: timestamps as keys (example: 2023-03-13T00:00:00+01:00) and prices as values (example: 1,64)
I need to code a sensor, which reads the timestamps and the prices in the following time window A: 00:00 - 05:59.
I need to code a sensor, which reads the timestamps and the prices in the following time window B: 06:01 - 08:59.
If there is a price found in time window B which is higher by more than 2,9 than a price in time window A, then I need to create 2 following time entities:
time_of_2_9lower_price_within_0000_0559
time_of_2_9higher_price_within_0601_0859
odpověď ChatGPT:
To accomplish this task, you can define two Template Sensors in your configuration.yaml file to filter the data from the sensor with timestamps and prices. Then, you can define two Automations in your automations.yaml file to check the conditions and create the two time entities if necessary.
Here is an example of how you can define the Template Sensors in your configuration.yaml file:
platform: template
sensors:
prices_window_a:
friendly_name: "Prices Window A"
value_template: >
{% set start_time = '00:00:00' %}
{% set end_time = '05:59:59' %}
{% set prices = state_attr('sensor.current_spot_electricity_price', 'prices') %}
{% set prices_window_a = {k: v for k, v in prices.items() if start_time <= k[-9:-6] <= end_time} %}
{% set prices_window_a_str = ', '.join([f'{k}: {v}' for k, v in prices_window_a.items()]) %}
{{ prices_window_a_str if prices_window_a else 'No prices in Window A' }}
prices_window_b:
friendly_name: "Prices Window B"
value_template: >
{% set start_time = '06:01:00' %}
{% set end_time = '08:59:59' %}
{% set prices = state_attr('sensor.current_spot_electricity_price', 'prices') %}
{% set prices_window_b = {k: v for k, v in prices.items() if start_time <= k[-9:-6] <= end_time} %}
{% set prices_window_b_str = ', '.join([f'{k}: {v}' for k, v in prices_window_b.items()]) %}
{{ prices_window_b_str if prices_window_b else 'No prices in Window B' }}
Note that you need to replace your_sensor_name with the actual name of your sensor entity.
The Template Sensors use the value_template to extract the prices in the specified time windows from the attributes of the sensor entity. They return a string with the timestamps and prices found, or a message indicating that there are no prices in the corresponding time window.
Next, you can define two Automations in your automations.yaml file to check the conditions and create the time entities:
automation:
Zdravím,
v logu se zobrazují tyto chyby, vzhledem k tomu, že je tato hodnota k dispozici až odpoledne, možná by nebylo špatné toto nezobrazovat jako "upozornění", případně tuto hodnotu načítat až 12+.
Osobně preferuji čisté logy a toto mi nepříjde nijak kritické :-)
Díky.
2023-10-14 03:03:05.651 WARNING (MainThread) [custom_components.cz_energy_spot_prices.spot_rate] Item has no "Price" child or is empty: 2023-10-152023-10-14 04:00:24.572 WARNING (MainThread) [custom_components.cz_energy_spot_prices.spot_rate] Item has no "Price" child or is empty: 2023-10-15 2023-10-14 05:01:01.614 WARNING (MainThread) [custom_components.cz_energy_spot_prices.spot_rate] Item has no "Price" child or is empty: 2023-10-15 2023-10-14 06:01:58.168 WARNING (MainThread) [custom_components.cz_energy_spot_prices.spot_rate] Item has no "Price" child or is empty: 2023-10-15 2023-10-14 07:00:16.518 WARNING (MainThread) [custom_components.cz_energy_spot_prices.spot_rate] Item has no "Price" child or is empty: 2023-10-15 2023-10-14 08:00:42.898 WARNING (MainThread) [custom_components.cz_energy_spot_prices.spot_rate] Item has no "Price" child or is empty: 2023-10-15 2023-10-14 09:00:14.082 WARNING (MainThread) [custom_components.cz_energy_spot_prices.spot_rate] Item has no "Price" child or is empty: 2023-10-15 2023-10-14 10:01:59.593 WARNING (MainThread) [custom_components.cz_energy_spot_prices.spot_rate] Item has no "Price" child or is empty: 2023-10-15
Ahoj,
přestala mi fungovat integrace po aktualizaci HA na poslední verzi.
Chyba v logu:
Logger: homeassistant.config_entries
Source: custom_components/cz_energy_spot_prices/init.py:31
Integration: Czech Energy Spot Prices (documentation)
First occurred: 18:08:36 (1 occurrences)
Last logged: 18:08:36
Error setting up entry Electricity Spot Rate in CZK/kWh for cz_energy_spot_prices
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/cz_energy_spot_prices/init.py", line 31, in async_setup_entry
hass.config_entries.async_setup_platforms(config_entry, ['sensor'])
AttributeError: 'ConfigEntries' object has no attribute 'async_setup_platforms'
Zkoušel jsem integraci přeinstalovat a to nepomohlo. Prosím o radu jak to opravit?
NanoGreen vytváří hodně podobnou integraci zde: https://github.com/nanogreencz/homeassistant-integrations jak @janhicl upozornil v tomto komentáři #1 (comment)
Koukal jsem zatím jen zběžně a hlavní rozdíl vidím v tom, že vy všechno počítáte na serveru (https://moje.nanogreen.cz/api/prices/daily
), zatímco já jen stahuji data z OTE a všechno počítám lokálně. Líbí se mi ty "X-tá hodina" senzory, to asi taky přidám.
Jaký máte s integrací dále cíl? Bude to specifické pro zákazníky NanoGreen? Dávalo by smysl využívat tuhle integraci (která bude asi spíše i nadále brát data z OTE) a případně nějaké specifické věci pro NanoGreen by se taky daly dodělat, třeba za nějaký flag při nastavovaní integrace.
Ahoj po aktualizaci na 2023.9.1 a následně i na 2023.9.2 se nepravidelně aktualizuje aktuální cena. Často zůstane několik hodin beze změny, ačkoliv načtené hodnoty na celý den jsou v pořádku.
Hello,
few days ago I realized that the spot electricity chart is showing incorrect (a bit lower) prices than presented on the official OTE web page. This is what my HA shows in the chart (using appexchart to visualise the prices):
... and here are prices shown on OTE (https://www.ote-cr.cz/)
With current exchange rate 24,725CZK/EUR it's obvious that prices shown in HA are not correct. I also checked HA log and found following exception there:
`2023-12-30 13:01:49.213 ERROR (MainThread) [custom_components.cz_energy_spot_prices.coordinator] OTE request failed 1 times, retrying in 2 seconds
Traceback (most recent call last):
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 210, in fetch_data
electricity_rates, gas_rates = await asyncio.gather(
^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/cz_energy_spot_prices/spot_rate.py", line 118, in get_gas_rates
rates, currency_rates = await asyncio.gather(
^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/cz_energy_spot_prices/spot_rate.py", line 133, in _get_rates
text = await self._download(query)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/cz_energy_spot_prices/spot_rate.py", line 94, in _download
async with session.post(self.OTE_PUBLIC_URL, data=query) as response:
File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 1141, in aenter
self._resp = await self._coro
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 560, in _request
await resp.start(conn)
File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 899, in start
message, payload = await protocol.read() # type: ignore[union-attr]
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 616, in read
await self._waiter
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 236, in update_data
self._spot_rate_data = await self.fetch_data()
^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 209, in fetch_data
async with async_timeout.timeout(10):
File "/usr/local/lib/python3.11/site-packages/async_timeout/init.py", line 141, in aexit
self._do_exit(exc_type)
File "/usr/local/lib/python3.11/site-packages/async_timeout/init.py", line 228, in _do_exit
raise asyncio.TimeoutError
TimeoutError
2023-12-30 13:02:01.230 ERROR (MainThread) [custom_components.cz_energy_spot_prices.coordinator] OTE request failed 2 times, retrying in 4 seconds
Traceback (most recent call last):
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 210, in fetch_data
electricity_rates, gas_rates = await asyncio.gather(
^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/cz_energy_spot_prices/spot_rate.py", line 106, in get_electricity_rates
return await self._get_rates(query, unit, has_hours=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/cz_energy_spot_prices/spot_rate.py", line 133, in _get_rates
text = await self._download(query)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/cz_energy_spot_prices/spot_rate.py", line 94, in _download
async with session.post(self.OTE_PUBLIC_URL, data=query) as response:
File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 1141, in aenter
self._resp = await self._coro
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 560, in _request
await resp.start(conn)
File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 899, in start
message, payload = await protocol.read() # type: ignore[union-attr]
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/aiohttp/streams.py", line 616, in read
await self._waiter
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 236, in update_data
self._spot_rate_data = await self.fetch_data()
^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/cz_energy_spot_prices/coordinator.py", line 209, in fetch_data
async with async_timeout.timeout(10):
File "/usr/local/lib/python3.11/site-packages/async_timeout/init.py", line 141, in aexit
self._do_exit(exc_type)
File "/usr/local/lib/python3.11/site-packages/async_timeout/init.py", line 228, in _do_exit
raise asyncio.TimeoutError
TimeoutError
`
It could be that there was short network connectivity outage but I expected that the integration will do some retries in order to get the right data. Any ideas what else shall I try to troubleshoot this issue?
Regards
Jan
Hi,
many thanks for this integration!
some day ago this integration did stop working
2022-12-05 17:03:09.679 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing platform custom_components.cz_energy_spot_prices.config_flow
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/loader.py", line 728, in get_platform
cache[full_name] = self._import_platform(platform_name)
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/loader.py", line 745, in _import_platform
return importlib.import_module(f"{self.pkg_path}.{platform_name}")
File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/home/homeassistant/.homeassistant/custom_components/cz_energy_spot_prices/config_flow.py", line 59, in <module>
class OptionsFlowHandler(config_entries.OptionsFlow):
File "/home/homeassistant/.homeassistant/custom_components/cz_energy_spot_prices/config_flow.py", line 65, in OptionsFlowHandler
self, user_input: dict[str, Any] | None = None
TypeError: unsupported operand type(s) for |: 'types.GenericAlias' and 'NoneType'
2022-12-05 17:03:09.680 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading configuration flow for integration cz_energy_spot_prices: Exception importing
custom_components.cz_energy_spot_prices.config_flow
2022-12-05 17:02:40.516 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
resp = await request_handler(request)
File "/srv/homeassistant/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
File "/srv/homeassistant/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
return await handler(request)
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/forwarded.py", line 222, in forwarded_middleware
return await handler(request)
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/ban.py", line 82, in ban_middleware
return await handler(request)
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/auth.py", line 236, in auth_middleware
return await handler(request)
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/view.py", line 136, in handle
result = await result
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/config/config_entries.py", line 218, in post
return await super().post(request)
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/components/http/data_validator.py", line 73, in wrapper
result = await method(view, request, data, *args, **kwargs)
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/data_entry_flow.py", line 71, in post
result = await self._flow_mgr.async_init(
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/data_entry_flow.py", line 225, in async_init
flow, result = await task
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/data_entry_flow.py", line 243, in _async_init
flow = await self.async_create_flow(handler, context=context, data=data)
File "/srv/homeassistant/lib/python3.9/site-packages/homeassistant/config_entries.py", line 1626, in async_create_flow
return HANDLERS[entry.domain].async_get_options_flow(entry)
File "/home/homeassistant/.homeassistant/custom_components/cz_energy_spot_prices/config_flow.py", line 42, in async_get_options_flow
return OptionsFlowHandler(config_entry)
NameError: name 'OptionsFlowHandler' is not defined
Ahoj,
snad to nebude vadit, že píšu česky, vzhledem k tomu, že se jedná o ceny z českého OTE. :)
1.) Rád bych se zeptal, jestli čas v atributech není trochu posunutý. Dle OTE je cena za první hodinu 00:00-00:59:59 158,06 euro za MWh, což znamená 3,84 Kč/kWh, ale v atributech máš od nulté hodiny 3,65, což zase odpovídá dle OTE času 01:00-01:59:99. Přitom na samotném stavu seznoru je to korektně, tedy v tuto hodinu je dle senzoru 5,76 Kč a dle OTE také 5,76 Kč. Jde to i vidět, kde atributy končí, na 22h, namísto 23.
2.) Vím, že to může být pro některé zbytečné, ale mohla by být zajímavá volba vytvoření senzoru, který by určoval čas, kdy začíná nejnižší kumulace cen dle nastavení. Například, chci nabíjet 3h, v nastavení bych nastavil 3h a senzor by mi ukázal, že nejnižší kumulativní cena začíná dnes v 01:00:00 a končí 03:59:59.
Jinak, naprosto skvělej počin, předtím jsem používal ten od Grinca, ale tam mi vadilo, že nemá další den po vyhlášení cen a každodenní hodinový výpadek.
Díky Bojkas
Předně díky za skvělou práci na téhle integraci!
Pro burzu NordPool(Skandinávie, Pobaltí, Německo, Rakousko, atd.) existuje skvělá integrace PriceAnalyzer - https://github.com/erlendsellie/priceanalyzer
Má to v podstatě všechny sensory pro automatizaci termostatů a nahřívání bojleru:
The sensor looks a lot like the nordpool-sensor, with a list of todays and tomorrows prices, but also includes info about the hour like:
- if the price is gaining later
- if the price is falling later
- the next hours price
- if the price for that hour is over peak price.
- if the price for that hour is over off peak 1 price.
- If the price is the lowest price in the foreseeable future
Nestálo by za to forknout PriceAnalyzer a upravit pro OTE?
Díky!
Zdravím,
po posledním updatu HA vyhodila integrace tuto chybu:
`Logger: homeassistant.config_entries
Source: custom_components/cz_energy_spot_prices/init.py:24
Integration: Czech Energy Spot Prices (documentation)
First occurred: 7. května 2023 16:27:06 (1 occurrences)
Last logged: 7. května 2023 16:27:06
Error setting up entry Electricity Spot Rate in CZK/kWh for cz_energy_spot_prices
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/cz_energy_spot_prices/init.py", line 24, in async_setup_entry
hass.config_entries.async_setup_platforms(entry, ['sensor'])
AttributeError: 'ConfigEntries' object has no attribute 'async_setup_platforms'`
A nespusti se, nejaké napady?
Díly
Prosím tento senzor měří v kč/kWh...ale v Energo panelu by měla být cena v kč/m3....je nějaký přepočet ev. jak lze rozdíl jednotek řešit? PS: Moc díky za super integraci!
Našel jsem chybu v zítřejším (tj. 26.3.) dni, kdy se posouvá čas. Podobný problém bude možná i na podzim.
V grafu zobrazení cen vidím sice správně sloupec 1:00, poté 3:00, ale zmizí cena jedné hodiny, takže všechny hodinové ceny po 3:00 (včetně) jsou posunuté o jednu hodinu.
Hi,
I installed it via Open HASC Repository (version 0.6.3) and restarted HAOS (Core 2023.11.3)). I have project under custom_components/cz_energy_spot_prices.
After Add integration I have Error message: Config flow could not be loaded: {"message":"Invalid handler specified"}.
The HA 2023.5.4 is complaining about this error:
This error originated from a custom integration.
Logger: custom_components.cz_energy_spot_prices.spot_rate
Source: custom_components/cz_energy_spot_prices/spot_rate.py:153
Integration: Czech Energy Spot Prices (documentation, issues)
First occurred: May 25, 2023 at 9:35:15 AM (44 occurrences)
Last logged: 2:00:04 PM
Item has no "Hour" child or is empty: 2023-05-25
Item has no "Hour" child or is empty: 2023-05-26
Item has no "Hour" child or is empty: 2023-05-27
Hi, I have problem with template sensor "Find cheapest hours in selected interval". Each day starts as unavailable and turns on during the day. Don't know where the problem could be?
here my code :
hodinovka:
value_template:
"{# Define your intervals here as tuples (hour starting the interval, hour ending the interval (excluded)) #}
{% set intervals = [
(1, 8),
(8, 16),
(16, 24),
] %}
{# We need to use namespace so we can write into it in inner cycle #}
{% set min = namespace(price=None, dt=None, cheapest_hours=[]) %}
{% set cheapest_hours = [] %}
{% for interval in intervals %}
{# Reset min price from previous runs #}
{% set min.price = None %}
{# Go through all the hours in the interval (end excluded) and find the hour with lowest price #}
{% for i in range(interval[0], interval[1]) %}
{# Get datetime of current hour in current interval #}
{% set hour_dt = now().replace(hour=i, minute=0, second=0, microsecond=0) %}
{# Get value for that hour #}
{% set value = states.sensor.current_spot_electricity_hour_order.attributes.get(hour_dt.isoformat()) %}
{# Skip if not found #}
{% if value is not defined %}
{% break %}
{% endif %}
{# value is tuple (order, price), we'll use the price #}
{% set price = value[1] %}
{# Min price is not set or is higher than price of current hour => store the min price and hour #}
{% if min.price is none or price < min.price %}
{% set min.price = price %}
{% set min.dt = hour_dt %}
{% endif %}
{% endfor %}
{# Store cheapest hour in current interval #}
{% set min.cheapest_hours = min.cheapest_hours + [min.dt.hour] %}
{% endfor %}
{# use this to get the cheapest hours #}
{# {{ min.cheapest_hours }} #}
{# return True if current hour is in the cheapest hour of any interval #}
{{ now().hour in min.cheapest_hours }}"
Podobne jako předchozí můj dotaz - včera jsem aktualizoval soubory v custom components doufaje, ze tyto errory zmizí.
Bohužel stále přetrvávají a update na ne neměl vliv.
Mam aktualizovat jeste jiné složky?
Problem je, ze se neaktualizuje cena pro danou hodinu. A klidne i několik hodin visí neplatná cena.
je to pouze u me?
dekuji
Logger: custom_components.cz_energy_spot_prices.coordinator
Source: helpers/update_coordinator.py:303
Integration: Czech Energy Spot Prices (documentation, issues)
First occurred: 19. listopadu 2023 20:00:02 (3 occurrences)
Last logged: 10:00:01
Error requesting Czech Energy Spot Prices data: Cannot connect to host www.ote-cr.cz:443 ssl:default [None]
Error requesting Czech Energy Spot Prices data: Cannot write to closing transport
The integration currently loads the data whenever HomeAssistant "wakes" it (note: need to investigate how often is it exactly). Given that the data should only need to be loaded once a day, it would make more sense to cache it and maybe just update it once in a while (once every hour maybe? Or is there no chance that the data will change during the day?)
Another problem is that the integration doesn't report anything when ote-cr.cz is down. It should be easy to fix it so it returns cached value. The cached value should also survive HA restart.
Hello, I have problem with instalation this integration.
I did everything according manual, but point 4 stuck me.
I have not found "Czech Energy Spot Prices" integratin in Settings -> Devices & Services -> Integration.
What can be wrong?
Snažím se přičítat ke spotovým cenám ještě cenu za distribuci podle HDO
nezdá se mi monetary
u device_class
Nevím zda je to podporované u HA.
home-assistant/core#86780
asi by měl být device_class
všude measurement
protože to není akumulace vydělaných/utracených peněz, ale měření aktuální ceny.
Je to v souboru custom_components/cz_energy_spot_prices/sensor.py:227
Podle mne je to důvod, proč entita sensor.current_spot_electricity_price
se v apex grafu ukazuje jako NaN
Logger: homeassistant.config
Source: config.py:505
First occurred: 15:24:10 (10 occurrences)
Last logged: 15:42:24
Invalid config for [template]: [hodinovka] is an invalid option for [template]. Check: template->hodinovka. (See /config/template.yaml, line 38).
Prosím o správný zapis do configu děkuji.
muj zapis https://pastebin.com/dUkC43fs
funkční zápis https://pastebin.com/3yych9ni
Dobrý den,
chtěl bych se zeptat, zda můžu nějak zjistit X nejlevnějších hodin v zadaném intervalu. Pokud správně chápu "Find cheapest hours in selected interval", tak to najde vždy jednu nejlevnější hodinu, ale já bych potřeboval najít např. 3 nebo 4 nejlevnější hodiny v intervalu 10-18hod.
Díky moc, Lukáš
Pár nápadů pro senzory které se diskutovaly v jiné issue. Měl jsem to ve svých poznámkách v angličtině tak to tak nechávám.
Purchase price (total price)
Add a sensor that will consider the SPOT price + distribution price per kWh. This needs to be able to consider the high and low tariffs. A helper may be controlled by external automation and always contain the actual distribution price per kWh. This will allow the users to have flexibility on the VT/NT data source (another integration, schedule, and hardware connected to the HDO-controlled circuit)
option to add a "spot market fee" price addon (ie 350czk/1MWh)
Sell price (export)
Additional price sensors (updated when the next day data are available)
This will allow the user to create flexible automation to control the consumption patterns
Dobrý den, po updatu mi píše HA
This entity (sensor.current_spot_electricity_price) is no longer being provided by the cz_energy_spot_prices integration. If the entity is no longer in use, delete it in settings.
Poradíte prosím?
Děkuji.
ahoj, mam to dnes nove, nastavil jsem entitu "Current Spot Electricity Price" pro elektrinu in i out.
Zda se ze in spotrebu pocita dobre, u out pretoku, je stale 0 CZK, i kdyz je pretok 7kWh, jedna se o data z predchozich dnu.
Poprve jsem nastavil omylem entitu "Current Spot Electricity hour order", je mozne ze se tam jiz zapsaly udaje, nemuze Vase integrace prepsat historicka data ?
Pockam na nove pretoky.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.