dummylabs / thewatchman

Home Assistant custom integration to keep track of missing entities and services in your config files
MIT License
459 stars 18 forks source link

service: watchman.report, throws an error: Unexpected error for call_service at pos 1: 'dict' object has no attribute 'split' #90

Open dennis-bell opened 1 year ago

dennis-bell commented 1 year ago

I can normally generate the report, however when I want to sent the report with telegram bot it throws an internal split error. Watchman version 0.6.1 Home assistant 2023.5.2

    action:
      service: watchman.report
      data:
        send_notification: true
        service:
          name: telegram_bot.create_message
          # data:
          #   parse_mode: html
2023-05-30 15:57:01.114 ERROR (MainThread) [homeassistant.components.automation.run_watchman_report] Run Watchman Report: Error executing script. Unexpected error for call_service at pos 1: 'dict' object has no attribute 'split'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 452, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1849, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1889, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/config/custom_components/watchman/__init__.py", line 240, in async_handle_report
    await async_report_to_notification(
  File "/config/custom_components/watchman/__init__.py", line 413, in async_report_to_notification
    if not is_service(hass, service_str):
  File "/config/custom_components/watchman/utils.py", line 174, in is_service
    domain, service = entry.split(".")[0], ".".join(entry.split(".")[1:])
AttributeError: 'dict' object has no attribute 'split'
2023-05-30 15:57:01.121 ERROR (MainThread) [homeassistant.components.automation.run_watchman_report] While executing automation automation.run_watchman_report
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 545, in async_trigger
    await self.action_script.async_run(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1533, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 410, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 454, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 477, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 452, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1849, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1889, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/config/custom_components/watchman/__init__.py", line 240, in async_handle_report
    await async_report_to_notification(
  File "/config/custom_components/watchman/__init__.py", line 413, in async_report_to_notification
    if not is_service(hass, service_str):
  File "/config/custom_components/watchman/utils.py", line 174, in is_service
    domain, service = entry.split(".")[0], ".".join(entry.split(".")[1:])
AttributeError: 'dict' object has no attribute 'split'
lasmaty07 commented 2 weeks ago

I belive there's an error on your syntax.

should be like this service: {service name}

try calling the service from /developer-tools/service like this.

service: watchman.report
data:
  send_notification: true
  create_file: true
  service: telegram_bot.send_message