bruxy70 / Holidays

📅 Custom Home Assistant integration for public holidays - also used for garbage_collection integration to automatically move scheduled events that fall on a public holiday (by an automation blueprint)
MIT License
45 stars 12 forks source link

Creating a new "Holidays" helper fails #41

Closed stefanuytterhoeven closed 1 year ago

stefanuytterhoeven commented 1 year ago

Before you submit a new bug report, please check that

Describe the bug

Saw "holidays" in the helpers section. When I tried to create a new "holidays" helper, I got the message: (translated to englisch) Config-flow could not be loaded: 500 Internal Server Error Server got itself in trouble

It's not that I use this a lot, so, don't know when it started to fail.

Configuration

My setup: typical HASSOS setup on RPI4
Hacs installed (latest version at 9 decemember 2022)
Home Assistant 2022.12.0
Supervisor 2022.11.2
Operating System 9.3
Frontend-versie: 20221207.0 - latest

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2022.12.0",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.10.7",
    "docker": true,
    "arch": "aarch64",
    "timezone": "Europe/Brussels",
    "os_name": "Linux",
    "os_version": "5.15.61-v8",
    "supervisor": "2022.11.2",
    "host_os": "Home Assistant OS 9.3",
    "docker_version": "20.10.18",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {
    "pyscript": {
      "version": "1.3.3",
      "requirements": [
        "croniter==1.3.4",
        "watchdog==2.1.6"
      ]
    },
    "afvalbeheer": {
      "version": "5.0.10",
      "requirements": [
        "rsa",
        "pycryptodome"
      ]
    },
    "hpprinter": {
      "version": "1.0.8",
      "requirements": [
        "xmltodict==0.12.0"
      ]
    },
    "hacs": {
      "version": "1.28.4",
      "requirements": [
        "aiogithubapi>=22.2.4"
      ]
    },
    "holidays": {
      "version": "1.8.0",
      "requirements": [
        "python-dateutil>=2.8.2",
        "holidays>=0.14.2"
      ]
    },
    "lghorizon": {
      "version": "0.3.5",
      "requirements": [
        "lghorizon>=0.5.6"
      ]
    },
    "watchman": {
      "version": "0.5.1",
      "requirements": [
        "prettytable==3.0.0"
      ]
    },
    "rpi_gpio": {
      "version": "2022.7.0",
      "requirements": [
        "RPi.GPIO==0.7.1"
      ]
    },
    "multiscrape": {
      "version": "6.5.0",
      "requirements": [
        "lxml==4.9.1",
        "beautifulsoup4==4.11.1"
      ]
    },
    "nest_protect": {
      "version": "0.3.8",
      "requirements": []
    },
    "arris_dcx960": {
      "version": "1.2.0",
      "requirements": [
        "arris-dcx960==0.2.1"
      ]
    }
  },
  "integration_manifest": {
    "domain": "holidays",
    "name": "Holidays",
    "version": "1.8.0",
    "documentation": "https://github.com/bruxy70/Holidays/",
    "issue_tracker": "https://github.com/bruxy70/Holidays/issues",
    "iot_class": "calculated",
    "integration_type": "helper",
    "dependencies": [],
    "config_flow": true,
    "codeowners": [
      "@bruxy70"
    ],
    "requirements": [
      "python-dateutil>=2.8.2",
      "holidays>=0.14.2"
    ],
    "is_built_in": false
  },
  "data": {
    "entity_id": "calendar.kalenderdagen001",
    "state": 16,
    "attributes": {
      "next_date": "2022-12-25T00:00:00+01:00",
      "next_holiday": "Kerstmis",
      "last_updated": "2022-12-09T00:00:02.732390+01:00",
      "holidays": {
        "2021-01-01": "Nieuwjaarsdag",
        "2021-04-04": "Pasen",
        "2021-04-05": "Paasmaandag",
        "2021-05-01": "Dag van de Arbeid",
        "2021-05-13": "O.L.H. Hemelvaart",
        "2021-05-23": "Pinksteren",
        "2021-05-24": "Pinkstermaandag",
        "2021-07-21": "Nationale feestdag",
        "2021-08-15": "O.L.V. Hemelvaart",
        "2021-11-01": "Allerheiligen",
        "2021-11-11": "Wapenstilstand",
        "2021-12-25": "Kerstmis",
        "2022-01-01": "Nieuwjaarsdag",
        "2022-04-17": "Pasen",
        "2022-04-18": "Paasmaandag",
        "2022-05-01": "Dag van de Arbeid",
        "2022-05-26": "O.L.H. Hemelvaart",
        "2022-06-05": "Pinksteren",
        "2022-06-06": "Pinkstermaandag",
        "2022-07-21": "Nationale feestdag",
        "2022-08-15": "O.L.V. Hemelvaart",
        "2022-11-01": "Allerheiligen",
        "2022-11-11": "Wapenstilstand",
        "2022-12-25": "Kerstmis",
        "2023-01-01": "Nieuwjaarsdag",
        "2023-04-09": "Pasen",
        "2023-04-10": "Paasmaandag",
        "2023-05-01": "Dag van de Arbeid",
        "2023-05-18": "O.L.H. Hemelvaart",
        "2023-05-28": "Pinksteren",
        "2023-05-29": "Pinkstermaandag",
        "2023-07-21": "Nationale feestdag",
        "2023-08-15": "O.L.V. Hemelvaart",
        "2023-11-01": "Allerheiligen",
        "2023-11-11": "Wapenstilstand",
        "2023-12-25": "Kerstmis"
      }
    },
    "config_entry": {
      "entry_id": "3da8714963e07553891b4409587704ba",
      "version": 3,
      "domain": "holidays",
      "title": "Kalenderdagen001",
      "data": {
        "unique_id": "5398aced-5475-4323-b6cc-aa35024e7e68",
        "observed": true
      },
      "options": {
        "icon_normal": "mdi:calendar-blank",
        "icon_today": "mdi:calendar-arrow-right",
        "icon_tomorrow": "mdi:calendar-check",
        "country": "BE"
      },
      "pref_disable_new_entities": false,
      "pref_disable_polling": false,
      "source": "user",
      "unique_id": null,
      "disabled_by": null
    }
  }
}

Debug logs

2022-12-09 07:21:17.746 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
resp = await request_handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 81, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/api/__init__.py", line 204, in post
data = await request.json()
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_request.py", line 670, in json
body = await self.text()
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_request.py", line 664, in text
bytes_body = await self.read()
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_request.py", line 649, in read
chunk = await self._payload.readany()
File "/usr/local/lib/python3.10/site-packages/aiohttp/streams.py", line 397, in readany
await self._wait("readany")
File "/usr/local/lib/python3.10/site-packages/aiohttp/streams.py", line 306, in _wait
await waiter
ConnectionResetError: Connection lost
2022-12-09 07:56:22.912 INFO (MainThread) [custom_components.pyscript.apps.waskot_auto_light.waskot_auto_light_off] turning off
2022-12-09 07:56:27.917 INFO (MainThread) [custom_components.pyscript.apps.waskot_auto_light.waskot_auto_light_off] waskot_auto_light changed from on to off
2022-12-09 08:11:28.251 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
resp = await request_handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 81, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 148, in post
return await super().post(request)
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, in wrapper
result = await method(view, request, data, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 71, in post
result = await self._flow_mgr.async_init(
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 226, in async_init
flow, result = await task
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 253, in _async_init
result = await self._async_handle_step(flow, flow.init_step, data, init_done)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 368, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
File "/usr/src/homeassistant/homeassistant/helpers/schema_config_entry_flow.py", line 305, in _async_step
result = await self._common_handler.async_step(step_id, user_input)
File "/usr/src/homeassistant/homeassistant/helpers/schema_config_entry_flow.py", line 129, in async_step
return await self._async_form_step(step_id, user_input)
File "/usr/src/homeassistant/homeassistant/helpers/schema_config_entry_flow.py", line 176, in _async_form_step
return await self._show_next_step(step_id)
File "/usr/src/homeassistant/homeassistant/helpers/schema_config_entry_flow.py", line 209, in _show_next_step
if (data_schema := await self._get_schema(form_step)) is None:
File "/usr/src/homeassistant/homeassistant/helpers/schema_config_entry_flow.py", line 137, in _get_schema
return await form_step.schema(self)
TypeError: general_config_schema() missing 1 required positional argument: 'options'
2022-12-09 08:14:49.750 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
resp = await request_handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
resp = await handler(request)
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 81, in ban_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
return await handler(request)
File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 136, in handle
result = await result
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 148, in post
return await super().post(request)
File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, in wrapper
result = await method(view, request, data, *args, **kwargs)
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 71, in post
result = await self._flow_mgr.async_init(
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 226, in async_init
flow, result = await task
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 253, in _async_init
result = await self._async_handle_step(flow, flow.init_step, data, init_done)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 368, in _async_handle_step
result: FlowResult = await getattr(flow, method)(user_input)
File "/usr/src/homeassistant/homeassistant/helpers/schema_config_entry_flow.py", line 305, in _async_step
result = await self._common_handler.async_step(step_id, user_input)
File "/usr/src/homeassistant/homeassistant/helpers/schema_config_entry_flow.py", line 129, in async_step
return await self._async_form_step(step_id, user_input)
File "/usr/src/homeassistant/homeassistant/helpers/schema_config_entry_flow.py", line 176, in _async_form_step
return await self._show_next_step(step_id)
File "/usr/src/homeassistant/homeassistant/helpers/schema_config_entry_flow.py", line 209, in _show_next_step
if (data_schema := await self._get_schema(form_step)) is None:
File "/usr/src/homeassistant/homeassistant/helpers/schema_config_entry_flow.py", line 137, in _get_schema
return await form_step.schema(self)
TypeError: general_config_schema() missing 1 required positional argument: 'options'
reaper7 commented 1 year ago

I have a latest 1.9.0 release but the error persists holidays

badewanne1234 commented 1 year ago

Same here @reaper7 , I also got "Unknown Error Occured". I tried to setup the helper for a country with no Subdivisions available (country: LI). When setting up the helper for a country with available subdivisions (CH), it works. @bruxy70 could it be that there is an issue with countries where no subdivisions are available? Thanks

gmusa commented 1 year ago

same issue here trying to add Argentinean holidays that also doesn't have subdivision information.

bruxy70 commented 1 year ago

Can you try 1.9.1b1 beta release? I have some issues with unit testing, but tested manually and it should be working.

badewanne1234 commented 1 year ago

I can confirm its working, just tested it right now - awesome!

JAudi23 commented 1 year ago

I'm currently running v1.9.1 and am getting the following error on the first helper page step. "Unknown error occurred" I enter a Friendly Name of "Canada Holidays" and whether I select "CA", "CAN", or "Canada" as my Country selection. Any advice on this?

bruxy70 commented 1 year ago

I have tested, and I do not get errors. Also, I do not get "CAN" or "Canada" as a Country. Not sure where these options are coming from. Looks almost like an old holidays package. You have the HA OS type installation with 2022.12 Home Assistant, correct?

JAudi23 commented 1 year ago

Latest version of Home Assistant is installed:

Home Assistant 2022.12.7
Supervisor 2022.11.2
Operating System 9.4
Frontend 20221213.1 - latest

Screenshot 2022-12-20 171610 Screenshot 2022-12-20 171418

bruxy70 commented 1 year ago

Ok. That's what it should look like

image

Do you have any custom integration that perhaps depends on an older version of holidays package? From Home Assistant core, the holidays package is also used the workday binary sensor. There used to be a similar issue in the past that somebody had an older version of that integration. But if not, I do not have other explanation where it could come from.

JAudi23 commented 1 year ago

I do have the Garbage Collection integration installed which I think relies on the Holiday integration. I'll take a look and see if that could be the issue.