Hi All,
I have a very simple script, that send an IR remote command.
It’s working, and the command is sent to the IR transmitter, however it generates an error:
Failed to perform the action script/lv_fan_off.
Enum RemoteKeyCode has no value defined for name ‘KEYCODE_fan_off
The YAML code of the script is:
alias: lv_fan_off
sequence:
- action: remote.send_command
data:
device: living_room_fan
command: fan_off
target:
area_id: living_room
description: ""
icon: mdi:fan-off
I’ve found the following in the HA logs:
Logger: homeassistant.helpers.script.living_room_fan
Source: helpers/script.py:525
First occurred: 10:30:39 (1 occurrences)
Last logged: 10:30:39
Living Room Fan: Error executing script. Unexpected error for call_service at pos 1: Enum RemoteKeyCode has no value defined for name 'KEYCODE_fan_off'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 525, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 763, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action
return await long_task
^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 718, in _service_handler
response = await self._async_start_run(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 674, in _async_start_run
script_result = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/script/__init__.py", line 707, in _async_run
return await self.script.async_run(script_vars, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1795, in async_run
return await asyncio.shield(create_eager_task(run.async_run()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 463, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 527, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 557, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 525, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 763, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action
return await long_task
^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1021, in entity_service_call
raise result from None
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1610, in async_request_call
return await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1068, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/androidtv_remote/remote.py", line 109, in async_send_command
self._send_key_command(single_command, "SHORT")
File "/usr/src/homeassistant/homeassistant/components/androidtv_remote/entity.py", line 73, in _send_key_command
self._api.send_key_command(key_code, direction)
File "/usr/local/lib/python3.12/site-packages/androidtvremote2/androidtv_remote.py", line 395, in send_key_command
self._remote_message_protocol.send_key_command(key_code, direction)
File "/usr/local/lib/python3.12/site-packages/androidtvremote2/remote.py", line 106, in send_key_command
key_code = RemoteKeyCode.Value(key_code)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/google/protobuf/internal/enum_type_wrapper.py", line 59, in Value
raise ValueError('Enum {} has no value defined for name {!r}'.format(
ValueError: Enum RemoteKeyCode has no value defined for name 'KEYCODE_fan_off'
The same code implemented as a button on a dashboard, is working without generating the error.
Does anyone know where the error is coming from, and how to solve it?
Cheers.