mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Remove unused RainMachine config flow function (#32165)
* Remove unused RainMachine config flow function * Remove test we don't need * Code review comments * Linting
This commit is contained in:
parent
7e387f93d6
commit
75f465bf7e
@ -24,7 +24,6 @@ from homeassistant.helpers.entity import Entity
|
|||||||
from homeassistant.helpers.event import async_track_time_interval
|
from homeassistant.helpers.event import async_track_time_interval
|
||||||
from homeassistant.helpers.service import verify_domain_control
|
from homeassistant.helpers.service import verify_domain_control
|
||||||
|
|
||||||
from .config_flow import configured_instances
|
|
||||||
from .const import (
|
from .const import (
|
||||||
DATA_CLIENT,
|
DATA_CLIENT,
|
||||||
DATA_PROGRAMS,
|
DATA_PROGRAMS,
|
||||||
@ -118,9 +117,6 @@ async def async_setup(hass, config):
|
|||||||
conf = config[DOMAIN]
|
conf = config[DOMAIN]
|
||||||
|
|
||||||
for controller in conf[CONF_CONTROLLERS]:
|
for controller in conf[CONF_CONTROLLERS]:
|
||||||
if controller[CONF_IP_ADDRESS] in configured_instances(hass):
|
|
||||||
continue
|
|
||||||
|
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
hass.config_entries.flow.async_init(
|
hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_IMPORT}, data=controller
|
DOMAIN, context={"source": SOURCE_IMPORT}, data=controller
|
||||||
@ -132,6 +128,11 @@ async def async_setup(hass, config):
|
|||||||
|
|
||||||
async def async_setup_entry(hass, config_entry):
|
async def async_setup_entry(hass, config_entry):
|
||||||
"""Set up RainMachine as config entry."""
|
"""Set up RainMachine as config entry."""
|
||||||
|
if not config_entry.unique_id:
|
||||||
|
hass.config_entries.async_update_entry(
|
||||||
|
config_entry, unique_id=config_entry.data[CONF_IP_ADDRESS]
|
||||||
|
)
|
||||||
|
|
||||||
_verify_domain_control = verify_domain_control(hass, DOMAIN)
|
_verify_domain_control = verify_domain_control(hass, DOMAIN)
|
||||||
|
|
||||||
websession = aiohttp_client.async_get_clientsession(hass)
|
websession = aiohttp_client.async_get_clientsession(hass)
|
||||||
|
@ -5,19 +5,9 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_PORT
|
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD, CONF_PORT
|
||||||
from homeassistant.core import callback
|
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
|
|
||||||
from .const import DEFAULT_PORT, DOMAIN
|
from .const import DEFAULT_PORT, DOMAIN # pylint: disable=unused-import
|
||||||
|
|
||||||
|
|
||||||
@callback
|
|
||||||
def configured_instances(hass):
|
|
||||||
"""Return a set of configured RainMachine instances."""
|
|
||||||
return set(
|
|
||||||
entry.data[CONF_IP_ADDRESS]
|
|
||||||
for entry in hass.config_entries.async_entries(DOMAIN)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class RainMachineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
class RainMachineFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
|
@ -29,8 +29,6 @@ async def test_duplicate_error(hass):
|
|||||||
MockConfigEntry(domain=DOMAIN, unique_id="192.168.1.100", data=conf).add_to_hass(
|
MockConfigEntry(domain=DOMAIN, unique_id="192.168.1.100", data=conf).add_to_hass(
|
||||||
hass
|
hass
|
||||||
)
|
)
|
||||||
flow = config_flow.RainMachineFlowHandler()
|
|
||||||
flow.hass = hass
|
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": SOURCE_USER}, data=conf
|
DOMAIN, context={"source": SOURCE_USER}, data=conf
|
||||||
@ -39,22 +37,6 @@ async def test_duplicate_error(hass):
|
|||||||
assert result["reason"] == "already_configured"
|
assert result["reason"] == "already_configured"
|
||||||
|
|
||||||
|
|
||||||
async def test_get_configured_instances(hass):
|
|
||||||
"""Test retrieving all configured instances."""
|
|
||||||
conf = {
|
|
||||||
CONF_IP_ADDRESS: "192.168.1.100",
|
|
||||||
CONF_PASSWORD: "password",
|
|
||||||
CONF_PORT: 8080,
|
|
||||||
CONF_SSL: True,
|
|
||||||
}
|
|
||||||
|
|
||||||
MockConfigEntry(domain=DOMAIN, unique_id="192.168.1.100", data=conf).add_to_hass(
|
|
||||||
hass
|
|
||||||
)
|
|
||||||
|
|
||||||
assert len(config_flow.configured_instances(hass)) == 1
|
|
||||||
|
|
||||||
|
|
||||||
async def test_invalid_password(hass):
|
async def test_invalid_password(hass):
|
||||||
"""Test that an invalid password throws an error."""
|
"""Test that an invalid password throws an error."""
|
||||||
conf = {
|
conf = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user