Fix flaky TP-Link test (#33790)
parent
9d38413e7c
commit
8fb89854d3
|
@ -35,23 +35,11 @@ ATTR_DAILY_ENERGY_KWH = "daily_energy_kwh"
|
|||
ATTR_MONTHLY_ENERGY_KWH = "monthly_energy_kwh"
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the platform.
|
||||
|
||||
Deprecated.
|
||||
"""
|
||||
_LOGGER.warning(
|
||||
"Loading as a platform is no longer supported, "
|
||||
"convert to use the tplink component."
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistantType, config_entry, async_add_entities):
|
||||
"""Set up switches."""
|
||||
await async_add_entities_retry(
|
||||
hass, async_add_entities, hass.data[TPLINK_DOMAIN][CONF_LIGHT], add_entity
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
|
|
@ -24,17 +24,6 @@ ATTR_TOTAL_ENERGY_KWH = "total_energy_kwh"
|
|||
ATTR_CURRENT_A = "current_a"
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the platform.
|
||||
|
||||
Deprecated.
|
||||
"""
|
||||
_LOGGER.warning(
|
||||
"Loading as a platform is no longer supported, "
|
||||
"convert to use the tplink component."
|
||||
)
|
||||
|
||||
|
||||
def add_entity(device: SmartPlug, async_add_entities):
|
||||
"""Check if device is online and add the entity."""
|
||||
# Attempt to get the sysinfo. If it fails, it will raise an
|
||||
|
|
|
@ -116,6 +116,8 @@ async def test_configuring_devices_from_multiple_sources(hass):
|
|||
"homeassistant.components.tplink.common.Discover.discover"
|
||||
) as discover, patch(
|
||||
"homeassistant.components.tplink.common.SmartDevice._query_helper"
|
||||
), patch(
|
||||
"homeassistant.config_entries.ConfigEntries.async_forward_entry_setup"
|
||||
):
|
||||
discover_device_fail = SmartPlug("123.123.123.123")
|
||||
discover_device_fail.get_sysinfo = MagicMock(side_effect=SmartDeviceException())
|
||||
|
|
Loading…
Reference in New Issue