From 11b0b2bd3db7fc83407b22f6af28d5bb24cffde3 Mon Sep 17 00:00:00 2001 From: jbouwh Date: Wed, 25 Jun 2025 13:06:53 +0000 Subject: [PATCH] Exclude `entity_category` from YAML and discovery export --- homeassistant/components/mqtt/config_flow.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/homeassistant/components/mqtt/config_flow.py b/homeassistant/components/mqtt/config_flow.py index 193c96128f0..52f00c82c27 100644 --- a/homeassistant/components/mqtt/config_flow.py +++ b/homeassistant/components/mqtt/config_flow.py @@ -564,6 +564,8 @@ SUPPORTED_COLOR_MODES_SELECTOR = SelectSelector( ) ) +EXCLUDE_FROM_CONFIG_IF_NONE = {CONF_ENTITY_CATEGORY} + @callback def validate_cover_platform_config( @@ -3189,6 +3191,9 @@ class MQTTSubentryFlowHandler(ConfigSubentryFlow): component_config.update( self._subentry_data["device"].get("mqtt_settings", {}).copy() ) + for field in EXCLUDE_FROM_CONFIG_IF_NONE: + if field in component_config and component_config[field] is None: + component_config.pop(field) mqtt_yaml_config.append({platform: component_config}) yaml_config = yaml.dump(mqtt_yaml_config_base) @@ -3237,6 +3242,9 @@ class MQTTSubentryFlowHandler(ConfigSubentryFlow): component_config.update( self._subentry_data["device"].get("mqtt_settings", {}).copy() ) + for field in EXCLUDE_FROM_CONFIG_IF_NONE: + if field in component_config and component_config[field] is None: + component_config.pop(field) discovery_payload["cmps"][component_id] = component_config data_schema = vol.Schema(