DanielBaulig / vestaboard

Vestaboard Home Assistant integration
https://www.rarelyunplugged.com
Other
13 stars 1 forks source link

Error not "list" to str #8

Closed thamarnan closed 12 months ago

thamarnan commented 12 months ago
Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/vestaboard/__init__.py:155
Integration: Home Assistant WebSocket API ([documentation](https://www.home-assistant.io/integrations/websocket_api), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+websocket_api%22))
First occurred: 9:49:25 PM (2 occurrences)
Last logged: 9:50:47 PM

[140417457095232] Error handling message: Unknown error (unknown_error) meenet from 192.167.0.71 (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 716, in handle_execute_script
    response = await script_obj.async_run(msg.get("variables"), context=context)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1569, in async_run
    return await asyncio.shield(run.async_run())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 420, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 470, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 493, in _handle_exception
    raise exception
  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 "/config/custom_components/vestaboard/__init__.py", line 213, in post
    result = await vestaboard.write(lines)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/vestaboard/__init__.py", line 166, in write
    async with self.post(self.encode_lines(lines)) as response:
                         ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/vestaboard/__init__.py", line 155, in encode_lines
    lines += [''] * (6 - len(lines))
TypeError: can only concatenate str (not "list") to str

I'm getting this error, not sure how to solve this

DanielBaulig commented 12 months ago

Make sure to pass a list / array to the vestaboard.post service, e.g.

- service: vestaboard.post
  data:
    lines:
      - Line 1
      - Line 2

Even when just providing a single line. The following will not work (and result in the error you shared):

- service: vestaboard.post
  data:
    lines: "This is a single line instead of an array / list".
DanielBaulig commented 12 months ago

Commit e6aa1fe57600f24704cc4ec25d65b1b155c5ed6d adds a more meaningful error message. Closing this issue out for now. Please let me know of this doesn't help you resolve your issue.

thamarnan commented 12 months ago

It's working now. Just like you mention, need to be as a list. not just single line. thanks!