Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup fails for 2022.5.b0 #143

Closed
Skeletorjus opened this issue Apr 27, 2022 · 12 comments
Closed

Setup fails for 2022.5.b0 #143

Skeletorjus opened this issue Apr 27, 2022 · 12 comments
Labels
bug Something isn't working

Comments

@Skeletorjus
Copy link

Version of the custom_component

0.0.5

Homeassistant version

2022.5.0b0

Configuration

Describe the bug

Home Assistant throws an error while trying to setup the sensor,

Debug log


2022-04-27 21:49:15 ERROR (MainThread) [homeassistant.setup] Setup failed for custom integration nordpool: Unable to import component: cannot import name 'EVENT_TIME_CHANGED' from 'homeassistant.const' (/usr/src/homeassistant/homeassistant/const.py)

@gllmlbrt
Copy link

gllmlbrt commented Apr 28, 2022

Same issue for me, on Core Beta 2022.5.0b0.
Traced back to this breaking change made to the core for the beta: home-assistant/core#69643

@paarak
Copy link

paarak commented Apr 28, 2022

Same issue for me!
Home Assistant Core 2022.5.0b1
Home Assistant Supervisor 2022.04.4
Home Assistant OS 8.0.rc3
Kernel version 5.15.35
Agent version 1.2.1

`Logger: homeassistant.helpers.event
Source: helpers/template.py:411
First occurred: 21:21:59 (35 occurrences)
Last logged: 21:21:59

Error while processing template: Template("{% set l=state_attr('sensor.nordpool_kwh_oslo_nok_3_10_025', 'raw_today')|sort(attribute='value') %} {{ (now() >= l[0].start and now() <= l[0].end) or (now() >= l[1].start and now() <= l[1].end) or (now() >= l[2].start and now() <= l[2].end) or (now() >= l[3].start and now() <= l[3].end) or (now() >= l[4].start and now() <= l[4].end) or (now() >= l[5].start and now() <= l[5].end) or (now() >= l[6].start and now() <= l[6].end) or (now() >= l[7].start and now() <= l[7].end) or (now() >= l[8].start and now() <= l[8].end) or (now() >= l[9].start and now() <= l[9].end) or (now() >= l[10].start and now() <= l[10].end) or (now() >= l[11].start and now() <= l[11].end) or (now() >= l[12].start and now() <= l[12].end) or (now() >= l[13].start and now() <= l[13].end) or (now() >= l[14].start and now() <= l[14].end) or (now() >= l[15].start and now() <= l[15].end) or (now() >= l[16].start and now() <= l[16].end) or (now() >= l[17].start and now() <= l[17].end) or (now() >= l[18].start and now() <= l[18].end) or (now() >= l[19].start and now() <= l[19].end) or (now() >= l[20].start and now() <= l[20].end) }}")
Error while processing template: Template("{% set l=state_attr('sensor.nordpool_kwh_oslo_nok_3_10_025', 'raw_today')|sort(attribute='value') %} {{ (now() >= l[0].start and now() <= l[0].end) or (now() >= l[1].start and now() <= l[1].end) or (now() >= l[2].start and now() <= l[2].end) or (now() >= l[3].start and now() <= l[3].end) or (now() >= l[4].start and now() <= l[4].end) or (now() >= l[5].start and now() <= l[5].end) or (now() >= l[6].start and now() <= l[6].end) or (now() >= l[7].start and now() <= l[7].end) or (now() >= l[8].start and now() <= l[8].end) or (now() >= l[9].start and now() <= l[9].end) or (now() >= l[10].start and now() <= l[10].end) or (now() >= l[11].start and now() <= l[11].end) or (now() >= l[12].start and now() <= l[12].end) or (now() >= l[13].start and now() <= l[13].end) or (now() >= l[14].start and now() <= l[14].end) or (now() >= l[15].start and now() <= l[15].end) or (now() >= l[16].start and now() <= l[16].end) or (now() >= l[17].start and now() <= l[17].end) or (now() >= l[18].start and now() <= l[18].end) or (now() >= l[19].start and now() <= l[19].end) or (now() >= l[20].start and now() <= l[20].end) or (now() >= l[21].start and now() <= l[21].end) }}")
Error while processing template: Template("{% set l=state_attr('sensor.nordpool_kwh_oslo_nok_3_10_025', 'raw_today')|sort(attribute='value') %} {{ (now() >= l[0].start and now() <= l[0].end) or (now() >= l[1].start and now() <= l[1].end) or (now() >= l[2].start and now() <= l[2].end) or (now() >= l[3].start and now() <= l[3].end) or (now() >= l[4].start and now() <= l[4].end) or (now() >= l[5].start and now() <= l[5].end) or (now() >= l[6].start and now() <= l[6].end) or (now() >= l[7].start and now() <= l[7].end) or (now() >= l[8].start and now() <= l[8].end) or (now() >= l[9].start and now() <= l[9].end) or (now() >= l[10].start and now() <= l[10].end) or (now() >= l[11].start and now() <= l[11].end) or (now() >= l[12].start and now() <= l[12].end) or (now() >= l[13].start and now() <= l[13].end) or (now() >= l[14].start and now() <= l[14].end) or (now() >= l[15].start and now() <= l[15].end) or (now() >= l[16].start and now() <= l[16].end) or (now() >= l[17].start and now() <= l[17].end) or (now() >= l[18].start and now() <= l[18].end) or (now() >= l[19].start and now() <= l[19].end) or (now() >= l[20].start and now() <= l[20].end) or (now() >= l[21].start and now() <= l[21].end) or (now() >= l[22].start and now() <= l[22].end) }}")
Error while processing template: Template("{% set l=state_attr('sensor.nordpool_kwh_oslo_nok_3_10_025', 'raw_today')|sort(attribute='value') %} {{ (now() >= l[0].start and now() <= l[0].end) or (now() >= l[1].start and now() <= l[1].end) or (now() >= l[2].start and now() <= l[2].end) or (now() >= l[3].start and now() <= l[3].end) or (now() >= l[4].start and now() <= l[4].end) or (now() >= l[5].start and now() <= l[5].end) or (now() >= l[6].start and now() <= l[6].end) or (now() >= l[7].start and now() <= l[7].end) or (now() >= l[8].start and now() <= l[8].end) or (now() >= l[9].start and now() <= l[9].end) or (now() >= l[10].start and now() <= l[10].end) or (now() >= l[11].start and now() <= l[11].end) or (now() >= l[12].start and now() <= l[12].end) or (now() >= l[13].start and now() <= l[13].end) or (now() >= l[14].start and now() <= l[14].end) or (now() >= l[15].start and now() <= l[15].end) or (now() >= l[16].start and now() <= l[16].end) or (now() >= l[17].start and now() <= l[17].end) or (now() >= l[18].start and now() <= l[18].end) or (now() >= l[19].start and now() <= l[19].end) or (now() >= l[20].start and now() <= l[20].end) or (now() >= l[21].start and now() <= l[21].end) or (now() >= l[22].start and now() <= l[22].end) or (now() >= l[23].start and now() <= l[23].end) }}")
Error while processing template: Template("{% set today_price = state_attr('sensor.nordpool_kwh_oslo_nok_3_10_025','today') %} {% set current = state_attr('sensor.nordpool_kwh_oslo_nok_3_10_025', 'current_price') %} {% set number_of_hours = states('input_number.number_of_hours') | int %} {% set max_price = states('input_number.max_price') | float %} {% if number_of_hours == 0 %} {% set price_limit = 0 %} {% else %} {% set price_limit = (today_price | sort)[number_of_hours-1] %} {% endif %} {% set limit = ([ price_limit, max_price ]) | min %} {{current <= limit}}")
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 409, in async_render
render_result = _render_with_context(self.template, compiled, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1858, in _render_with_context
return template.render(**kwargs)
File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 1291, in render
self.environment.handle_exception()
File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 926, in handle_exception
raise rewrite_traceback_stack(source=source)
File "", line 1, in top-level template code
File "/usr/local/lib/python3.9/site-packages/jinja2/filters.py", line 409, in do_sort
return sorted(value, key=key_func, reverse=reverse)
TypeError: 'NoneType' object is not iterable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 525, in async_render_to_info
render_info._result = self.async_render(variables, strict=strict, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 411, in async_render
raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: TypeError: 'NoneType' object is not iterable
`

@Hellowlol Hellowlol added the bug Something isn't working label Apr 28, 2022
@Klangen82
Copy link

Is there any plan to transition to the built-in event helpers? Sounds like a small change but I'm not a programmer:( "in most cases, a one-line drop-in replacement"

https://developers.home-assistant.io/blog/2022/04/20/saying-goodbye-to-event_time_changed/

@Hellowlol
Copy link
Collaborator

Hellowlol commented May 2, 2022

I haven't had time to investigate it. But I highly doubt we can just drop in and replace it, as I have modified the code to support other timezones.

@Klangen82
Copy link

I believe you when you say that, as I said not a programmer:/ It's just that the integration will not work when they release 2022-05 version. You have UTC time changes so I guess this should work with times zones, but again that do I know. Please let me know if there is anything I can do or help and I will try my best.

image

@Hellowlol
Copy link
Collaborator

Anybody want to test #145 ? This should work with the latest dev version

@Skeletorjus
Copy link
Author

Anybody want to test #145 ? This should work with the latest dev version

Maybe I did something wrong, but I couldn't get it to work.

2022-05-03 23:07:42 ERROR (MainThread) [homeassistant.loader] Unexpected exception importing platform custom_components.nordpool.config_flow
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 603, in get_platform
    cache[full_name] = self._import_platform(platform_name)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 620, 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 972, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  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 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/config/custom_components/nordpool/__init__.py", line 17, in <module>    from .events import async_track_time_change_in_tz
  File "/config/custom_components/nordpool/events.py", line 31, in <module>
    action: Callable[[datetime], Awaitable[None] | None],
TypeError: unsupported operand type(s) for |: 'types.GenericAlias' and 'NoneType'
2022-05-03 23:07:42 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading configuration flow for integration nordpool: Exception importing custom_components.nordpool.config_flow

@aherbjornsen
Copy link

It would be easier for me to test this if it showed up as a beta version in HACS.

I manually copied the 4 changed files from 0.0.6 and got the same error as Skeletorjus.

@Klangen82
Copy link

Same here, I tested with HA version 2022.5.0b7.

@KennethSeiero
Copy link

Same here, this is no longer just the beta version. I'm on the official branch, and my nordpool just stopped working after 2022.5.0 update

@Hellowlol
Copy link
Collaborator

That's strange, that typing signature is copied directly from homeassistant and works fine in my dev docker. What python version are you running?

@Klangen82
Copy link

Thanks @Hellowlol for fixing this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants