jpulakka / nordpool_diff

Transforms electricity spot price into thermostat control signal. Home Assistant custom component.
MIT License
63 stars 7 forks source link

Using nordpool as a backup dosn't seem to work #23

Closed SVH-Powel closed 1 year ago

SVH-Powel commented 1 year ago

image

2022-10-31 14:48:39.622 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.nordpool_diff_rank_10_normalize_max_min fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 515, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 710, in async_device_update raise exc File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/nordpool_diff/sensor.py", line 139, in update prices = self._get_next_n_hours(self._filter_length + 1) # +1 to calculate next hour File "/config/custom_components/nordpool_diff/sensor.py", line 148, in _get_next_n_hours prices = _get_next_n_hours_from_entsoe(n, e) File "/config/custom_components/nordpool_diff/sensor.py", line 83, in _get_next_n_hours_from_entsoe if p := e.attributes["prices"]: KeyError: 'prices'

image

jpulakka commented 1 year ago

@SVH-Powel Can you try tip of master, if it works for you? I don't have access to my hass right now..

stigvi commented 1 year ago

No worries. This lasted for a few minutes and I wasn't able to test anything. But I can test it later, maybe tomorrow

jpulakka commented 1 year ago

Yep, so indeed the fallback didn't work if hass-entsoe sensor was missing the whole "prices" attribute, which probably can happen if entsoe API is down at the moment when hass-entsoe is started, or something.

Thanks for reporting this!

That is now fixed, error handling is much more robust. I'll release 0.2.1 with this soon.