frenck / spook

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

New zone services do not work #311

Closed martinhoess closed 9 months ago

martinhoess commented 9 months ago

What version of Spook are you using?

1.1.0

What version of Home Assistant are you using?

2023.8.1

The problem

The new zone services that were implemented with the last version do not work.

service: zone.create
data:
  radius: 50
  name: Test
  icon: mdi:test-tube
  latitude: 46.123
  longitude: 14.321

Anything in the logs? Paste it here!

Logger: homeassistant.helpers.script.websocket_api_script
Source: custom_components/spook/ectoplasms/zone/services/create.py:23
Integration: Spook (documentation, issues)
First occurred: 23:38:28 (1 occurrences)
Last logged: 23:38:28

websocket_api script: Error executing script. Unexpected error for call_service at pos 1: 'zone'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 703, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 665, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 1974, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2011, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 980, in admin_handler
    await result
  File "/config/custom_components/spook/ectoplasms/zone/services/create.py", line 23, in async_handle_service
    collection: ZoneStorageCollection = self.hass.data[DOMAIN]
                                        ~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'zone'
frenck commented 9 months ago

Some question:

martinhoess commented 9 months ago
frenck commented 9 months ago

Shit, there goes my possible theory 💩 I'm not fully understanding how this can happen to be honest. I lack re-production as well, as shown in the screenshots before. Need to dig a bit more and will report back.

../Frenck

martinhoess commented 9 months ago

I've removed the Home Zone from the yaml. And now the spook services work.

frenck commented 9 months ago

Ah! I see it in the code now... ok that needs better handling!

CleanShot 2023-08-11 at 23 57 47

If zone.home is there, it will just return and not set the data as I need in the last line.

Thank you so much for this, will address this... not sure how.. but I'll figure something out :)

../Frenck