dummylabs / thewatchman

Home Assistant custom integration to keep track of missing entities and actions in your config files
MIT License
475 stars 20 forks source link

Telegram send Mesage: TypeError: the JSON object must be str, bytes or bytearray, not dict #148

Closed lasmaty07 closed 19 hours ago

lasmaty07 commented 2 months ago

When I call the service to generate the report and include a data just like the read.me shows

service: watchman.report
data:
  send_notification: true
  create_file: true
  service: telegram_bot.send_message
  data: 
    title: Hello
    parse_mode: html

I get the next error: TypeError: the JSON object must be str, bytes or bytearray, not dict

this is the full trace.

2024-08-24 17:00:24.736 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140415053530816] Error handling message: Unknown error (unknown_error) Matt from 190.226.208.201 (Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0)

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 795, in handle_execute_script

    script_result = await script_obj.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 2319, in async_call

    response_data = await coro

                    ^^^^^^^^^^

  File "/usr/src/homeassistant/homeassistant/core.py", line 2356, in _execute_service

    return await target(service_call)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/config/custom_components/watchman/__init__.py", line 229, in async_handle_report

    await async_report_to_notification(

  File "/config/custom_components/watchman/__init__.py", line 416, in async_report_to_notification

    data = {} if service_data is None else json.loads(service_data)

                                           ^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.12/json/__init__.py", line 339, in loads

    raise TypeError(f'the JSON object must be str, bytes or bytearray, '

TypeError: the JSON object must be str, bytes or bytearray, not dict
dummylabs commented 19 hours ago

Will be fixed in 0.6.4