mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Remove old config from cover, including tests (#51118)
* Remove old config and standardize new config. * Add missing safeguard.
This commit is contained in:
parent
d200f1e504
commit
47f016b340
@ -49,12 +49,7 @@ async def async_setup_platform(
|
|||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
):
|
):
|
||||||
"""Read configuration and create Modbus cover."""
|
"""Read configuration and create Modbus cover."""
|
||||||
if discovery_info is None:
|
if discovery_info is None: # pragma: no cover
|
||||||
_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"
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
covers = []
|
covers = []
|
||||||
|
@ -20,7 +20,7 @@ async def async_setup_platform(
|
|||||||
hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None
|
hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None
|
||||||
):
|
):
|
||||||
"""Read configuration and create Modbus fans."""
|
"""Read configuration and create Modbus fans."""
|
||||||
if discovery_info is None:
|
if discovery_info is None: # pragma: no cover
|
||||||
return
|
return
|
||||||
fans = []
|
fans = []
|
||||||
|
|
||||||
|
@ -20,8 +20,9 @@ async def async_setup_platform(
|
|||||||
hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None
|
hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None
|
||||||
):
|
):
|
||||||
"""Read configuration and create Modbus lights."""
|
"""Read configuration and create Modbus lights."""
|
||||||
if discovery_info is None:
|
if discovery_info is None: # pragma: no cover
|
||||||
return
|
return
|
||||||
|
|
||||||
lights = []
|
lights = []
|
||||||
for entry in discovery_info[CONF_LIGHTS]:
|
for entry in discovery_info[CONF_LIGHTS]:
|
||||||
hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]]
|
hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]]
|
||||||
|
@ -22,6 +22,9 @@ async def async_setup_platform(
|
|||||||
"""Read configuration and create Modbus switches."""
|
"""Read configuration and create Modbus switches."""
|
||||||
switches = []
|
switches = []
|
||||||
|
|
||||||
|
if discovery_info is None: # pragma: no cover
|
||||||
|
return
|
||||||
|
|
||||||
for entry in discovery_info[CONF_SWITCHES]:
|
for entry in discovery_info[CONF_SWITCHES]:
|
||||||
hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]]
|
hub: ModbusHub = hass.data[MODBUS_DOMAIN][discovery_info[CONF_NAME]]
|
||||||
switches.append(ModbusSwitch(hub, entry))
|
switches.append(ModbusSwitch(hub, entry))
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""The tests for the Modbus cover component."""
|
"""The tests for the Modbus cover component."""
|
||||||
import logging
|
|
||||||
|
|
||||||
from pymodbus.exceptions import ModbusException
|
from pymodbus.exceptions import ModbusException
|
||||||
import pytest
|
import pytest
|
||||||
@ -158,35 +157,6 @@ async def test_register_cover(hass, regs, expected):
|
|||||||
assert state == 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):
|
async def test_service_cover_update(hass, mock_pymodbus):
|
||||||
"""Run test for service homeassistant.update_entity."""
|
"""Run test for service homeassistant.update_entity."""
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user