mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-05-09 05:35:30 +02:00
[GH-ISSUE #214] [Bug]: Adding scripts from HA and problems deleting printers #133
Labels
No labels
A1
automated
automated
bug
bug
Closed due to inactivity
contrib
dependencies
dependencies
duplicate
enhancement
feedback
hold
invalid
Notes
P1S
pull-request
security
security
ThumbsUp
user-report
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/bambuddy#133
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @IROKILLER on GitHub (Feb 1, 2026).
Original GitHub issue: https://github.com/maziggy/bambuddy/issues/214
Originally assigned to: @maziggy on GitHub.
Bug Description
I tried to see if the new version's feature that allows you to bind multiple Home Assistant scripts to the printer worked. You can add multiple scripts to Bambuddy, but you can only bind one to the printer at a time. Therefore, I tried to remove the printer and found that Bambuddy completely froze, requiring a full restart.
Expected Behavior
That the function works as I tested it in feature/176
Steps to Reproduce
HA Problem
Settings - Smart Plug - +Add Smart Plug - HA - Script entity input - Link to Printer
Printer
Printer - the 3 dots in the upper right - Delete
Printer Model
A1
Bambuddy Version
0.1.6
Printer Firmware Version
01.07.02.00
Installation Method
Docker
Operating System
Docker
Relevant Logs / Support Package
bambuddy-support-20260201-121018.zip
Screenshots
from the current version

from yesterday's tested version
Additional Context
No response
Checklist
@maziggy commented on GitHub (Feb 1, 2026):
Fixed in branch 0.1.7b. Please check and let me know. Thanks!!!
@IROKILLER commented on GitHub (Feb 2, 2026):
Deleting the printer is possible, but assigning the HA script is only possible once.
after the update from 0.1.6.2
@maziggy commented on GitHub (Feb 3, 2026):
This was not merged into the last release :(
Fixed in branch 0.1.7b. Please let me know if it works.
@IROKILLER commented on GitHub (Feb 3, 2026):
HAScript is throwing a new error. And unfortunately, deleting the printer is no longer possible either.
bambuddy-support-20260203-150924.zip
@maziggy commented on GitHub (Feb 3, 2026):
Use just release version. There are some fixes which unfortunately didn't make it to te former release.
@IROKILLER commented on GitHub (Feb 3, 2026):
I'm using version 0.1.7
@maziggy commented on GitHub (Feb 3, 2026):
Cannot reproduce. There are also no erros in your log files.
@IROKILLER commented on GitHub (Feb 3, 2026):
I can see this in the Unraid log. Oddly enough, it's not in the Bambuddy.log file.
`INFO: 192.168.178.48:61598 - "PATCH /api/v1/smart-plugs/2 HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
self.dialect.do_execute(
~~~~~~~~~~~~~~~~~~~~~~~^
cursor, str_statement, effective_parameters, context
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/engine/default.py", line 952, in do_execute
cursor.execute(statement, parameters)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 182, in execute
self._adapt_connection._handle_exception(error)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 342, in handle_exception
raise error
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 164, in execute
self.await(_cursor.execute(operation, parameters))
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 132, in await_only
return current.parent.switch(awaitable) # type: ignore[no-any-return,attr-defined] # noqa: E501
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 196, in greenlet_spawn
value = await result
^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/aiosqlite/cursor.py", line 40, in execute
await self._execute(self._cursor.execute, sql, parameters)
File "/usr/local/lib/python3.13/site-packages/aiosqlite/cursor.py", line 32, in _execute
return await self._conn._execute(fn, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/aiosqlite/core.py", line 160, in _execute
return await future
^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/aiosqlite/core.py", line 63, in _connection_worker_thread
result = function()
sqlite3.IntegrityError: UNIQUE constraint failed: smart_plugs.printer_id
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.13/site-packages/uvicorn/protocols/http/httptools_impl.py", line 416, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
self.scope, self.receive, self.send
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.13/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/fastapi/applications.py", line 1135, in call
await super().call(scope, receive, send)
File "/usr/local/lib/python3.13/site-packages/starlette/applications.py", line 107, in call
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.13/site-packages/starlette/middleware/errors.py", line 186, in call
raise exc
File "/usr/local/lib/python3.13/site-packages/starlette/middleware/errors.py", line 164, in call
await self.app(scope, receive, _send)
File "/usr/local/lib/python3.13/site-packages/starlette/middleware/base.py", line 191, in call
with recv_stream, send_stream, collapse_excgroups():
~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/contextlib.py", line 162, in exit
self.gen.throw(value)
~~~~~~~~~~~~~~^^^^^^^
File "/usr/local/lib/python3.13/site-packages/starlette/_utils.py", line 85, in collapse_excgroups
raise exc
File "/usr/local/lib/python3.13/site-packages/starlette/middleware/base.py", line 193, in call
response = await self.dispatch_func(request, call_next)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/backend/app/main.py", line 2700, in auth_middleware
return await call_next(request)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/starlette/middleware/base.py", line 168, in call_next
raise app_exc from app_exc.cause or app_exc.context
File "/usr/local/lib/python3.13/site-packages/starlette/middleware/base.py", line 144, in coro
await self.app(scope, receive_or_disconnect, send_no_error)
File "/usr/local/lib/python3.13/site-packages/starlette/middleware/exceptions.py", line 63, in call
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/usr/local/lib/python3.13/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/usr/local/lib/python3.13/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/usr/local/lib/python3.13/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in call
await self.app(scope, receive, send)
File "/usr/local/lib/python3.13/site-packages/starlette/routing.py", line 716, in call
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.13/site-packages/starlette/routing.py", line 736, in app
await route.handle(scope, receive, send)
File "/usr/local/lib/python3.13/site-packages/starlette/routing.py", line 290, in handle
await self.app(scope, receive, send)
File "/usr/local/lib/python3.13/site-packages/fastapi/routing.py", line 115, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/usr/local/lib/python3.13/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
raise exc
File "/usr/local/lib/python3.13/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
await app(scope, receive, sender)
File "/usr/local/lib/python3.13/site-packages/fastapi/routing.py", line 101, in app
response = await f(request)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/fastapi/routing.py", line 355, in app
raw_response = await run_endpoint_function(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<3 lines>...
)
^
File "/usr/local/lib/python3.13/site-packages/fastapi/routing.py", line 243, in run_endpoint_function
return await dependant.call(**values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/backend/app/api/routes/smart_plugs.py", line 461, in update_smart_plug
await db.commit()
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/ext/asyncio/session.py", line 1000, in commit
await greenlet_spawn(self.sync_session.commit)
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 203, in greenlet_spawn
result = context.switch(value)
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/orm/session.py", line 2030, in commit
trans.commit(_to_root=True)
~~~~~~~~~~~~^^^^^^^^^^^^^^^
File "", line 2, in commit
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/orm/state_changes.py", line 137, in _go
ret_value = fn(self, *arg, **kw)
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/orm/session.py", line 1311, in commit
self._prepare_impl()
~~~~~~~~~~~~~~~~~~^^
File "", line 2, in _prepare_impl
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/orm/state_changes.py", line 137, in _go
ret_value = fn(self, *arg, **kw)
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/orm/session.py", line 1286, in _prepare_impl
self.session.flush()
~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/orm/session.py", line 4331, in flush
self._flush(objects)
~~~~~~~~~~~^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/orm/session.py", line 4466, in _flush
with util.safe_reraise():
~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/util/langhelpers.py", line 224, in exit
raise exc_value.with_traceback(exc_tb)
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/orm/session.py", line 4427, in _flush
flush_context.execute()
~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/orm/unitofwork.py", line 466, in execute
rec.execute(self)
~~~~~~~~~~~^^^^^^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/orm/unitofwork.py", line 642, in execute
util.preloaded.orm_persistence.save_obj(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
self.mapper,
^^^^^^^^^^^^
uow.states_for_mapper_hierarchy(self.mapper, False, False),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
uow,
^^^^
)
^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/orm/persistence.py", line 85, in save_obj
_emit_update_statements(
~~~~~~~~~~~~~~~~~~~~~~~^
base_mapper,
^^^^^^^^^^^^
...<3 lines>...
update,
^^^^^^^
)
^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/orm/persistence.py", line 912, in _emit_update_statements
c = connection.execute(
statement, multiparams, execution_options=execution_options
)
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/engine/base.py", line 1419, in execute
return meth(
self,
distilled_parameters,
execution_options or NO_OPTIONS,
)
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/sql/elements.py", line 527, in _execute_on_connection
return connection._execute_clauseelement(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
self, distilled_params, execution_options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/engine/base.py", line 1641, in _execute_clauseelement
ret = self._execute_context(
dialect,
...<8 lines>...
cache_hit=cache_hit,
)
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/engine/base.py", line 1846, in _execute_context
return self._exec_single_context(
~~~~~~~~~~~~~~~~~~~~~~~~~^
dialect, context, statement, parameters
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/engine/base.py", line 1986, in _exec_single_context
self._handle_dbapi_exception(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
e, str_statement, effective_parameters, cursor, context
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/engine/base.py", line 2363, in _handle_dbapi_exception
raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/engine/base.py", line 1967, in _exec_single_context
self.dialect.do_execute(
~~~~~~~~~~~~~~~~~~~~~~~^
cursor, str_statement, effective_parameters, context
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/engine/default.py", line 952, in do_execute
cursor.execute(statement, parameters)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 182, in execute
self._adapt_connection._handle_exception(error)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 342, in handle_exception
raise error
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/dialects/sqlite/aiosqlite.py", line 164, in execute
self.await(_cursor.execute(operation, parameters))
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 132, in await_only
return current.parent.switch(awaitable) # type: ignore[no-any-return,attr-defined] # noqa: E501
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/sqlalchemy/util/_concurrency_py3k.py", line 196, in greenlet_spawn
value = await result
^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/aiosqlite/cursor.py", line 40, in execute
await self._execute(self._cursor.execute, sql, parameters)
File "/usr/local/lib/python3.13/site-packages/aiosqlite/cursor.py", line 32, in _execute
return await self._conn._execute(fn, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/aiosqlite/core.py", line 160, in _execute
return await future
^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/aiosqlite/core.py", line 63, in _connection_worker_thread
result = function()
sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) UNIQUE constraint failed: smart_plugs.printer_id
[SQL: UPDATE smart_plugs SET printer_id=?, updated_at=CURRENT_TIMESTAMP WHERE smart_plugs.id = ?]
[parameters: (1, 2)]
(Background on this error at: https://sqlalche.me/e/20/gkpj)`
@maziggy commented on GitHub (Feb 3, 2026):
Did you restart the container after uograding? Looks like the database migration hasn't run.
@IROKILLER commented on GitHub (Feb 3, 2026):
Unraid actually does that on its own after the update. But yes, I did turn it off again, wait a short while, and then restart it.
@IROKILLER commented on GitHub (Feb 3, 2026):
Either something must have gone wrong with the entire update, but I completely reinstalled everything and now it works.
@maziggy commented on GitHub (Feb 3, 2026):
I don't know Unraid at all. Glad it works again for you!