From 1800a60a6d72d8b81fd448cea783c2cb00d297ec Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 21 May 2024 15:04:31 -1000 Subject: [PATCH] Simplify and speed up mqtt_config_entry_enabled check (#117886) --- homeassistant/components/mqtt/util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/mqtt/util.py b/homeassistant/components/mqtt/util.py index ab21ab56f1b..6f8392c5cf1 100644 --- a/homeassistant/components/mqtt/util.py +++ b/homeassistant/components/mqtt/util.py @@ -84,9 +84,9 @@ async def async_forward_entry_setup_and_setup_discovery( def mqtt_config_entry_enabled(hass: HomeAssistant) -> bool | None: """Return true when the MQTT config entry is enabled.""" - if not bool(hass.config_entries.async_entries(DOMAIN)): - return None - return not bool(hass.config_entries.async_entries(DOMAIN)[0].disabled_by) + return hass.config_entries.async_has_entries( + DOMAIN, include_disabled=False, include_ignore=False + ) async def async_wait_for_mqtt_client(hass: HomeAssistant) -> bool: