JaccoR / hass-entso-e

Integration for Home Assistant to fetch day ahead energy prices from European countries via ENTSO-e Transparency Platform
159 stars 25 forks source link

entso-e data not updating #68

Closed whulshof closed 1 year ago

whulshof commented 1 year ago

I'm getting "can't multiply sequence by non-int of type 'float'" in the integration tile. No data for today or tomorrow

< 2022-11-06 14:14:38.950 ERROR (MainThread) [custom_components.entsoe.coordinator] Unexpected error fetching ENTSO-e coordinator data: can't multiply sequence by non-int of type 'float' File "/config/custom_components/entsoe/coordinator.py", line 100, in _async_update_data File "/config/custom_components/entsoe/coordinator.py", line 85, in parse_hourprices File "/config/custom_components/entsoe/coordinator.py", line 79, in calc_price 2022-11-06 14:14:38.962 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Day Ahead Prices' for entsoe integration not ready yet: can't multiply sequence by non-int of type 'float'; Retrying in background 2022-11-06 14:14:45.878 ERROR (MainThread) [custom_components.entsoe.coordinator] Unexpected error fetching ENTSO-e coordinator data: can't multiply sequence by non-int of type 'float' File "/config/custom_components/entsoe/coordinator.py", line 100, in _async_update_data File "/config/custom_components/entsoe/coordinator.py", line 85, in parse_hourprices File "/config/custom_components/entsoe/coordinator.py", line 79, in calc_price >

sfstar commented 1 year ago

See #69

sfstar commented 1 year ago

I'm having the same issue. It's caused by entsoe returning E-notation pricing for the netherlands. Thereby causing python to treat the api returned value as an str that is passed to the rounding function (that strips up to the last 5 digits of a price). By instructing (casting) the value to float explicitly it's working again on my instance. @JaccoR Could you merge my PR and make an emergency release? Since all dutch users will have a broken integration until this fix is released or until there are no more prices E notation in them

sfstar commented 1 year ago

For anybody reading this you could clone this branch/repo and copy it's contents to your custom_components directory. Then do a restart and then everything will work until jaccor releases an new version with my fix (or the upcoming days don't contain E notation pricing)

sfstar commented 1 year ago

When the new release is made you can just update via hacs again to overwrite the changes made by the copying action

pieter-1978 commented 1 year ago

@sfstar I added 'float" in the coordinator.py file and restarted but without success. I changed the file by using file editor

below my changed coordinator.py, did I do something wrong?

    template_value = self.modifyer.async_render(now=faker(), current_price=price)
    else:
        template_value = self.modifyer.async_render()

    price = round(float(template_value * (1 + self.vat)), 5)

    return price
sfstar commented 1 year ago

Just to check:

pieter-1978 commented 1 year ago

Hi,

answer on both your questions are yes, below the error message:

Logger: custom_components.entsoe.coordinator Source: custom_components/entsoe/coordinator.py:74 Integration: ENTSO-e Transparency Platform (documentation, issues) First occurred: 5:17:30 PM (4 occurrences) Last logged: 5:18:16 PM

Unexpected error fetching ENTSO-e coordinator data: can't multiply sequence by non-int of type 'float' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh self.data = await self._async_update_data() File "/config/custom_components/entsoe/coordinator.py", line 96, in _async_update_data parsed_data = self.parse_hourprices(data) File "/config/custom_components/entsoe/coordinator.py", line 80, in parse_hourprices hourprices[hour] = self.calc_price(value=price, fake_dt=hour) File "/config/custom_components/entsoe/coordinator.py", line 74, in calc_price price = round(float(template_value * (1 + self.vat)), 5) TypeError: can't multiply sequence by non-int of type 'float'

sfstar commented 1 year ago

Just got another idea what it might be: are you using a custom template for calculating the costs? If so it might be that for the vat multiplication it is also getting an str multiplication error

sfstar commented 1 year ago

ow gg, yeah that is it try changing: price = round(float(template_value * (1 + self.vat)), 5) to price = round(float(template_value) * (1 + self.vat), 5)

sfstar commented 1 year ago

If that works for your case I'll be updating my pr so that it's also working for custom template users

pieter-1978 commented 1 year ago

many thanks! price = round(float(template_value) * (1 + self.vat), 5) did the trick!

JaccoR commented 1 year ago

Had little time today, so i just merged an did a new release. Just saw your message @sfstar . So i think your update was not included..

sfstar commented 1 year ago

You were just 2 minutes to early @JaccoR

sfstar commented 1 year ago

I can re-open a PR or you could change it on main (if you like)

JaccoR commented 1 year ago

You can reopen a pr, ill approve right away, am on my phone atm

sfstar commented 1 year ago

This is the PR https://github.com/JaccoR/hass-entso-e/pull/70 should have done PR 70 originally, but I though hey to be sure that vat is also correctly interpreted include it in the cast. So in short should have gone with my first instinct :)

sfstar commented 1 year ago

Great thank you :)

sfstar commented 1 year ago

Thanks for merging, are you capable (on mobile) of making a release? (never had to do that myself - on mobile)

Edit: nvm, see that the release was made. Thanks for logging in on mobile :)

sfstar commented 1 year ago

@JaccoR are you going to re-tag the 0.1.3 release or create an 0.1.4 release so that the PR 70 is also included?

whulshof commented 1 year ago

works like a charm again! Thanks, guys.