rnovacek / homeassistant_cz_energy_spot_prices

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

incorrect electricity prices #48

Closed kreuzj closed 9 months ago

kreuzj commented 9 months ago

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

image

... and here are prices shown on OTE (https://www.ote-cr.cz/)

image

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

rnovacek commented 9 months ago

The prices look correct to me: 0:00 35.79 24.725 = 884.90775 CZK/MWh = 0.88 CZK/kWh - same as the chart show, HA shows 0.88 1:00 12.97 24.725 = 320.68325 - HA shows 0.32 15:00 20.37 * 24.725 = 503.64825 - HA shows 0.5

Please mind that what OTE shows as hour 1 is actually 0:00 - 1:00 (first hour of the day).

The connectivity has 10 seconds timeout, which might be too low is some cases. Nevertheless it should retry when it fails.

kreuzj commented 9 months ago

thanks for prompt reply and explanation. Also pls. accept my apologize for this stupid question - not sure why but used incorrect formula in my manual calculation :-(

rnovacek commented 9 months ago

No worries :)