1 """The Remote Python Debugger integration."""
3 from __future__
import annotations
5 from asyncio
import Event, get_running_loop
7 from threading
import Thread
10 import voluptuous
as vol
21 SERVICE_START =
"start"
23 CONFIG_SCHEMA = vol.Schema(
27 vol.Optional(CONF_HOST, default=
"0.0.0.0"): cv.string,
28 vol.Optional(CONF_PORT, default=5678): cv.port,
29 vol.Optional(CONF_START, default=
True): cv.boolean,
30 vol.Optional(CONF_WAIT, default=
False): cv.boolean,
34 extra=vol.ALLOW_EXTRA,
37 _LOGGER = logging.getLogger(__name__)
40 async
def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
41 """Set up the Remote Python Debugger component."""
44 async
def debug_start(
45 call: ServiceCall |
None =
None, *, wait: bool =
True
47 """Enable asyncio debugging and start the debugger."""
48 get_running_loop().set_debug(
True)
50 await hass.async_add_executor_job(
51 debugpy.listen, (conf[CONF_HOST], conf[CONF_PORT])
56 "Waiting for remote debug connection on %s:%s",
63 debugpy.wait_for_client()
64 hass.loop.call_soon_threadsafe(ready.set)
66 Thread(target=waitfor).start()
71 "Listening for remote debug connection on %s:%s",
77 hass, DOMAIN, SERVICE_START, debug_start, schema=vol.Schema({})
82 await debug_start(wait=conf[CONF_WAIT])
bool async_setup(HomeAssistant hass, ConfigType config)
None async_register_admin_service(HomeAssistant hass, str domain, str service, Callable[[ServiceCall], Awaitable[None]|None] service_func, VolSchemaType schema=vol.Schema({}, extra=vol.PREVENT_EXTRA))