travisghansen / hass-opnsense

OPNsense integration with Home Assistant
214 stars 29 forks source link

Wake on Lan not working with HA 2024.2.0 #123

Closed belgianrubs closed 8 months ago

belgianrubs commented 8 months ago

WOL stopped working for me while my OPNsense installation was still at 23.7.12 and updated HA to 2024.2.0. I updated my OPNsense instance in the hope to fix it, but jokes were on me, it became worse. Had to check the open issues here first... I just saw the exact same errors as noted in the pfSense repository: https://github.com/travisghansen/hass-pfsense/issues/188 Can't reproduce the error at the moment since I remotely upgraded OPNsense, but can do so if needed, when I'm back home.

belgianrubs commented 8 months ago

Logs: Telegram command: turn on Server: Error executing script. Unexpected error for call_service at pos 1: 'list' object has no attribute 'get' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 485, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 723, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_run_long_action return long_task.result() ^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2279, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2316, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 892, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 962, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/template/switch.py", line 161, in async_turn_on await self.async_run_script(self._on_script, context=self._context) File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 562, in async_run_script await script.async_run( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1600, in async_run return await asyncio.shield(run.async_run()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 435, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 487, in _async_step self._handle_exception( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 512, in _handle_exception raise exception File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 485, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 723, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_run_long_action return long_task.result() ^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2279, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2316, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/opnsense/services.py", line 43, in _async_send_service await self.hass.helpers.service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 843, in entity_service_call entity_candidates = _get_permissible_entity_candidates( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 796, in _get_permissible_entity_candidates and (entity := entities.get(single_entity)) is not None ^^^^^^^^^^^^ AttributeError: 'list' object has no attribute 'get'

travisghansen commented 8 months ago

I think this is a bug in hass. We probably need to have the devs look at it and comment.

lolmachine4 commented 8 months ago

Is there something I, as a user with zero programming knowledge, can do to speed this up? WoL was my main usage of this plugin, I miss it dearly, but don't want to come off rude.

Iceman248 commented 8 months ago

This explains why this hasn't been working. Ugh. Hopefully this gets resolved soon, as I too rely on it quite a bit. Thanks.

The WOL feature of HA works fine though for this specific service.

bdf0506 commented 8 months ago

Check out https://github.com/travisghansen/hass-pfsense/issues/188#issuecomment-1941605767 for a potential workaround.

raman325 commented 8 months ago

Can you share the service call you are making that generates this error? Can you also re-send the logs but with line breaks? I tried reformatting it below but it looks like it's a single line which makes it extremely difficult to follow

Telegram command: turn on Server: Error executing script. Unexpected error for call_service at pos 1: 'list' object has no attribute 'get' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 485, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 723, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_run_long_action return long_task.result() ^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2279, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2316, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 892, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 962, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/template/switch.py", line 161, in async_turn_on await self.async_run_script(self._on_script, context=self._context) File "/usr/src/homeassistant/homeassistant/components/template/template_entity.py", line 562, in async_run_script await script.async_run( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1600, in async_run return await asyncio.shield(run.async_run()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 435, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 487, in _async_step self._handle_exception( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 512, in _handle_exception raise exception File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 485, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 723, in _async_call_service_step response_data = await self._async_run_long_action( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_run_long_action return long_task.result() ^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2279, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2316, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/opnsense/services.py", line 43, in _async_send_service await self.hass.helpers.service.entity_service_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 843, in entity_service_call entity_candidates = _get_permissible_entity_candidates( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 796, in _get_permissible_entity_candidates and (entity := entities.get(single_entity)) is not None ^^^^^^^^^^^^ AttributeError: 'list' object has no attribute 'get'
raman325 commented 8 months ago

Ignore the above ^

The PR linked below is what caused the code to break and the fix is shown in the isy994 integration code changes from the same PR: https://github.com/home-assistant/core/pull/106759/files

travisghansen commented 8 months ago

Should be fixed in v0.1.19. Thanks to @raman325 !

belgianrubs commented 8 months ago

Issue resolved in v0.1.19!