asosnovsky / Shortumation

[Not Maintained] A better way to write automations in home-assistant without having to install and run a seperate automation engine!
MIT License
302 stars 7 forks source link

AssertionError: configurations.homeassistant.packages[media_player] must be a dictionary! #159

Open asosnovsky opened 1 year ago

asosnovsky commented 1 year ago

I'm having the same issue. Running v7.0 on latest beta 2022.9.0b1. Installed as Add On. I have my automation integration as a package: folder/integration.yaml in which I include the main integrations.yaml from the root of my config folder. Logging says:

2022-09-01:15:28:31|ERROR[/usr/local/lib/python3.10/site-packages/hypercorn/logging.py:100@exception] Error in ASGI Framework
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/hypercorn/asyncio/task_group.py", line 21, in _handle
    await invoke_asgi(app, scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/hypercorn/utils.py", line 247, in invoke_asgi
    await app(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/fastapi/applications.py", line 269, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/applications.py", line 124, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/cors.py", line 92, in __call__
    await self.simple_response(scope, receive, send, request_headers=headers)
  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/cors.py", line 147, in simple_response
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/exceptions.py", line 93, in __call__
    raise exc
  File "/usr/local/lib/python3.10/site-packages/starlette/exceptions.py", line 82, in __call__
    await self.app(scope, receive, sender)
  File "/usr/local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/usr/local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 670, in __call__
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 266, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 65, in app
    response = await func(request)
  File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 227, in app
    raw_response = await run_endpoint_function(
  File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 162, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/usr/local/lib/python3.10/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "/usr/local/lib/python3.10/site-packages/anyio/to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "/app/src/api/routes/automations.py", line 18, in list_autos
    automations.reload()
  File "/app/src/automations/manager.py", line 45, in reload
    batch.append(next(auto_it))
  File "/app/src/automations/loader.py", line 37, in load_and_iter_automations
    for ref in extract_automation_refs(hass_config):
  File "/app/src/automations/loader.py", line 59, in extract_automation_refs
    for ref in chain(
  File "/app/src/automations/loader.py", line 100, in extract_automation_package_refs
    yield from extract_automation_inline_package_refs(
  File "/app/src/automations/loader.py", line 172, in extract_automation_inline_package_refs
    raise AssertionError(
AssertionError: configurations.homeassistant.packages[media_player] must be a dictionary!

Originally posted by @Sholofly in https://github.com/asosnovsky/Shortumation/issues/149#issuecomment-1234279898

asosnovsky commented 1 year ago

@Sholofly moved the issue here

asosnovsky commented 1 year ago

I reviewed your issue a bit more. I am pretty sure that you have an invalid configuration file.

Packages should always map to a dictionary of overrides. When using the same configuration as you I get this error in HA (which tracks with the error I am throwing in Shortumation) image

Sholofly commented 1 year ago

My config validates fine in HA.

configuration.yaml:

homeassistant:
  packages: !include_dir_named integrations

../integrations/automation.yaml:

automation: !include ../automations.yaml
Sholofly commented 1 year ago

I even removed de media_player package file (it was commented out :) and the problem still exists.

Sholofly commented 1 year ago

Ok, I readded the media_player package file and uncommented the include_dir_list that points to an empty directory. Now it works. It looks like the media_player integration must be present all the time, even when you don't use it. Thats strange.

asosnovsky commented 1 year ago

@Sholofly can you share what you mean? How did the media player integration look like on your config?

uSlackr commented 1 year ago

I'm getting a similar error AssertionError: configurations.homeassistant.packages[mudroom_lovelace] must be a dictionary! HA is OK with the config. This file is generated by the keymaster integration (from HACS). IIRC< this file isn't actually used by H. I had to copy the contents into a dashboard to build the interface. I renamed it to .txt but got the same error

asosnovsky commented 1 year ago

@uSlackr ive updated v0.7.4 to ignore non yaml files now so your issue should be fixed.

@Sholofly do you mind sharing more about your config and also confirm if your issue is resolved in the new version?

uSlackr commented 1 year ago

I can do so tomorrow. I moved the bad file out of the directory since it was not being used.

Thanks for the assist!

\Greg


From: Ari Sosnovsky @.> Sent: Saturday, September 3, 2022 3:00:58 PM To: asosnovsky/Shortumation @.> Cc: uSlackr @.>; Mention @.> Subject: Re: [asosnovsky/Shortumation] AssertionError: configurations.homeassistant.packages[media_player] must be a dictionary! (Issue #159)

@uSlackrhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FuSlackr&data=05%7C01%7C%7C85dadfff0f734a73977a08da8ddea430%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637978284623933086%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=MKhqiH2HOVixub1nPI7CDPDXMNB0k4nGKWWhXCwU6c8%3D&reserved=0 ive updated v0.7.4 to ignore non yaml files now so your issue should be fixed.

@Sholoflyhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FSholofly&data=05%7C01%7C%7C85dadfff0f734a73977a08da8ddea430%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637978284623933086%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=GEs6MT8WUCYo45Uutmq5DPPSb2YdkuSGv6w6pacrYXM%3D&reserved=0 do you mind sharing more about your config and also confirm if your issue is resolved in the new version?

— Reply to this email directly, view it on GitHubhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fasosnovsky%2FShortumation%2Fissues%2F159%23issuecomment-1236182616&data=05%7C01%7C%7C85dadfff0f734a73977a08da8ddea430%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637978284623933086%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=5Xd2komosjhcDJ%2FQDut3CXNGVvniEGFs5%2B3%2FpFLJHBA%3D&reserved=0, or unsubscribehttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGEO6Z3T45ICDIJGKDSZJDLV4ON6VANCNFSM6AAAAAAQCXMZDI&data=05%7C01%7C%7C85dadfff0f734a73977a08da8ddea430%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637978284623933086%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=5ucmnkfEGmNPIfGp77BBwhD8BMm6sQlLLttV8h0VOiY%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

Sholofly commented 1 year ago

@asosnovsky

Sorry for the late reply.

I'm including packages.

media_player.yaml

################################################
## Integrations / Media Player
################################################
# media_player: !include_dir_list ../entities/media_players

still doesn't work. If i try to load shortumation it gives me the error on the frontend as described in #162. and in the logs: [AssertionError: configurations.homeassistant.packages[media_player] must be a dictionary!]

################################################
## Integrations / Media Player
################################################
media_player: !include_dir_list ../entities/media_players

does work

In both cases the folder ../entities/media_players is empty

Both validate fine in HA.

barto95100 commented 1 year ago

the same problem

this is log 👍

   await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/exceptions.py", line 93, in __call__
    raise exc
  File "/usr/local/lib/python3.10/site-packages/starlette/exceptions.py", line 82, in __call__
    await self.app(scope, receive, sender)
  File "/usr/local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/usr/local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 670, in __call__
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 266, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 65, in app
    response = await func(request)
  File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 227, in app
    raw_response = await run_endpoint_function(
  File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 162, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/usr/local/lib/python3.10/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "/usr/local/lib/python3.10/site-packages/anyio/to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "/app/src/api/routes/automations.py", line 18, in list_autos
    automations.reload()
  File "/app/src/automations/manager.py", line 45, in reload
    batch.append(next(auto_it))
  File "/app/src/automations/loader.py", line 37, in load_and_iter_automations
    for ref in extract_automation_refs(hass_config):
  File "/app/src/automations/loader.py", line 59, in extract_automation_refs
    for ref in chain(
  File "/app/src/automations/loader.py", line 100, in extract_automation_package_refs
    yield from extract_automation_inline_package_refs(
  File "/app/src/automations/loader.py", line 172, in extract_automation_inline_package_refs
    raise AssertionError(
AssertionError: configurations.homeassistant.packages[spotify] must be a dictionary!
2022-09-07:11:37:24|ERROR[/usr/local/lib/python3.10/site-packages/hypercorn/logging.py:100@exception] Error in ASGI Framework
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/hypercorn/asyncio/task_group.py", line 21, in _handle
    await invoke_asgi(app, scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/hypercorn/utils.py", line 247, in invoke_asgi
    await app(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/fastapi/applications.py", line 269, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/applications.py", line 124, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/cors.py", line 92, in __call__
    await self.simple_response(scope, receive, send, request_headers=headers)
  File "/usr/local/lib/python3.10/site-packages/starlette/middleware/cors.py", line 147, in simple_response
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/exceptions.py", line 93, in __call__
    raise exc
  File "/usr/local/lib/python3.10/site-packages/starlette/exceptions.py", line 82, in __call__
    await self.app(scope, receive, sender)
  File "/usr/local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
    raise e
  File "/usr/local/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 670, in __call__
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 266, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 65, in app
    response = await func(request)
  File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 227, in app
    raw_response = await run_endpoint_function(
  File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 162, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/usr/local/lib/python3.10/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "/usr/local/lib/python3.10/site-packages/anyio/to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "/app/src/api/routes/automations.py", line 18, in list_autos
    automations.reload()
  File "/app/src/automations/manager.py", line 45, in reload
    batch.append(next(auto_it))
  File "/app/src/automations/loader.py", line 37, in load_and_iter_automations
    for ref in extract_automation_refs(hass_config):
  File "/app/src/automations/loader.py", line 59, in extract_automation_refs
    for ref in chain(
  File "/app/src/automations/loader.py", line 100, in extract_automation_package_refs
    yield from extract_automation_inline_package_refs(
  File "/app/src/automations/loader.py", line 172, in extract_automation_inline_package_refs
    raise AssertionError(
AssertionError: configurations.homeassistant.packages[spotify] must be a dictionary!
2022-09-07:11:37:48|INFO[/app/src/api/routes/socket.py:30@wait_for_data] Websocket closed.
2022-09-07:11:37:48|INFO[/app/src/ws_redirect/__init__.py:52@start] Closing socket...
2022-09-07:11:37:48|INFO[/app/src/ws_redirect/__init__.py:54@start] Closed socket`
asosnovsky commented 1 year ago

@Sholofly @barto95100 @uSlackr please try to update to v0.7.6

if you still have the issue repost logs, and confirm that you setup matches these or not (tried to reproduce the issue)

https://github.com/asosnovsky/Shortumation/tree/main/api/tests/samples/config-14 https://github.com/asosnovsky/Shortumation/tree/main/api/tests/samples/config-15 https://github.com/asosnovsky/Shortumation/tree/main/api/tests/samples/config-16 https://github.com/asosnovsky/Shortumation/tree/main/api/tests/samples/config-17

ezfrag2021 commented 1 year ago

Since the update to 0.7.6. The error message has changed to:

(["automation id '1657099393999' in 'automations.yaml' was already seen before. Please check for duplicate automation ids in your files."],)

I have checked and this is not a duplicate anywhere in the file. I tried changing the ID to something random and still get the duplicate error.

Shortumation Log.txt