core: Script throw error: Dict key must be str

The problem

In 2023.11, scripts that used parameters had no issues. In 2023.12, the same scripts no longer run, throwing the following error:

Error executing script. Unexpected error for call_service at pos 1: Dict key must be str

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 704, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2067, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2104, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 878, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/roomba/irobot_base.py", line 266, in async_send_command
    await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/roombapy/roomba.py", line 224, in send_command
    str_command = orjson.dumps(roomba_command).decode("utf-8")
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Dict key must be str

Tested in 2023.12.4 and still not functioning.

What version of Home Assistant Core has the issue?

core-2023.12.4

What was the last working version of Home Assistant Core?

core-2023.11.3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Scripts

Link to integration documentation on our website

https://www.home-assistant.io/integrations/script

Diagnostics information

No response

Example YAML snippet

alias: "Vacuum: Morning"
sequence:
  - service: vacuum.send_command
    data:
      command: start
      params:
        pmap_id: YghMPxN7QEuIToNdonQVTg
        ordered: 1
        regions:
          - region_id: "13"
            type: rid
          - region_id: "20"
            type: rid
          - region_id: "10"
            type: rid
          - region_id: "16"
            type: rid
          - region_id: "17"
            type: rid
          - region_id: "4"
            type: rid
          - region_id: "15"
            type: rid
          - region_id: "18"
            type: rid
    alias: Morning Clean
    target:
      entity_id: vacuum.howie
mode: single
icon: mdi:robot-vacuum

Anything in the logs that might be useful for us?

Logger: homeassistant.components.script.vacuum_evening
Source: helpers/script.py:468
Integration: Script (documentation, issues)
First occurred: 6:44:25 PM (1 occurrences)
Last logged: 6:44:25 PM

Vacuum: Evening: Error executing script. Unexpected error for call_service at pos 1: Dict key must be str
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 704, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 666, in _async_run_long_action
    return long_task.result()
           ^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2067, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2104, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 878, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/roomba/irobot_base.py", line 266, in async_send_command
    await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/roombapy/roomba.py", line 224, in send_command
    str_command = orjson.dumps(roomba_command).decode("utf-8")
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Dict key must be str

Additional information

See the following issue for other instances: https://github.com/home-assistant/core/issues/105323

About this issue

  • Original URL
  • State: closed
  • Created 6 months ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

Can confirm that the scripts are working again in 2024.1