From e682d8c6e2cb08074f167c8877f04da5602a2c30 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Sun, 4 Aug 2024 04:39:41 -1000 Subject: [PATCH] Handle command_line missing discovery_info (#116873) * command_line: Do not lead to erroring out code indexing None or empty discovery_info * Apply suggestions from code review Co-authored-by: Franck Nijhof --------- Co-authored-by: Erik Montnemery Co-authored-by: Franck Nijhof --- homeassistant/components/command_line/switch.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/homeassistant/components/command_line/switch.py b/homeassistant/components/command_line/switch.py index f8e9d21cf23..a3c3d0b3e9c 100644 --- a/homeassistant/components/command_line/switch.py +++ b/homeassistant/components/command_line/switch.py @@ -37,6 +37,8 @@ async def async_setup_platform( ) -> None: """Find and return switches controlled by shell commands.""" + if not discovery_info: + return switches = [] discovery_info = cast(DiscoveryInfoType, discovery_info) entities: dict[str, dict[str, Any]] = {