Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't hit debugger breakpoints #198

Closed
4 tasks done
thargy opened this issue Oct 16, 2024 · 3 comments
Closed
4 tasks done

Can't hit debugger breakpoints #198

thargy opened this issue Oct 16, 2024 · 3 comments
Labels

Comments

@thargy
Copy link

thargy commented Oct 16, 2024

System Health details

System Information

version core-2024.10.2
installation_type Unsupported Third Party Container
dev false
hassio false
docker true
user vscode
virtualenv false
python_version 3.12.6
os_name Linux
os_version 5.15.153.1-microsoft-standard-WSL2
arch x86_64
timezone Europe/London
config_dir /workspaces/area_tree/config
Home Assistant Cloud
logged_in false
can_reach_cert_server ok
can_reach_cloud_auth ok
can_reach_cloud ok
Dashboards
dashboards 2
resources 0
views 0
mode storage
Recorder
oldest_recorder_run October 16, 2024 at 4:03 PM
current_recorder_run October 16, 2024 at 6:16 PM
estimated_db_size 0.50 MiB
database_engine sqlite
database_version 3.40.1

Checklist

  • I have enabled debug logging for my installation.
  • I have filled out the issue template to the best of my ability.
  • This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
  • This issue is not a duplicate issue of any previous issues..

Describe the issue

Firstly, thank you for this repo which has been a real headstart.

I have managed to get HA running and added the integration. I have also managed to attach the remote debugger in VSCode, however I cannot get it to hit any breakpoints.

Reproduction steps

Reproduction steps

  1. Add the following to HA Config:

    debugpy:
      host: localhost # Optional
      port: 5678 # Optional
      start: true
      wait: true  # Force wait for remote debugging
  2. Set breakpoint, e.g. on reload.

  3. Start HA using Run Task - tasks.json:

    {
        "version": "2.0.0",
        "tasks": [
            {
                "label": "Run Home Assistant on port 8123",
                "type": "shell",
                "command": "scripts/develop",
                "problemMatcher": []
            }
        ]
    }

    It will pause, with the following showing in the console

     2024-10-16 17:16:26.345 INFO (MainThread) [homeassistant.setup] Setting up debugpy
     0.00s - Debugger warning: It seems that frozen modules are being used, which may
     0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
     0.00s - to python to disable frozen modules.
     0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
     2024-10-16 17:16:26.868 WARNING (MainThread) [homeassistant.components.debugpy] Waiting for remote debug connection on localhost:5678
    
  4. Attach debugger - launch.json:

    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Python Debugger: Remote Attach",
                "type": "debugpy",
                "request": "attach",
                "connect": {
                    "host": "localhost",
                    "port": 5678
                },
                "pathMappings": [
                    {
                        "localRoot": "${workspaceFolder}",
                        "remoteRoot": "."
                    }
                ]
            }
        ]
    }

    On attaching, the console will continue outputting messages, indicating a successful attachment.

Result

Reloading the integration will not hit the breakpoint, nor will any other breakpoints cause the debugger to pause. The debugger will show running threads.

Debug logs

2024-10-16 17:13:23.741 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration area_tree which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-10-16 17:13:24.190 INFO (MainThread) [homeassistant.setup] Setup of domain system_log took 0.06 seconds
2024-10-16 17:13:24.190 INFO (MainThread) [homeassistant.setup] Setup of domain logger took 0.04 seconds
2024-10-16 17:13:24.191 INFO (MainThread) [homeassistant.bootstrap] Setting up frontend: {'frontend'}
2024-10-16 17:13:24.195 INFO (MainThread) [homeassistant.setup] Setting up http
2024-10-16 17:13:24.199 INFO (MainThread) [homeassistant.setup] Setting up device_automation
2024-10-16 17:13:24.200 INFO (MainThread) [homeassistant.setup] Setup of domain device_automation took 0.00 seconds
2024-10-16 17:13:24.206 WARNING (MainThread) [aiohttp_fast_zlib] zlib_ng and isal are not available, falling back to zlib, performance will be degraded.
2024-10-16 17:13:24.209 INFO (MainThread) [homeassistant.setup] Setup of domain http took 0.01 seconds
2024-10-16 17:13:24.212 INFO (MainThread) [homeassistant.setup] Setting up auth
2024-10-16 17:13:24.214 INFO (MainThread) [homeassistant.setup] Setup of domain auth took 0.00 seconds
2024-10-16 17:13:24.215 INFO (MainThread) [homeassistant.setup] Setting up config
2024-10-16 17:13:24.218 INFO (MainThread) [homeassistant.setup] Setup of domain config took 0.00 seconds
2024-10-16 17:13:24.219 INFO (MainThread) [homeassistant.setup] Setting up diagnostics
2024-10-16 17:13:24.221 INFO (MainThread) [homeassistant.setup] Setup of domain diagnostics took 0.00 seconds
2024-10-16 17:13:24.222 INFO (MainThread) [homeassistant.setup] Setting up file_upload
2024-10-16 17:13:24.223 INFO (MainThread) [homeassistant.setup] Setup of domain file_upload took 0.00 seconds
2024-10-16 17:13:24.223 INFO (MainThread) [homeassistant.setup] Setting up image_upload
2024-10-16 17:13:24.227 INFO (MainThread) [homeassistant.setup] Setup of domain image_upload took 0.00 seconds
2024-10-16 17:13:24.228 INFO (MainThread) [homeassistant.setup] Setting up repairs
2024-10-16 17:13:24.229 INFO (MainThread) [homeassistant.setup] Setup of domain repairs took 0.00 seconds
2024-10-16 17:13:24.230 INFO (MainThread) [homeassistant.setup] Setting up websocket_api
2024-10-16 17:13:24.230 INFO (MainThread) [homeassistant.setup] Setup of domain websocket_api took 0.00 seconds
2024-10-16 17:13:24.231 INFO (MainThread) [homeassistant.setup] Setting up api
2024-10-16 17:13:24.235 INFO (MainThread) [homeassistant.setup] Setup of domain api took 0.00 seconds
2024-10-16 17:13:24.237 INFO (MainThread) [homeassistant.setup] Setting up person
2024-10-16 17:13:24.240 INFO (MainThread) [homeassistant.setup] Setting up search
2024-10-16 17:13:24.240 INFO (MainThread) [homeassistant.setup] Setup of domain search took 0.00 seconds
2024-10-16 17:13:24.243 INFO (MainThread) [homeassistant.setup] Setup of domain person took 0.01 seconds
2024-10-16 17:13:24.244 INFO (MainThread) [homeassistant.setup] Setting up onboarding
2024-10-16 17:13:24.245 INFO (MainThread) [homeassistant.setup] Setup of domain onboarding took 0.00 seconds
2024-10-16 17:13:24.247 INFO (MainThread) [homeassistant.setup] Setting up lovelace
2024-10-16 17:13:24.250 INFO (MainThread) [homeassistant.setup] Setup of domain lovelace took 0.00 seconds
2024-10-16 17:13:24.251 INFO (MainThread) [homeassistant.setup] Setting up frontend
2024-10-16 17:13:24.256 INFO (MainThread) [homeassistant.setup] Setup of domain frontend took 0.01 seconds
2024-10-16 17:13:24.260 INFO (MainThread) [homeassistant.bootstrap] Setting up recorder: {'recorder'}
2024-10-16 17:13:24.262 INFO (MainThread) [homeassistant.setup] Setting up recorder
2024-10-16 17:13:24.266 INFO (MainThread) [asyncio] <Server sockets=(<asyncio.TransportSocket fd=11, family=2, type=1, proto=6, laddr=('0.0.0.0', 8123)>, <asyncio.TransportSocket fd=12, family=10, type=1, proto=6, laddr=('::', 8123, 0, 0)>)> is serving
2024-10-16 17:13:24.267 INFO (MainThread) [homeassistant.components.http] Now listening on port 8123
2024-10-16 17:13:24.269 WARNING (Recorder) [homeassistant.components.recorder.util] The system could not validate that the sqlite3 database at //workspaces/area_tree/config/home-assistant_v2.db was shutdown cleanly
2024-10-16 17:13:24.269 INFO (MainThread) [homeassistant.setup] Setup of domain http took 0.01 seconds
2024-10-16 17:13:24.288 WARNING (Recorder) [homeassistant.components.recorder.util] Ended unfinished session (id=6 from 2024-10-16 17:11:16.888639)
2024-10-16 17:13:24.302 INFO (MainThread) [homeassistant.setup] Setup of domain recorder took 0.04 seconds
2024-10-16 17:13:24.303 INFO (MainThread) [homeassistant.bootstrap] Setting up debugger: {'debugpy'}
2024-10-16 17:13:24.307 INFO (MainThread) [homeassistant.setup] Setting up debugpy
2024-10-16 17:13:24.823 WARNING (MainThread) [homeassistant.components.debugpy] Waiting for remote debug connection on localhost:5678
2024-10-16 17:13:26.503 INFO (MainThread) [homeassistant.setup] Setup of domain debugpy took 2.20 seconds
2024-10-16 17:13:26.506 INFO (MainThread) [homeassistant.bootstrap] Setting up stage 1: {'cloud', 'websocket_api', 'repairs', 'api', 'ssdp', 'bluetooth', 'webhook', 'http', 'usb', 'zeroconf', 'dhcp', 'network', 'auth'}
2024-10-16 17:13:26.508 INFO (MainThread) [homeassistant.setup] Setting up webhook
2024-10-16 17:13:26.512 INFO (MainThread) [homeassistant.setup] Setup of domain webhook took 0.00 seconds
2024-10-16 17:13:26.522 INFO (MainThread) [homeassistant.setup] Setting up network
2024-10-16 17:13:26.526 INFO (MainThread) [homeassistant.setup] Setup of domain network took 0.00 seconds
2024-10-16 17:13:26.584 ERROR (ImportExecutor_0) [homeassistant.components.camera.img_util] Error loading libturbojpeg; Camera snapshot performance will be sub-optimal
Traceback (most recent call last):
  File "/home/vscode/.local/lib/python3.12/site-packages/homeassistant/components/camera/img_util.py", line 100, in __init__
    TurboJPEGSingleton.__instance = TurboJPEG()
                                    ^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.12/site-packages/turbojpeg.py", line 300, in __init__
    self.__find_turbojpeg() if lib_path is None else lib_path)
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.12/site-packages/turbojpeg.py", line 967, in __find_turbojpeg
    raise RuntimeError(
RuntimeError: Unable to locate turbojpeg library automatically. You may specify the turbojpeg library path manually.
e.g. jpeg = TurboJPEG(lib_path)
2024-10-16 17:13:26.853 INFO (MainThread) [homeassistant.setup] Setting up cloud
2024-10-16 17:13:26.902 INFO (MainThread) [homeassistant.setup] Setting up ffmpeg
2024-10-16 17:13:26.914 ERROR (MainThread) [haffmpeg.core] FFmpeg fails [Errno 2] No such file or directory: 'ffmpeg'
Traceback (most recent call last):
  File "/home/vscode/.local/lib/python3.12/site-packages/haffmpeg/core.py", line 130, in open
    self._proc = await asyncio.create_subprocess_exec(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/subprocess.py", line 224, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1743, in subprocess_exec
    transport = await self._make_subprocess_transport(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/unix_events.py", line 211, in _make_subprocess_transport
    transp = _UnixSubprocessTransport(self, protocol, args, shell,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_subprocess.py", line 36, in __init__
    self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
  File "/usr/local/lib/python3.12/asyncio/unix_events.py", line 820, in _start
    self._proc = subprocess.Popen(
                 ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/lib/python3.12/subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'
2024-10-16 17:13:26.921 WARNING (MainThread) [haffmpeg.tools] Error starting FFmpeg.
2024-10-16 17:13:26.922 INFO (MainThread) [homeassistant.setup] Setup of domain ffmpeg took 0.02 seconds
2024-10-16 17:13:26.925 INFO (MainThread) [homeassistant.setup] Setting up tts
2024-10-16 17:13:26.937 INFO (MainThread) [homeassistant.setup] Setup of domain cloud took 0.08 seconds
2024-10-16 17:13:26.949 INFO (MainThread) [homeassistant.setup] Setup of domain tts took 0.02 seconds
2024-10-16 17:13:26.960 INFO (MainThread) [homeassistant.setup] Setting up ssdp
2024-10-16 17:13:26.981 INFO (MainThread) [homeassistant.setup] Setting up usb
2024-10-16 17:13:26.983 INFO (MainThread) [homeassistant.setup] Setup of domain usb took 0.00 seconds
2024-10-16 17:13:26.995 INFO (MainThread) [homeassistant.setup] Setup of domain ssdp took 0.03 seconds
2024-10-16 17:13:27.033 INFO (MainThread) [homeassistant.setup] Setting up zeroconf
2024-10-16 17:13:27.048 INFO (MainThread) [homeassistant.components.zeroconf] Starting Zeroconf broadcast
2024-10-16 17:13:27.054 INFO (MainThread) [homeassistant.setup] Setup of domain zeroconf took 0.02 seconds
2024-10-16 17:13:27.215 INFO (MainThread) [homeassistant.setup] Setting up dhcp
2024-10-16 17:13:27.217 INFO (MainThread) [homeassistant.setup] Setup of domain dhcp took 0.00 seconds
2024-10-16 17:13:27.333 INFO (MainThread) [homeassistant.setup] Setting up bluetooth
2024-10-16 17:13:27.379 INFO (MainThread) [homeassistant.setup] Setup of domain bluetooth took 0.05 seconds
2024-10-16 17:13:27.389 INFO (MainThread) [homeassistant.bootstrap] Setting up stage 2: {'media_source', 'input_boolean', 'timer', 'device_automation', 'intent', 'input_button', 'map', 'diagnostics', 'stt', 'google_translate', 'scene', 'input_select', 'input_text', 'application_credentials', 'image_upload', 'demo', 'input_datetime', 'counter', 'shopping_list', 'tag', 'input_number', 'met', 'homeassistant_alerts', 'search', 'blueprint', 'sun', 'backup', 'assist_pipeline', 'logbook', 'area_tree', 'conversation', 'file_upload', 'onboarding', 'stream', 'group', 'radio_browser', 'ffmpeg', 'hardware', 'history', 'energy', 'lovelace', 'automation', 'config', 'person', 'mobile_app', 'zone', 'trace', 'default_config', 'system_health', 'schedule', 'tts', 'my', 'script', 'analytics', 'wake_word'}
2024-10-16 17:13:27.391 INFO (MainThread) [homeassistant.setup] Setting up stt
2024-10-16 17:13:27.393 INFO (MainThread) [homeassistant.setup] Setup of domain stt took 0.00 seconds
2024-10-16 17:13:27.396 INFO (MainThread) [homeassistant.setup] Setting up scene
2024-10-16 17:13:27.401 INFO (MainThread) [homeassistant.components.scene] Setting up homeassistant.scene
2024-10-16 17:13:27.408 INFO (MainThread) [homeassistant.setup] Setup of domain scene took 0.01 seconds
2024-10-16 17:13:27.430 INFO (MainThread) [homeassistant.setup] Setting up wake_word
2024-10-16 17:13:27.432 INFO (MainThread) [homeassistant.setup] Setup of domain wake_word took 0.00 seconds
2024-10-16 17:13:27.434 INFO (MainThread) [homeassistant.setup] Setting up media_source
2024-10-16 17:13:27.444 INFO (MainThread) [homeassistant.setup] Setup of domain media_source took 0.01 seconds
2024-10-16 17:13:27.447 INFO (MainThread) [homeassistant.setup] Setting up input_boolean
2024-10-16 17:13:27.455 INFO (MainThread) [homeassistant.setup] Setup of domain input_boolean took 0.01 seconds
2024-10-16 17:13:27.457 INFO (MainThread) [homeassistant.setup] Setting up stream
2024-10-16 17:13:27.478 INFO (MainThread) [homeassistant.setup] Setting up timer
2024-10-16 17:13:27.484 INFO (MainThread) [homeassistant.setup] Setup of domain timer took 0.01 seconds
2024-10-16 17:13:27.492 INFO (MainThread) [homeassistant.setup] Setting up group
2024-10-16 17:13:27.503 INFO (MainThread) [homeassistant.setup] Setup of domain group took 0.01 seconds
2024-10-16 17:13:27.521 INFO (MainThread) [homeassistant.setup] Setting up input_button
2024-10-16 17:13:27.530 INFO (MainThread) [homeassistant.setup] Setup of domain input_button took 0.01 seconds
2024-10-16 17:13:27.548 INFO (MainThread) [homeassistant.setup] Setting up history
2024-10-16 17:13:27.554 INFO (MainThread) [homeassistant.setup] Setup of domain history took 0.01 seconds
2024-10-16 17:13:27.575 INFO (MainThread) [homeassistant.setup] Setting up blueprint
2024-10-16 17:13:27.607 INFO (MainThread) [homeassistant.setup] Setup of domain blueprint took 0.03 seconds
2024-10-16 17:13:27.673 INFO (MainThread) [homeassistant.setup] Setting up trace
2024-10-16 17:13:27.675 INFO (MainThread) [homeassistant.setup] Setup of domain trace took 0.00 seconds
2024-10-16 17:13:27.681 INFO (MainThread) [homeassistant.setup] Setting up automation
2024-10-16 17:13:27.694 INFO (MainThread) [homeassistant.setup] Setup of domain automation took 0.01 seconds
2024-10-16 17:13:27.705 INFO (MainThread) [homeassistant.setup] Setting up input_select
2024-10-16 17:13:27.714 INFO (MainThread) [homeassistant.setup] Setup of domain input_select took 0.01 seconds
2024-10-16 17:13:27.751 INFO (MainThread) [homeassistant.setup] Setting up zone
2024-10-16 17:13:27.763 INFO (MainThread) [homeassistant.setup] Setup of domain zone took 0.01 seconds
2024-10-16 17:13:27.803 INFO (MainThread) [homeassistant.setup] Setting up logbook
2024-10-16 17:13:27.814 INFO (MainThread) [homeassistant.setup] Setup of domain logbook took 0.01 seconds
2024-10-16 17:13:27.829 INFO (MainThread) [homeassistant.setup] Setting up system_health
2024-10-16 17:13:27.834 INFO (MainThread) [homeassistant.setup] Setup of domain system_health took 0.00 seconds
2024-10-16 17:13:27.837 INFO (MainThread) [homeassistant.setup] Setting up input_number
2024-10-16 17:13:27.844 INFO (MainThread) [homeassistant.setup] Setup of domain input_number took 0.01 seconds
2024-10-16 17:13:27.874 INFO (MainThread) [homeassistant.setup] Setting up script
2024-10-16 17:13:27.886 INFO (MainThread) [homeassistant.setup] Setup of domain script took 0.01 seconds
2024-10-16 17:13:27.912 WARNING (MainThread) [asyncio] Executing <Task pending name='Task-1' coro=<setup_and_run_hass() running at /home/vscode/.local/lib/python3.12/site-packages/homeassistant/runner.py:157> wait_for=<_GatheringFuture pending cb=[Task.task_wakeup()] created at /usr/local/lib/python3.12/asyncio/tasks.py:712> cb=[_run_until_complete_cb() at /usr/local/lib/python3.12/asyncio/base_events.py:182] created at /usr/local/lib/python3.12/asyncio/tasks.py:695> took 0.532 seconds
2024-10-16 17:13:27.931 INFO (MainThread) [homeassistant.setup] Setting up intent
2024-10-16 17:13:27.935 INFO (MainThread) [homeassistant.setup] Setup of domain intent took 0.00 seconds
2024-10-16 17:13:27.955 INFO (MainThread) [homeassistant.setup] Setup of domain stream took 0.50 seconds
2024-10-16 17:13:27.957 INFO (MainThread) [homeassistant.setup] Setting up radio_browser
2024-10-16 17:13:27.958 INFO (MainThread) [homeassistant.setup] Setup of domain radio_browser took 0.00 seconds
2024-10-16 17:13:27.961 INFO (MainThread) [homeassistant.setup] Setting up hardware
2024-10-16 17:13:27.969 INFO (MainThread) [homeassistant.setup] Setting up energy
2024-10-16 17:13:27.981 INFO (MainThread) [homeassistant.setup] Setting up sensor
2024-10-16 17:13:27.994 INFO (MainThread) [homeassistant.setup] Setup of domain sensor took 0.01 seconds
2024-10-16 17:13:28.014 INFO (MainThread) [homeassistant.setup] Setup of domain energy took 0.04 seconds
2024-10-16 17:13:28.026 INFO (MainThread) [homeassistant.setup] Setting up map
2024-10-16 17:13:28.055 INFO (MainThread) [homeassistant.setup] Setup of domain map took 0.03 seconds
2024-10-16 17:13:28.063 INFO (MainThread) [homeassistant.setup] Setting up google_translate
2024-10-16 17:13:28.064 INFO (MainThread) [homeassistant.setup] Setup of domain google_translate took 0.00 seconds
2024-10-16 17:13:28.068 INFO (MainThread) [homeassistant.setup] Setting up tag
2024-10-16 17:13:28.075 INFO (MainThread) [homeassistant.setup] Setup of domain tag took 0.01 seconds
2024-10-16 17:13:28.077 INFO (MainThread) [homeassistant.setup] Setting up application_credentials
2024-10-16 17:13:28.080 INFO (MainThread) [homeassistant.setup] Setup of domain application_credentials took 0.00 seconds
2024-10-16 17:13:28.082 INFO (MainThread) [homeassistant.setup] Setting up input_text
2024-10-16 17:13:28.091 INFO (MainThread) [homeassistant.setup] Setup of domain input_text took 0.01 seconds
2024-10-16 17:13:28.093 INFO (MainThread) [homeassistant.setup] Setting up input_datetime
2024-10-16 17:13:28.099 INFO (MainThread) [homeassistant.setup] Setup of domain input_datetime took 0.01 seconds
2024-10-16 17:13:28.102 INFO (MainThread) [homeassistant.setup] Setting up counter
2024-10-16 17:13:28.109 INFO (MainThread) [homeassistant.setup] Setup of domain counter took 0.01 seconds
2024-10-16 17:13:28.110 INFO (MainThread) [homeassistant.setup] Setting up shopping_list
2024-10-16 17:13:28.111 INFO (MainThread) [homeassistant.setup] Setup of domain shopping_list took 0.00 seconds
2024-10-16 17:13:28.136 INFO (MainThread) [homeassistant.setup] Setting up homeassistant_alerts
2024-10-16 17:13:28.138 INFO (MainThread) [homeassistant.setup] Setup of domain homeassistant_alerts took 0.00 seconds
2024-10-16 17:13:28.141 INFO (MainThread) [homeassistant.setup] Setting up my
2024-10-16 17:13:28.144 INFO (MainThread) [homeassistant.setup] Setup of domain my took 0.00 seconds
2024-10-16 17:13:28.146 INFO (MainThread) [homeassistant.setup] Setting up sun
2024-10-16 17:13:28.148 INFO (MainThread) [homeassistant.setup] Setup of domain sun took 0.00 seconds
2024-10-16 17:13:28.154 INFO (MainThread) [homeassistant.components.sensor] Setting up sun.sensor
2024-10-16 17:13:28.250 WARNING (MainThread) [asyncio] Executing <Task finished name='setup sun as dependency of default_config' coro=<async_setup_component() done, defined at /home/vscode/.local/lib/python3.12/site-packages/homeassistant/setup.py:145> result=True created at /home/vscode/.local/lib/python3.12/site-packages/homeassistant/util/async_.py:45> took 0.104 seconds
2024-10-16 17:13:28.253 INFO (MainThread) [homeassistant.setup] Setting up met
2024-10-16 17:13:28.254 INFO (MainThread) [homeassistant.setup] Setup of domain met took 0.00 seconds
2024-10-16 17:13:28.263 INFO (MainThread) [homeassistant.setup] Setting up schedule
2024-10-16 17:13:28.270 INFO (MainThread) [homeassistant.setup] Setup of domain schedule took 0.01 seconds
2024-10-16 17:13:28.271 INFO (MainThread) [homeassistant.setup] Setting up backup
2024-10-16 17:13:28.276 INFO (MainThread) [homeassistant.setup] Setup of domain backup took 0.00 seconds
2024-10-16 17:13:28.284 INFO (MainThread) [homeassistant.setup] Setting up area_tree
2024-10-16 17:13:28.285 INFO (MainThread) [homeassistant.setup] Setup of domain area_tree took 0.00 seconds
2024-10-16 17:13:28.295 INFO (MainThread) [homeassistant.setup] Setting up conversation
2024-10-16 17:13:28.298 INFO (MainThread) [homeassistant.setup] Setup of domain conversation took 0.00 seconds
2024-10-16 17:13:28.300 INFO (MainThread) [homeassistant.components.sensor] Setting up energy.sensor
2024-10-16 17:13:28.305 INFO (MainThread) [homeassistant.setup] Setup of domain hardware took 0.34 seconds
2024-10-16 17:13:28.307 INFO (MainThread) [homeassistant.components.tts] Setting up google_translate.tts
2024-10-16 17:13:28.335 INFO (MainThread) [homeassistant.setup] Setting up assist_pipeline
2024-10-16 17:13:28.341 INFO (MainThread) [homeassistant.setup] Setup of domain assist_pipeline took 0.01 seconds
2024-10-16 17:13:28.347 INFO (MainThread) [homeassistant.setup] Setting up analytics
2024-10-16 17:13:28.351 INFO (MainThread) [homeassistant.setup] Setup of domain analytics took 0.00 seconds
2024-10-16 17:13:28.359 INFO (MainThread) [homeassistant.setup] Setting up todo
2024-10-16 17:13:28.363 INFO (MainThread) [homeassistant.setup] Setup of domain todo took 0.00 seconds
2024-10-16 17:13:28.368 INFO (MainThread) [homeassistant.components.todo] Setting up shopping_list.todo
2024-10-16 17:13:28.395 INFO (MainThread) [homeassistant.setup] Setting up demo
2024-10-16 17:13:28.406 INFO (MainThread) [homeassistant.setup] Setting up camera
2024-10-16 17:13:28.417 INFO (MainThread) [homeassistant.setup] Setup of domain camera took 0.01 seconds
2024-10-16 17:13:28.425 INFO (MainThread) [homeassistant.setup] Setting up image_processing
2024-10-16 17:13:28.427 INFO (MainThread) [homeassistant.setup] Setup of domain image_processing took 0.00 seconds
2024-10-16 17:13:28.442 INFO (MainThread) [homeassistant.setup] Setting up device_tracker
2024-10-16 17:13:28.449 INFO (MainThread) [homeassistant.setup] Setup of domain device_tracker took 0.01 seconds
2024-10-16 17:13:28.477 INFO (MainThread) [homeassistant.setup] Setting up mobile_app
2024-10-16 17:13:28.479 INFO (MainThread) [homeassistant.setup] Setting up notify
2024-10-16 17:13:28.480 INFO (MainThread) [homeassistant.setup] Setup of domain notify took 0.00 seconds
2024-10-16 17:13:28.482 INFO (MainThread) [homeassistant.setup] Setup of domain mobile_app took 0.01 seconds
2024-10-16 17:13:28.489 INFO (MainThread) [homeassistant.components.notify] Setting up notify.mobile_app
2024-10-16 17:13:28.491 INFO (MainThread) [homeassistant.setup] Setup of domain demo took 0.10 seconds
2024-10-16 17:13:28.505 INFO (MainThread) [homeassistant.setup] Setting up default_config
2024-10-16 17:13:28.505 INFO (MainThread) [homeassistant.setup] Setup of domain default_config took 0.00 seconds
2024-10-16 17:13:28.573 INFO (MainThread) [homeassistant.setup] Setting up air_quality
2024-10-16 17:13:28.574 INFO (MainThread) [homeassistant.setup] Setup of domain air_quality took 0.00 seconds
2024-10-16 17:13:28.574 INFO (MainThread) [homeassistant.components.air_quality] Setting up demo.air_quality
2024-10-16 17:13:28.579 INFO (MainThread) [homeassistant.setup] Setting up alarm_control_panel
2024-10-16 17:13:28.580 INFO (MainThread) [homeassistant.setup] Setup of domain alarm_control_panel took 0.00 seconds
2024-10-16 17:13:28.581 INFO (MainThread) [homeassistant.components.alarm_control_panel] Setting up demo.alarm_control_panel
2024-10-16 17:13:28.585 INFO (MainThread) [homeassistant.setup] Setting up binary_sensor
2024-10-16 17:13:28.586 INFO (MainThread) [homeassistant.setup] Setup of domain binary_sensor took 0.00 seconds
2024-10-16 17:13:28.587 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up demo.binary_sensor
2024-10-16 17:13:28.592 INFO (MainThread) [homeassistant.setup] Setting up button
2024-10-16 17:13:28.593 INFO (MainThread) [homeassistant.setup] Setup of domain button took 0.00 seconds
2024-10-16 17:13:28.594 INFO (MainThread) [homeassistant.components.button] Setting up demo.button
2024-10-16 17:13:28.598 INFO (MainThread) [homeassistant.components.camera] Setting up demo.camera
2024-10-16 17:13:28.603 INFO (MainThread) [homeassistant.setup] Setting up calendar
2024-10-16 17:13:28.606 INFO (MainThread) [homeassistant.setup] Setup of domain calendar took 0.00 seconds
2024-10-16 17:13:28.606 INFO (MainThread) [homeassistant.components.calendar] Setting up demo.calendar
2024-10-16 17:13:28.613 INFO (MainThread) [homeassistant.setup] Setting up climate
2024-10-16 17:13:28.618 INFO (MainThread) [homeassistant.setup] Setup of domain climate took 0.00 seconds
2024-10-16 17:13:28.621 INFO (MainThread) [homeassistant.components.climate] Setting up demo.climate
2024-10-16 17:13:28.629 INFO (MainThread) [homeassistant.setup] Setting up cover
2024-10-16 17:13:28.631 INFO (MainThread) [homeassistant.setup] Setup of domain cover took 0.00 seconds
2024-10-16 17:13:28.634 INFO (MainThread) [homeassistant.components.cover] Setting up demo.cover
2024-10-16 17:13:28.641 INFO (MainThread) [homeassistant.setup] Setting up date
2024-10-16 17:13:28.642 INFO (MainThread) [homeassistant.setup] Setup of domain date took 0.00 seconds
2024-10-16 17:13:28.643 INFO (MainThread) [homeassistant.components.date] Setting up demo.date
2024-10-16 17:13:28.649 INFO (MainThread) [homeassistant.setup] Setting up datetime
2024-10-16 17:13:28.651 INFO (MainThread) [homeassistant.setup] Setup of domain datetime took 0.00 seconds
2024-10-16 17:13:28.652 INFO (MainThread) [homeassistant.components.datetime] Setting up demo.datetime
2024-10-16 17:13:28.657 INFO (MainThread) [homeassistant.setup] Setting up event
2024-10-16 17:13:28.658 INFO (MainThread) [homeassistant.setup] Setup of domain event took 0.00 seconds
2024-10-16 17:13:28.658 INFO (MainThread) [homeassistant.components.event] Setting up demo.event
2024-10-16 17:13:28.664 INFO (MainThread) [homeassistant.setup] Setting up fan
2024-10-16 17:13:28.669 INFO (MainThread) [homeassistant.setup] Setup of domain fan took 0.00 seconds
2024-10-16 17:13:28.669 INFO (MainThread) [homeassistant.components.fan] Setting up demo.fan
2024-10-16 17:13:28.676 INFO (MainThread) [homeassistant.setup] Setting up humidifier
2024-10-16 17:13:28.678 INFO (MainThread) [homeassistant.setup] Setup of domain humidifier took 0.00 seconds
2024-10-16 17:13:28.681 INFO (MainThread) [homeassistant.components.humidifier] Setting up demo.humidifier
2024-10-16 17:13:28.686 INFO (MainThread) [homeassistant.setup] Setting up light
2024-10-16 17:13:28.693 INFO (MainThread) [homeassistant.setup] Setup of domain light took 0.01 seconds
2024-10-16 17:13:28.700 INFO (MainThread) [homeassistant.components.light] Setting up demo.light
2024-10-16 17:13:28.707 INFO (MainThread) [homeassistant.setup] Setting up lock
2024-10-16 17:13:28.708 INFO (MainThread) [homeassistant.setup] Setup of domain lock took 0.00 seconds
2024-10-16 17:13:28.709 INFO (MainThread) [homeassistant.components.lock] Setting up demo.lock
2024-10-16 17:13:28.715 INFO (MainThread) [homeassistant.setup] Setting up media_player
2024-10-16 17:13:28.732 INFO (MainThread) [homeassistant.setup] Setup of domain media_player took 0.02 seconds
2024-10-16 17:13:28.736 INFO (MainThread) [homeassistant.components.media_player] Setting up demo.media_player
2024-10-16 17:13:28.744 INFO (MainThread) [homeassistant.components.notify] Setting up demo.notify
2024-10-16 17:13:28.749 INFO (MainThread) [homeassistant.setup] Setting up number
2024-10-16 17:13:28.750 INFO (MainThread) [homeassistant.setup] Setup of domain number took 0.00 seconds
2024-10-16 17:13:28.751 INFO (MainThread) [homeassistant.components.number] Setting up demo.number
2024-10-16 17:13:28.758 INFO (MainThread) [homeassistant.setup] Setting up select
2024-10-16 17:13:28.761 INFO (MainThread) [homeassistant.setup] Setup of domain select took 0.00 seconds
2024-10-16 17:13:28.761 INFO (MainThread) [homeassistant.components.select] Setting up demo.select
2024-10-16 17:13:28.766 INFO (MainThread) [homeassistant.components.sensor] Setting up demo.sensor
2024-10-16 17:13:28.778 INFO (MainThread) [homeassistant.setup] Setting up siren
2024-10-16 17:13:28.780 INFO (MainThread) [homeassistant.setup] Setup of domain siren took 0.00 seconds
2024-10-16 17:13:28.780 INFO (MainThread) [homeassistant.components.siren] Setting up demo.siren
2024-10-16 17:13:28.785 INFO (MainThread) [homeassistant.components.stt] Setting up demo.stt
2024-10-16 17:13:28.791 INFO (MainThread) [homeassistant.setup] Setting up switch
2024-10-16 17:13:28.792 INFO (MainThread) [homeassistant.setup] Setup of domain switch took 0.00 seconds
2024-10-16 17:13:28.793 INFO (MainThread) [homeassistant.components.switch] Setting up demo.switch
2024-10-16 17:13:28.799 INFO (MainThread) [homeassistant.setup] Setting up text
2024-10-16 17:13:28.800 INFO (MainThread) [homeassistant.setup] Setup of domain text took 0.00 seconds
2024-10-16 17:13:28.801 INFO (MainThread) [homeassistant.components.text] Setting up demo.text
2024-10-16 17:13:28.809 INFO (MainThread) [homeassistant.setup] Setting up time
2024-10-16 17:13:28.811 INFO (MainThread) [homeassistant.setup] Setup of domain time took 0.00 seconds
2024-10-16 17:13:28.811 INFO (MainThread) [homeassistant.components.time] Setting up demo.time
2024-10-16 17:13:28.816 INFO (MainThread) [homeassistant.setup] Setting up update
2024-10-16 17:13:28.818 INFO (MainThread) [homeassistant.setup] Setup of domain update took 0.00 seconds
2024-10-16 17:13:28.818 INFO (MainThread) [homeassistant.components.update] Setting up demo.update
2024-10-16 17:13:28.829 INFO (MainThread) [homeassistant.setup] Setting up vacuum
2024-10-16 17:13:28.831 INFO (MainThread) [homeassistant.setup] Setup of domain vacuum took 0.00 seconds
2024-10-16 17:13:28.834 INFO (MainThread) [homeassistant.components.vacuum] Setting up demo.vacuum
2024-10-16 17:13:28.841 INFO (MainThread) [homeassistant.setup] Setting up water_heater
2024-10-16 17:13:28.845 INFO (MainThread) [homeassistant.setup] Setup of domain water_heater took 0.00 seconds
2024-10-16 17:13:28.845 INFO (MainThread) [homeassistant.components.water_heater] Setting up demo.water_heater
2024-10-16 17:13:28.851 INFO (MainThread) [homeassistant.setup] Setting up weather
2024-10-16 17:13:28.855 INFO (MainThread) [homeassistant.setup] Setup of domain weather took 0.00 seconds
2024-10-16 17:13:28.859 INFO (MainThread) [homeassistant.components.weather] Setting up demo.weather
2024-10-16 17:13:28.867 WARNING (MainThread) [asyncio] Executing <Task finished name='config entry setup Demo demo 01JAB44XFZ9N4EEMF3Q7SM06XH' coro=<ConfigEntry.async_setup_locked() done, defined at /home/vscode/.local/lib/python3.12/site-packages/homeassistant/config_entries.py:726> result=None created at /home/vscode/.local/lib/python3.12/site-packages/homeassistant/util/async_.py:45> took 0.295 seconds
2024-10-16 17:13:28.889 DEBUG (MainThread) [custom_components.area_tree] Finished fetching area_tree data in 0.603 seconds (success: True)
2024-10-16 17:13:28.894 INFO (MainThread) [homeassistant.components.image_processing] Setting up demo.image_processing
2024-10-16 17:13:28.900 INFO (MainThread) [homeassistant.components.device_tracker] Setting up demo.device_tracker
2024-10-16 17:13:28.911 INFO (MainThread) [homeassistant.components.sensor] Setting up area_tree.sensor
2024-10-16 17:13:28.915 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up area_tree.binary_sensor
2024-10-16 17:13:28.921 INFO (MainThread) [homeassistant.components.switch] Setting up area_tree.switch
2024-10-16 17:13:29.037 INFO (MainThread) [homeassistant.components.weather] Setting up met.weather
2024-10-16 17:13:29.043 INFO (MainThread) [homeassistant.bootstrap] Home Assistant initialized in 5.31s
2024-10-16 17:13:29.044 INFO (MainThread) [homeassistant.core] Starting Home Assistant
2024-10-16 17:13:29.201 INFO (MainThread) [asyncio] <Server sockets=(<asyncio.TransportSocket fd=26, family=2, type=1, proto=6, laddr=('172.17.0.2', 40000)>,)> is serving
2024-10-16 17:13:29.616 ERROR (SyncWorker_1) [aiodhcpwatcher] Cannot watch for dhcp packets without a functional packet filter: libpcap is not available. Cannot compile filter !
2024-10-16 17:14:25.456 WARNING (MainThread) [asyncio] Executing <Task pending name='Task-159' coro=<RequestHandler._handle_request() running at /home/vscode/.local/lib/python3.12/site-packages/aiohttp/web_protocol.py:477> wait_for=<Future pending cb=[Task.task_wakeup()] created at /usr/local/lib/python3.12/asyncio/base_events.py:449> cb=[Task.task_wakeup()] created at /home/vscode/.local/lib/python3.12/site-packages/aiohttp/web_protocol.py:556> took 0.127 seconds
2024-10-16 17:14:39.082 DEBUG (MainThread) [custom_components.area_tree] Finished fetching area_tree data in 0.075 seconds (success: True)
2024-10-16 17:14:39.083 INFO (MainThread) [homeassistant.components.sensor] Setting up area_tree.sensor
2024-10-16 17:14:39.089 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up area_tree.binary_sensor
2024-10-16 17:14:39.096 INFO (MainThread) [homeassistant.components.switch] Setting up area_tree.switch
2024-10-16 17:14:59.911 INFO (SyncWorker_2) [homeassistant.loader] Loaded min_max from homeassistant.components.min_max
2024-10-16 17:14:59.913 INFO (SyncWorker_2) [homeassistant.loader] Loaded moehlenhoff_alpha2 from homeassistant.components.moehlenhoff_alpha2
2024-10-16 17:14:59.915 INFO (SyncWorker_2) [homeassistant.loader] Loaded rpi_power from homeassistant.components.rpi_power
2024-10-16 17:14:59.916 INFO (SyncWorker_2) [homeassistant.loader] Loaded garages_amsterdam from homeassistant.components.garages_amsterdam
2024-10-16 17:14:59.917 INFO (SyncWorker_2) [homeassistant.loader] Loaded tod from homeassistant.components.tod
2024-10-16 17:14:59.920 INFO (SyncWorker_2) [homeassistant.loader] Loaded islamic_prayer_times from homeassistant.components.islamic_prayer_times
2024-10-16 17:14:59.923 INFO (SyncWorker_2) [homeassistant.loader] Loaded utility_meter from homeassistant.components.utility_meter
2024-10-16 17:14:59.931 INFO (SyncWorker_2) [homeassistant.loader] Loaded nmap_tracker from homeassistant.components.nmap_tracker
2024-10-16 17:14:59.935 INFO (SyncWorker_2) [homeassistant.loader] Loaded threshold from homeassistant.components.threshold
2024-10-16 17:14:59.937 INFO (SyncWorker_2) [homeassistant.loader] Loaded plant from homeassistant.components.plant
2024-10-16 17:14:59.939 INFO (SyncWorker_2) [homeassistant.loader] Loaded holiday from homeassistant.components.holiday
2024-10-16 17:14:59.942 INFO (SyncWorker_2) [homeassistant.loader] Loaded generic_thermostat from homeassistant.components.generic_thermostat
2024-10-16 17:14:59.943 INFO (SyncWorker_2) [homeassistant.loader] Loaded workday from homeassistant.components.workday
2024-10-16 17:14:59.945 INFO (SyncWorker_2) [homeassistant.loader] Loaded cpuspeed from homeassistant.components.cpuspeed
2024-10-16 17:14:59.956 INFO (SyncWorker_2) [homeassistant.loader] Loaded generic from homeassistant.components.generic
2024-10-16 17:14:59.958 INFO (SyncWorker_2) [homeassistant.loader] Loaded filesize from homeassistant.components.filesize
2024-10-16 17:14:59.961 INFO (SyncWorker_2) [homeassistant.loader] Loaded uptime from homeassistant.components.uptime
2024-10-16 17:14:59.964 INFO (SyncWorker_2) [homeassistant.loader] Loaded waze_travel_time from homeassistant.components.waze_travel_time
2024-10-16 17:14:59.966 INFO (SyncWorker_2) [homeassistant.loader] Loaded moon from homeassistant.components.moon
2024-10-16 17:14:59.967 INFO (SyncWorker_2) [homeassistant.loader] Loaded generic_hygrostat from homeassistant.components.generic_hygrostat
2024-10-16 17:14:59.969 INFO (SyncWorker_2) [homeassistant.loader] Loaded local_todo from homeassistant.components.local_todo
2024-10-16 17:14:59.972 INFO (SyncWorker_2) [homeassistant.loader] Loaded local_calendar from homeassistant.components.local_calendar
2024-10-16 17:14:59.974 INFO (SyncWorker_2) [homeassistant.loader] Loaded aurora from homeassistant.components.aurora
2024-10-16 17:14:59.976 INFO (SyncWorker_2) [homeassistant.loader] Loaded season from homeassistant.components.season
2024-10-16 17:14:59.979 INFO (SyncWorker_2) [homeassistant.loader] Loaded emulated_roku from homeassistant.components.emulated_roku
2024-10-16 17:14:59.982 INFO (SyncWorker_2) [homeassistant.loader] Loaded nextbus from homeassistant.components.nextbus
2024-10-16 17:14:59.983 INFO (SyncWorker_2) [homeassistant.loader] Loaded proximity from homeassistant.components.proximity
2024-10-16 17:14:59.985 INFO (SyncWorker_2) [homeassistant.loader] Loaded growatt_server from homeassistant.components.growatt_server
2024-10-16 17:14:59.987 INFO (SyncWorker_2) [homeassistant.loader] Loaded energenie_power_sockets from homeassistant.components.energenie_power_sockets
2024-10-16 17:14:59.988 INFO (SyncWorker_2) [homeassistant.loader] Loaded alert from homeassistant.components.alert
2024-10-16 17:14:59.990 INFO (SyncWorker_2) [homeassistant.loader] Loaded homekit_controller from homeassistant.components.homekit_controller
2024-10-16 17:14:59.993 INFO (SyncWorker_2) [homeassistant.loader] Loaded zodiac from homeassistant.components.zodiac
2024-10-16 17:14:59.995 INFO (SyncWorker_2) [homeassistant.loader] Loaded version from homeassistant.components.version
2024-10-16 17:14:59.997 INFO (SyncWorker_2) [homeassistant.loader] Loaded derivative from homeassistant.components.derivative
2024-10-16 17:15:00.000 INFO (SyncWorker_2) [homeassistant.loader] Loaded integration from homeassistant.components.integration
2024-10-16 17:15:00.001 INFO (SyncWorker_2) [homeassistant.loader] Loaded google_travel_time from homeassistant.components.google_travel_time
2024-10-16 17:15:00.003 INFO (SyncWorker_2) [homeassistant.loader] Loaded time_date from homeassistant.components.time_date
2024-10-16 17:15:00.005 INFO (SyncWorker_2) [homeassistant.loader] Loaded local_ip from homeassistant.components.local_ip
2024-10-16 17:15:00.007 INFO (SyncWorker_2) [homeassistant.loader] Loaded cert_expiry from homeassistant.components.cert_expiry
2024-10-16 17:15:24.198 DEBUG (MainThread) [custom_components.area_tree] Finished fetching area_tree data in 0.025 seconds (success: True)
2024-10-16 17:15:24.200 INFO (MainThread) [homeassistant.components.sensor] Setting up area_tree.sensor
2024-10-16 17:15:24.205 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.area_tree entity: sensor.integration_sensor
2024-10-16 17:15:24.217 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up area_tree.binary_sensor
2024-10-16 17:15:24.220 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.area_tree entity: binary_sensor.area_tree_binary_sensor
2024-10-16 17:15:24.230 INFO (MainThread) [homeassistant.components.switch] Setting up area_tree.switch
2024-10-16 17:15:24.234 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new switch.area_tree entity: switch.integration_switch
@thargy thargy added the Bug label Oct 16, 2024
@ludeeus
Copy link
Owner

ludeeus commented Oct 16, 2024

That is not something for this repository.
You need to seek help elsewere.

@ludeeus ludeeus closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2024
@thargy
Copy link
Author

thargy commented Oct 17, 2024

Pre-amble

OK, fair enough. After many hours of head scratching and searching, I found the issue and figured out a solution.

I hope you can figure me posting here because:

  1. Anyone else trying to debug using your repo in vscode will currently encounter the same probelm and will hopefully find this issue.
  2. It was not easy to figure out what was going on.
  3. You may wish to incorporate the below fix to support F5 debugging out of the box in vscode.

Problem

A discussion of the problem can be found here.

In short, this has been a known problem with HA's debugpy integration since the change to Python 3.12, which means that frozen modules now need to be explicitly turned off while debugging. Unfortunately, there's no 'easy' way to disable the frozen modules, at least until Python 3.13, which adds an environmental variable.

Further running the homeassistant module directly from Python, with the -Xfrozen_modules=off was not sufficient to use the debugpy integration, which would still complain of frozen modules in the console output:

 2024-10-16 17:16:26.345 INFO (MainThread) [homeassistant.setup] Setting up debugpy
 0.00s - Debugger warning: It seems that frozen modules are being used, which may
 0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
 0.00s - to python to disable frozen modules.
 0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
 2024-10-16 17:16:26.868 WARNING (MainThread) [homeassistant.components.debugpy] Waiting for remote debug connection on localhost:5678

Solution

I found the best way to enable debugging was to add a scripts\debug file to start homeassistant and debugpy directly without frozen modules:

#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

# Create config dir if not present
if [[ ! -d "${PWD}/config" ]]; then
    mkdir -p "${PWD}/config"
    hass --config "${PWD}/config" --script ensure_config
fi

# Set the path to custom_components
## This let's us have the structure we want <root>/custom_components/area_tree
## while at the same time have Home Assistant configuration inside <root>/config
## without resulting to symlinks.
export PYTHONPATH="${PYTHONPATH}:${PWD}/custom_components"

# Start Home Assistant
#
# See https://github.com/home-assistant/core/issues/110623#issuecomment-2266933072
# Also see https://docs.python.org/3/using/cmdline.html#envvar-PYTHON_FROZEN_MODULES for alternate fix when HA moves to Python 13, using env in launch.json
# Do not set debugpy in configuration.yaml if adding debugpy in command line here...

# To start and wait for remote debugger
python3 -Xfrozen_modules=off -m debugpy --listen localhost:5678 -m homeassistant --config ${PWD}/config

For consistency, I renamed scripts\develop to scripts\run and updated tasks.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Run Home Assistant",
            "type": "shell",
            "command": "scripts/run",
            "problemMatcher": []
        },
        {
            "label": "Debug Home Assistant",
            "type": "shell",
            "command": "scripts/debug",
            "isBackground": true,
            "problemMatcher": [
                {
                    "owner": "homeassistant",
                    "pattern": [
                        {
                            "regexp": "(.?)",
                            "file": 1,
                            "location": 1,
                            "message": 1
                        }
                    ],
                    "background": {
                        "activeOnStart": true,
                        "beginsPattern": ".?",
                        "endsPattern": "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}.\\d{3}",
                    }
                }
            ]
        },
        {
            "label": "Terminate Debug",
            "command": "echo ${input:terminate}",
            "type": "shell",
            "problemMatcher": []
        }
    ],
    "inputs": [
        {
            "id": "terminate",
            "type": "command",
            "command": "workbench.action.tasks.terminate",
            "args": "Debug Home Assistant"
        }
    ]
}

Alongside the original Run Home Assistant task, I added a Debug Home Assistant which executes scripts\debug as a background task, allowing the debugger to attach once the logs start to appear (see endsPattern regex). I also added a Terminate Debug task to kill the home assistant instance when the debugger disconnects.

The following launch.json then allows F5 debugging - which runs home assistant and attaches a debugger, and cleans up after the debugger is detached:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [

        {
            "name": "Debug Home Assistant",
            "type": "debugpy",
            "request": "attach",
            "connect": {
                "host": "localhost",
                "port": 5678
            },
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "."
                }
            ],
            "preLaunchTask": "Debug Home Assistant",
            "postDebugTask": "Terminate Debug",
            "justMyCode": false
        }
    ]
}

There's no reason for this launch.json to be excluded from the repository; it doesn't change because it is run in a container.

Future

When HA moves to Python 3.13, it may be possible to return to a single script for running/debugging that calls hass directly and runs as a service in debug mode. This is guaranteed though, and even if there is a better solution at that time (including supporting the debugpy integration directly), the above launch settings and tasks would still allow F5 debugging out of the box.

Although a relatively minor set of changes, the time saved for anyone wanting to debug using vscode will be massive. I'd be more than willing to submit a PR if you would be willing to consider it for inclusion?

@pcartwright81
Copy link

Not being able to debug on vs code was the first thing I noticed when I switched Home Assistant development environment. The .vscode folder has the launch.json and extensions.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants