frenck / spook

A scary 👻 powerful toolbox 🧰 for Home Assistant 🏡
https://spook.boo
MIT License
381 stars 36 forks source link

Enable entity does not work #736

Open basbruss opened 3 weeks ago

basbruss commented 3 weeks ago

What version of Spook are you using?

v2.2.4

What version of Home Assistant are you using?

2024.4.3

The problem

The enable_entity service does not seem to work on disabled entities.

Steps to reproduce the problem

  1. disable a random entity with disable_entity from spook
  2. change service to enable_entity
  3. find entity in the selector field -> does not show up
  4. switch to yaml mode
  5. add entity_id in yaml and run the service

Entity_id seems to be removed from the entity registry

Anything in the logs? Paste it here!

Logger: homeassistant.components.websocket_api.http.connection
Bron: helpers/entity_registry.py:966
integratie: Home Assistant WebSocket API (documentatie, problemen)
Eerst voorgekomen: 01:56:06 (3 gebeurtenissen)
Laatst gelogd: 02:05:27

[140031002837952] Error handling message: Unknown error (unknown_error) Bas from 172.71.99.76 (Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 27, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 794, in handle_execute_script
    script_result = await script_obj.async_run(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1713, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 457, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 509, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 539, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 507, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 736, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 699, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2543, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2580, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1074, in _async_admin_handler
    await result
  File "/config/custom_components/spook/ectoplasms/homeassistant/services/enable_entity.py", line 29, in async_handle_service
    entity_registry.async_update_entity(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 1095, in async_update_entity
    return self._async_update_entity(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 966, in _async_update_entity
    old = self.entities[entity_id]
          ~~~~~~~~~~~~~^^^^^^^^^^^
  File "/usr/local/lib/python3.12/collections/__init__.py", line 1134, in __getitem__
    raise KeyError(key)
KeyError: 'update.adaptive_cover'
MrFr33man123 commented 2 hours ago

+1 on this.

2024-05-15 06:31:00.190 WARNING (MainThread) [homeassistant.helpers.service] Referenced entities camera.cam_02_cam_02 are missing or not currently available

when the Service tries to enable it that is the log output. Interesstingly a manual execution of the sequenz in automation does work... Enabeling the Device. Just automatic on trigger seems to not work? I will try to debug a little further.

Most Recent HA Core and Spook 2024.5.3 / 3.0.1

Thanks for this awesome integration, solves so much things