diff --git a/homeassistant/components/modbus/cover.py b/homeassistant/components/modbus/cover.py index ca00576770e..2317bc5401f 100644 --- a/homeassistant/components/modbus/cover.py +++ b/homeassistant/components/modbus/cover.py @@ -49,12 +49,7 @@ async def async_setup_platform( discovery_info: DiscoveryInfoType | None = None, ): """Read configuration and create Modbus cover.""" - if discovery_info is None: - _LOGGER.warning( - "You're trying to init Modbus Cover in an unsupported way." - " Check https://www.home-assistant.io/integrations/modbus/#configuring-platform-cover" - " and fix your configuration" - ) + if discovery_info is None: # pragma: no cover return covers = [] diff --git a/homeassistant/components/modbus/fan.py b/homeassistant/components/modbus/fan.py index 7fabff25711..a4d4265846d 100644 --- a/homeassistant/components/modbus/fan.py +++ b/homeassistant/components/modbus/fan.py @@ -20,7 +20,7 @@ async def async_setup_platform( hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None ): """Read configuration and create Modbus fans.""" - if discovery_info is None: + if discovery_info is None: # pragma: no cover return fans = [] diff --git a/homeassistant/components/modbus/light.py b/homeassistant/components/modbus/light.py index f56b01ff001..3eae5ed3db3 100644 --- a/homeassistant/components/modbus/light.py +++ b/homeassistant/components/modbus/light.py @@ -20,8 +20,9 @@ async def async_setup_platform( hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None ): """Read configuration and create Modbus lights.""" - if discovery_info is None: + if discovery_info is None: # pragma: no cover return + lights = [] for entry in discovery_info[CONF_LIGHTS]: hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]] diff --git a/homeassistant/components/modbus/switch.py b/homeassistant/components/modbus/switch.py index 98e15d5b311..820e43419a0 100644 --- a/homeassistant/components/modbus/switch.py +++ b/homeassistant/components/modbus/switch.py @@ -22,6 +22,9 @@ async def async_setup_platform( """Read configuration and create Modbus switches.""" switches = [] + if discovery_info is None: # pragma: no cover + return + for entry in discovery_info[CONF_SWITCHES]: hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]] switches.append(ModbusSwitch(hub, entry)) diff --git a/tests/components/modbus/test_cover.py b/tests/components/modbus/test_cover.py index 8fbb45fde8e..4073e46a86e 100644 --- a/tests/components/modbus/test_cover.py +++ b/tests/components/modbus/test_cover.py @@ -1,5 +1,4 @@ """The tests for the Modbus cover component.""" -import logging from pymodbus.exceptions import ModbusException import pytest @@ -158,35 +157,6 @@ async def test_register_cover(hass, regs, expected): assert state == expected -@pytest.mark.parametrize("read_type", [CALL_TYPE_COIL, CONF_REGISTER]) -async def test_unsupported_config_cover(hass, read_type, caplog): - """ - Run test for cover. - - Initialize the Cover in the legacy manner via platform. - This test expects that the Cover won't be initialized, and that we get a config warning. - """ - device_name = "test_cover" - device_config = {CONF_NAME: device_name, read_type: 1234} - - caplog.set_level(logging.WARNING) - caplog.clear() - - await base_config_test( - hass, - device_config, - device_name, - COVER_DOMAIN, - CONF_COVERS, - None, - method_discovery=False, - expect_init_to_fail=True, - ) - - assert len(caplog.records) == 1 - assert caplog.records[0].levelname == "WARNING" - - async def test_service_cover_update(hass, mock_pymodbus): """Run test for service homeassistant.update_entity."""