From 7c22225cd19ddd4e84d71781794876e6715a854d Mon Sep 17 00:00:00 2001 From: Jan Bouwhuis Date: Tue, 18 Jul 2023 14:29:45 +0200 Subject: [PATCH] Allow ADR 0007 compliant schema for mqtt (#94305) * Enforce listed entities in MQTT yaml config * Add tests for setup with listed items * Fix test * Remove validator add comment * Update homeassistant/components/mqtt/__init__.py Co-authored-by: Erik Montnemery --------- Co-authored-by: Erik Montnemery --- homeassistant/components/mqtt/__init__.py | 67 +++++++++++++------ .../components/mqtt/config_integration.py | 2 +- homeassistant/components/mqtt/mixins.py | 11 ++- homeassistant/components/mqtt/models.py | 2 +- .../mqtt/test_alarm_control_panel.py | 6 +- tests/components/mqtt/test_binary_sensor.py | 6 +- tests/components/mqtt/test_button.py | 6 +- tests/components/mqtt/test_camera.py | 6 +- tests/components/mqtt/test_climate.py | 6 +- tests/components/mqtt/test_cover.py | 6 +- tests/components/mqtt/test_fan.py | 6 +- tests/components/mqtt/test_humidifier.py | 6 +- tests/components/mqtt/test_init.py | 4 +- tests/components/mqtt/test_legacy_vacuum.py | 6 +- tests/components/mqtt/test_light.py | 6 +- tests/components/mqtt/test_light_json.py | 6 +- tests/components/mqtt/test_light_template.py | 6 +- tests/components/mqtt/test_lock.py | 6 +- tests/components/mqtt/test_number.py | 6 +- tests/components/mqtt/test_scene.py | 6 +- tests/components/mqtt/test_select.py | 6 +- tests/components/mqtt/test_sensor.py | 6 +- tests/components/mqtt/test_siren.py | 6 +- tests/components/mqtt/test_state_vacuum.py | 6 +- tests/components/mqtt/test_switch.py | 6 +- tests/components/mqtt/test_text.py | 6 +- tests/components/mqtt/test_update.py | 6 +- tests/components/mqtt/test_water_heater.py | 6 +- 28 files changed, 176 insertions(+), 48 deletions(-) diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index de5093d1817..405eb86e6ec 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -5,7 +5,7 @@ import asyncio from collections.abc import Callable from datetime import datetime import logging -from typing import Any, cast +from typing import Any, TypeVar, cast import jinja2 import voluptuous as vol @@ -42,7 +42,7 @@ from .client import ( # noqa: F401 publish, subscribe, ) -from .config_integration import PLATFORM_CONFIG_SCHEMA_BASE +from .config_integration import CONFIG_SCHEMA_BASE from .const import ( # noqa: F401 ATTR_PAYLOAD, ATTR_QOS, @@ -130,25 +130,54 @@ CONFIG_ENTRY_CONFIG_KEYS = [ CONF_WILL_MESSAGE, ] +_T = TypeVar("_T") + +REMOVED_OPTIONS = vol.All( + cv.removed(CONF_BIRTH_MESSAGE), # Removed in HA Core 2023.4 + cv.removed(CONF_BROKER), # Removed in HA Core 2023.4 + cv.removed(CONF_CERTIFICATE), # Removed in HA Core 2023.4 + cv.removed(CONF_CLIENT_ID), # Removed in HA Core 2023.4 + cv.removed(CONF_CLIENT_CERT), # Removed in HA Core 2023.4 + cv.removed(CONF_CLIENT_KEY), # Removed in HA Core 2023.4 + cv.removed(CONF_DISCOVERY), # Removed in HA Core 2022.3 + cv.removed(CONF_DISCOVERY_PREFIX), # Removed in HA Core 2023.4 + cv.removed(CONF_KEEPALIVE), # Removed in HA Core 2023.4 + cv.removed(CONF_PASSWORD), # Removed in HA Core 2023.4 + cv.removed(CONF_PORT), # Removed in HA Core 2023.4 + cv.removed(CONF_PROTOCOL), # Removed in HA Core 2023.4 + cv.removed(CONF_TLS_INSECURE), # Removed in HA Core 2023.4 + cv.removed(CONF_USERNAME), # Removed in HA Core 2023.4 + cv.removed(CONF_WILL_MESSAGE), # Removed in HA Core 2023.4 +) + +# We accept 2 schemes for configuring manual MQTT items +# +# Preferred style: +# +# mqtt: +# - {domain}: +# name: "" +# ... +# - {domain}: +# name: "" +# ... +# ``` +# +# Legacy supported style: +# +# mqtt: +# {domain}: +# - name: "" +# ... +# - name: "" +# ... CONFIG_SCHEMA = vol.Schema( { DOMAIN: vol.All( - cv.removed(CONF_BIRTH_MESSAGE), # Removed in HA Core 2023.4 - cv.removed(CONF_BROKER), # Removed in HA Core 2023.4 - cv.removed(CONF_CERTIFICATE), # Removed in HA Core 2023.4 - cv.removed(CONF_CLIENT_ID), # Removed in HA Core 2023.4 - cv.removed(CONF_CLIENT_CERT), # Removed in HA Core 2023.4 - cv.removed(CONF_CLIENT_KEY), # Removed in HA Core 2023.4 - cv.removed(CONF_DISCOVERY), # Removed in HA Core 2022.3 - cv.removed(CONF_DISCOVERY_PREFIX), # Removed in HA Core 2023.4 - cv.removed(CONF_KEEPALIVE), # Removed in HA Core 2023.4 - cv.removed(CONF_PASSWORD), # Removed in HA Core 2023.4 - cv.removed(CONF_PORT), # Removed in HA Core 2023.4 - cv.removed(CONF_PROTOCOL), # Removed in HA Core 2023.4 - cv.removed(CONF_TLS_INSECURE), # Removed in HA Core 2023.4 - cv.removed(CONF_USERNAME), # Removed in HA Core 2023.4 - cv.removed(CONF_WILL_MESSAGE), # Removed in HA Core 2023.4 - PLATFORM_CONFIG_SCHEMA_BASE, + cv.ensure_list, + cv.remove_falsy, + [REMOVED_OPTIONS], + [CONFIG_SCHEMA_BASE], ) }, extra=vol.ALLOW_EXTRA, @@ -190,7 +219,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: # Fetch configuration conf = dict(entry.data) hass_config = await conf_util.async_hass_config_yaml(hass) - mqtt_yaml = PLATFORM_CONFIG_SCHEMA_BASE(hass_config.get(DOMAIN, {})) + mqtt_yaml = CONFIG_SCHEMA(hass_config).get(DOMAIN, []) await async_create_certificate_temp_files(hass, conf) client = MQTT(hass, entry, conf) if DOMAIN in hass.data: diff --git a/homeassistant/components/mqtt/config_integration.py b/homeassistant/components/mqtt/config_integration.py index ba2e0427ba7..ef2c771218a 100644 --- a/homeassistant/components/mqtt/config_integration.py +++ b/homeassistant/components/mqtt/config_integration.py @@ -52,7 +52,7 @@ from .const import ( DEFAULT_TLS_PROTOCOL = "auto" -PLATFORM_CONFIG_SCHEMA_BASE = vol.Schema( +CONFIG_SCHEMA_BASE = vol.Schema( { Platform.ALARM_CONTROL_PANEL.value: vol.All( cv.ensure_list, diff --git a/homeassistant/components/mqtt/mixins.py b/homeassistant/components/mqtt/mixins.py index e1e5f3d61bb..314800f33f2 100644 --- a/homeassistant/components/mqtt/mixins.py +++ b/homeassistant/components/mqtt/mixins.py @@ -309,9 +309,16 @@ async def async_setup_entry_helper( mqtt_data = get_mqtt_data(hass) if not (config_yaml := mqtt_data.config): return - if domain not in config_yaml: + setups: list[Coroutine[Any, Any, None]] = [ + async_setup(config) + for config_item in config_yaml + for config_domain, configs in config_item.items() + for config in configs + if config_domain == domain + ] + if not setups: return - await asyncio.gather(*[async_setup(config) for config in config_yaml[domain]]) + await asyncio.gather(*setups) # discover manual configured MQTT items mqtt_data.reload_handlers[domain] = _async_setup_entities diff --git a/homeassistant/components/mqtt/models.py b/homeassistant/components/mqtt/models.py index 9f0a178ce87..fb11400a312 100644 --- a/homeassistant/components/mqtt/models.py +++ b/homeassistant/components/mqtt/models.py @@ -289,7 +289,7 @@ class MqttData: """Keep the MQTT entry data.""" client: MQTT - config: ConfigType + config: list[ConfigType] debug_info_entities: dict[str, EntityDebugInfo] = field(default_factory=dict) debug_info_triggers: dict[tuple[str, str], TriggerDebugInfo] = field( default_factory=dict diff --git a/tests/components/mqtt/test_alarm_control_panel.py b/tests/components/mqtt/test_alarm_control_panel.py index ee32b7131c4..d1b1d6b68b3 100644 --- a/tests/components/mqtt/test_alarm_control_panel.py +++ b/tests/components/mqtt/test_alarm_control_panel.py @@ -1096,7 +1096,11 @@ async def test_reloadable( await help_test_reloadable(hass, mqtt_client_mock, domain, config) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_binary_sensor.py b/tests/components/mqtt/test_binary_sensor.py index 921f46703c2..d32754625f4 100644 --- a/tests/components/mqtt/test_binary_sensor.py +++ b/tests/components/mqtt/test_binary_sensor.py @@ -1203,7 +1203,11 @@ async def test_skip_restoring_state_with_over_due_expire_trigger( assert state.state == STATE_UNAVAILABLE -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_button.py b/tests/components/mqtt/test_button.py index e99182323c8..fa16ef77817 100644 --- a/tests/components/mqtt/test_button.py +++ b/tests/components/mqtt/test_button.py @@ -545,7 +545,11 @@ async def test_reloadable( await help_test_reloadable(hass, mqtt_client_mock, domain, config) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_camera.py b/tests/components/mqtt/test_camera.py index 8bb21f5eb51..5552457c213 100644 --- a/tests/components/mqtt/test_camera.py +++ b/tests/components/mqtt/test_camera.py @@ -439,7 +439,11 @@ async def test_reloadable( await help_test_reloadable(hass, mqtt_client_mock, domain, config) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_climate.py b/tests/components/mqtt/test_climate.py index 4a6d1bf64d4..e717c04b317 100644 --- a/tests/components/mqtt/test_climate.py +++ b/tests/components/mqtt/test_climate.py @@ -2484,7 +2484,11 @@ async def test_reloadable( await help_test_reloadable(hass, mqtt_client_mock, domain, config) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_cover.py b/tests/components/mqtt/test_cover.py index c388ded6587..2eec5f8374b 100644 --- a/tests/components/mqtt/test_cover.py +++ b/tests/components/mqtt/test_cover.py @@ -3642,7 +3642,11 @@ async def test_encoding_subscribable_topics( ) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_fan.py b/tests/components/mqtt/test_fan.py index c4181a3f885..803a0d74766 100644 --- a/tests/components/mqtt/test_fan.py +++ b/tests/components/mqtt/test_fan.py @@ -2220,7 +2220,11 @@ async def test_reloadable( await help_test_reloadable(hass, mqtt_client_mock, domain, config) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_humidifier.py b/tests/components/mqtt/test_humidifier.py index 1c386b28703..0cc4d936841 100644 --- a/tests/components/mqtt/test_humidifier.py +++ b/tests/components/mqtt/test_humidifier.py @@ -1545,7 +1545,11 @@ async def test_reloadable( await help_test_reloadable(hass, mqtt_client_mock, domain, config) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_init.py b/tests/components/mqtt/test_init.py index 9432f231301..3395dc0825f 100644 --- a/tests/components/mqtt/test_init.py +++ b/tests/components/mqtt/test_init.py @@ -2106,8 +2106,8 @@ async def test_setup_manual_mqtt_with_invalid_config( with pytest.raises(AssertionError): await mqtt_mock_entry() assert ( - "Invalid config for [mqtt]: required key not provided @ data['mqtt']['light'][0]['command_topic']." - " Got None. (See ?, line ?)" in caplog.text + "Invalid config for [mqtt]: required key not provided @ data['mqtt'][0]['light'][0]['command_topic']. " + "Got None. (See ?, line ?)" in caplog.text ) diff --git a/tests/components/mqtt/test_legacy_vacuum.py b/tests/components/mqtt/test_legacy_vacuum.py index 6b1a74f256d..85e3bdd12b9 100644 --- a/tests/components/mqtt/test_legacy_vacuum.py +++ b/tests/components/mqtt/test_legacy_vacuum.py @@ -1087,7 +1087,11 @@ async def test_encoding_subscribable_topics( ) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_light.py b/tests/components/mqtt/test_light.py index 59d5090b711..08def9a923e 100644 --- a/tests/components/mqtt/test_light.py +++ b/tests/components/mqtt/test_light.py @@ -3440,7 +3440,11 @@ async def test_sending_mqtt_xy_command_with_template( assert state.attributes["xy_color"] == (0.151, 0.343) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_light_json.py b/tests/components/mqtt/test_light_json.py index 5a7bedd91e6..7ff4ccbab85 100644 --- a/tests/components/mqtt/test_light_json.py +++ b/tests/components/mqtt/test_light_json.py @@ -2441,7 +2441,11 @@ async def test_encoding_subscribable_topics( ) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_light_template.py b/tests/components/mqtt/test_light_template.py index 4727caca2cc..0583a1176b6 100644 --- a/tests/components/mqtt/test_light_template.py +++ b/tests/components/mqtt/test_light_template.py @@ -1354,7 +1354,11 @@ async def test_encoding_subscribable_topics( ) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_lock.py b/tests/components/mqtt/test_lock.py index 2b77a573bad..bf7e1529a4e 100644 --- a/tests/components/mqtt/test_lock.py +++ b/tests/components/mqtt/test_lock.py @@ -1006,7 +1006,11 @@ async def test_encoding_subscribable_topics( ) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_number.py b/tests/components/mqtt/test_number.py index f882209139c..96d9cdcef64 100644 --- a/tests/components/mqtt/test_number.py +++ b/tests/components/mqtt/test_number.py @@ -1097,7 +1097,11 @@ async def test_encoding_subscribable_topics( ) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_scene.py b/tests/components/mqtt/test_scene.py index 4da60d44bb7..dfea7b3f915 100644 --- a/tests/components/mqtt/test_scene.py +++ b/tests/components/mqtt/test_scene.py @@ -251,7 +251,11 @@ async def test_reloadable( await help_test_reloadable(hass, mqtt_client_mock, domain, config) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_select.py b/tests/components/mqtt/test_select.py index 583e65bc61c..f1903fa4c3c 100644 --- a/tests/components/mqtt/test_select.py +++ b/tests/components/mqtt/test_select.py @@ -762,7 +762,11 @@ async def test_encoding_subscribable_topics( ) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_sensor.py b/tests/components/mqtt/test_sensor.py index d5483cf3a74..d6ab692af52 100644 --- a/tests/components/mqtt/test_sensor.py +++ b/tests/components/mqtt/test_sensor.py @@ -1385,7 +1385,11 @@ async def test_encoding_subscribable_topics( ) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_siren.py b/tests/components/mqtt/test_siren.py index 76a9cb9c6f6..7c448eba85e 100644 --- a/tests/components/mqtt/test_siren.py +++ b/tests/components/mqtt/test_siren.py @@ -1067,7 +1067,11 @@ async def test_encoding_subscribable_topics( ) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_state_vacuum.py b/tests/components/mqtt/test_state_vacuum.py index b22fb96aa13..a24884941fc 100644 --- a/tests/components/mqtt/test_state_vacuum.py +++ b/tests/components/mqtt/test_state_vacuum.py @@ -809,7 +809,11 @@ async def test_encoding_subscribable_topics( ) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_switch.py b/tests/components/mqtt/test_switch.py index b06cfa34442..4471cc7dc11 100644 --- a/tests/components/mqtt/test_switch.py +++ b/tests/components/mqtt/test_switch.py @@ -738,7 +738,11 @@ async def test_encoding_subscribable_topics( ) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_text.py b/tests/components/mqtt/test_text.py index b96b82277b0..9e068a07824 100644 --- a/tests/components/mqtt/test_text.py +++ b/tests/components/mqtt/test_text.py @@ -738,7 +738,11 @@ async def test_encoding_subscribable_topics( ) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_update.py b/tests/components/mqtt/test_update.py index 8e2cdaf8eaa..9c881352f8c 100644 --- a/tests/components/mqtt/test_update.py +++ b/tests/components/mqtt/test_update.py @@ -696,7 +696,11 @@ async def test_entity_id_update_discovery_update( ) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: diff --git a/tests/components/mqtt/test_water_heater.py b/tests/components/mqtt/test_water_heater.py index 942a2ec87d4..c4f798e05ec 100644 --- a/tests/components/mqtt/test_water_heater.py +++ b/tests/components/mqtt/test_water_heater.py @@ -1087,7 +1087,11 @@ async def test_reloadable( await help_test_reloadable(hass, mqtt_client_mock, domain, config) -@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG]) +@pytest.mark.parametrize( + "hass_config", + [DEFAULT_CONFIG, {"mqtt": [DEFAULT_CONFIG["mqtt"]]}], + ids=["platform_key", "listed"], +) async def test_setup_manual_entity_from_yaml( hass: HomeAssistant, mqtt_mock_entry: MqttMockHAClientGenerator ) -> None: