diff --git a/IronOS b/IronOS new file mode 160000 index 00000000000..35f1cba2b90 --- /dev/null +++ b/IronOS @@ -0,0 +1 @@ +Subproject commit 35f1cba2b90da1a76e948ad5d141b5a786d13cd6 diff --git a/homeassistant/components/pyload/config_flow.py b/homeassistant/components/pyload/config_flow.py index 3e6cbd33bb3..c8d08f997f9 100644 --- a/homeassistant/components/pyload/config_flow.py +++ b/homeassistant/components/pyload/config_flow.py @@ -30,7 +30,7 @@ from homeassistant.helpers.selector import ( TextSelectorType, ) -from .const import DEFAULT_HOST, DEFAULT_NAME, DEFAULT_PORT, DOMAIN +from .const import DEFAULT_NAME, DEFAULT_PORT, DOMAIN _LOGGER = logging.getLogger(__name__) @@ -120,7 +120,7 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN): _LOGGER.exception("Unexpected exception") errors["base"] = "unknown" else: - title = user_input.pop(CONF_NAME, DEFAULT_NAME) + title = DEFAULT_NAME return self.async_create_entry(title=title, data=user_input) return self.async_show_form( @@ -131,25 +131,6 @@ class PyLoadConfigFlow(ConfigFlow, domain=DOMAIN): errors=errors, ) - async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResult: - """Import config from yaml.""" - - config = { - CONF_NAME: import_data.get(CONF_NAME), - CONF_HOST: import_data.get(CONF_HOST, DEFAULT_HOST), - CONF_PASSWORD: import_data.get(CONF_PASSWORD, ""), - CONF_PORT: import_data.get(CONF_PORT, DEFAULT_PORT), - CONF_SSL: import_data.get(CONF_SSL, False), - CONF_USERNAME: import_data.get(CONF_USERNAME, ""), - CONF_VERIFY_SSL: False, - } - - result = await self.async_step_user(config) - - if errors := result.get("errors"): - return self.async_abort(reason=errors["base"]) - return result - async def async_step_reauth( self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: diff --git a/homeassistant/components/pyload/const.py b/homeassistant/components/pyload/const.py index a0b66687bd0..e802152df16 100644 --- a/homeassistant/components/pyload/const.py +++ b/homeassistant/components/pyload/const.py @@ -2,12 +2,9 @@ DOMAIN = "pyload" -DEFAULT_HOST = "localhost" DEFAULT_NAME = "pyLoad" DEFAULT_PORT = 8000 -ISSUE_PLACEHOLDER = {"url": "/config/integrations/dashboard/add?domain=pyload"} - MANUFACTURER = "pyLoad Team" SERVICE_NAME = "pyLoad" diff --git a/homeassistant/components/pyload/sensor.py b/homeassistant/components/pyload/sensor.py index a1b29b46260..38f681d30d5 100644 --- a/homeassistant/components/pyload/sensor.py +++ b/homeassistant/components/pyload/sensor.py @@ -6,43 +6,19 @@ from collections.abc import Callable from dataclasses import dataclass from enum import StrEnum -import voluptuous as vol - from homeassistant.components.sensor import ( - PLATFORM_SCHEMA as SENSOR_PLATFORM_SCHEMA, SensorDeviceClass, SensorEntity, SensorEntityDescription, SensorStateClass, ) -from homeassistant.config_entries import SOURCE_IMPORT -from homeassistant.const import ( - CONF_HOST, - CONF_MONITORED_VARIABLES, - CONF_NAME, - CONF_PASSWORD, - CONF_PORT, - CONF_SSL, - CONF_USERNAME, - UnitOfDataRate, - UnitOfInformation, -) -from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant -from homeassistant.data_entry_flow import FlowResultType -import homeassistant.helpers.config_validation as cv +from homeassistant.const import UnitOfDataRate, UnitOfInformation +from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, StateType +from homeassistant.helpers.typing import StateType from . import PyLoadConfigEntry -from .const import ( - DEFAULT_HOST, - DEFAULT_NAME, - DEFAULT_PORT, - DOMAIN, - ISSUE_PLACEHOLDER, - UNIT_DOWNLOADS, -) +from .const import UNIT_DOWNLOADS from .coordinator import PyLoadData from .entity import BasePyLoadEntity @@ -106,63 +82,6 @@ SENSOR_DESCRIPTIONS: tuple[PyLoadSensorEntityDescription, ...] = ( ), ) -PLATFORM_SCHEMA = SENSOR_PLATFORM_SCHEMA.extend( - { - vol.Optional(CONF_HOST, default=DEFAULT_HOST): cv.string, - vol.Optional(CONF_MONITORED_VARIABLES, default=["speed"]): vol.All( - cv.ensure_list, [vol.In(PyLoadSensorEntity)] - ), - vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string, - vol.Optional(CONF_PASSWORD): cv.string, - vol.Optional(CONF_PORT, default=DEFAULT_PORT): cv.port, - vol.Optional(CONF_SSL, default=False): cv.boolean, - vol.Optional(CONF_USERNAME): cv.string, - } -) - - -async def async_setup_platform( - hass: HomeAssistant, - config: ConfigType, - add_entities: AddEntitiesCallback, - discovery_info: DiscoveryInfoType | None = None, -) -> None: - """Import config from yaml.""" - - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_IMPORT}, data=config - ) - if ( - result.get("type") == FlowResultType.CREATE_ENTRY - or result.get("reason") == "already_configured" - ): - async_create_issue( - hass, - HOMEASSISTANT_DOMAIN, - f"deprecated_yaml_{DOMAIN}", - is_fixable=False, - issue_domain=DOMAIN, - breaks_in_ha_version="2025.1.0", - severity=IssueSeverity.WARNING, - translation_key="deprecated_yaml", - translation_placeholders={ - "domain": DOMAIN, - "integration_title": "pyLoad", - }, - ) - elif error := result.get("reason"): - async_create_issue( - hass, - DOMAIN, - f"deprecated_yaml_import_issue_{error}", - breaks_in_ha_version="2025.1.0", - is_fixable=False, - issue_domain=DOMAIN, - severity=IssueSeverity.WARNING, - translation_key=f"deprecated_yaml_import_issue_{error}", - translation_placeholders=ISSUE_PLACEHOLDER, - ) - async def async_setup_entry( hass: HomeAssistant, diff --git a/homeassistant/components/pyload/strings.json b/homeassistant/components/pyload/strings.json index 4ae4c4fee67..0fd9b4befcf 100644 --- a/homeassistant/components/pyload/strings.json +++ b/homeassistant/components/pyload/strings.json @@ -105,19 +105,5 @@ "service_call_auth_exception": { "message": "Unable to send command to pyLoad due to an authentication error, try again later" } - }, - "issues": { - "deprecated_yaml_import_issue_cannot_connect": { - "title": "The pyLoad YAML configuration import failed", - "description": "Configuring pyLoad using YAML is being removed but there was a connection error when trying to import the YAML configuration.\n\nPlease verify that you have a stable internet connection and restart Home Assistant to try again or remove the pyLoad YAML configuration from your configuration.yaml file and continue to [set up the integration]({url}) manually." - }, - "deprecated_yaml_import_issue_invalid_auth": { - "title": "The pyLoad YAML configuration import failed", - "description": "Configuring pyLoad using YAML is being removed but there was an authentication error when trying to import the YAML configuration.\n\nCorrect the YAML configuration and restart Home Assistant to try again or remove the pyLoad YAML configuration from your configuration.yaml file and continue to [set up the integration]({url}) manually." - }, - "deprecated_yaml_import_issue_unknown": { - "title": "The pyLoad YAML configuration import failed", - "description": "Configuring pyLoad using YAML is being removed but there was an unknown error when trying to import the YAML configuration.\n\nEnsure the YAML configuration is correct and restart Home Assistant to try again or remove the pyLoad YAML configuration from your configuration.yaml file and continue to [set up the integration]({url}) manually." - } } } diff --git a/tests/components/pyload/conftest.py b/tests/components/pyload/conftest.py index c0f181396ab..46144771cc1 100644 --- a/tests/components/pyload/conftest.py +++ b/tests/components/pyload/conftest.py @@ -9,16 +9,12 @@ import pytest from homeassistant.components.pyload.const import DEFAULT_NAME, DOMAIN from homeassistant.const import ( CONF_HOST, - CONF_MONITORED_VARIABLES, - CONF_NAME, CONF_PASSWORD, - CONF_PLATFORM, CONF_PORT, CONF_SSL, CONF_USERNAME, CONF_VERIFY_SSL, ) -from homeassistant.helpers.typing import ConfigType from tests.common import MockConfigEntry @@ -31,16 +27,6 @@ USER_INPUT = { CONF_VERIFY_SSL: False, } -YAML_INPUT = { - CONF_HOST: "pyload.local", - CONF_MONITORED_VARIABLES: ["speed"], - CONF_NAME: "test-name", - CONF_PASSWORD: "test-password", - CONF_PLATFORM: "pyload", - CONF_PORT: 8000, - CONF_SSL: True, - CONF_USERNAME: "test-username", -} REAUTH_INPUT = { CONF_PASSWORD: "new-password", CONF_USERNAME: "new-username", @@ -65,12 +51,6 @@ def mock_setup_entry() -> Generator[AsyncMock]: yield mock_setup_entry -@pytest.fixture -def pyload_config() -> ConfigType: - """Mock pyload configuration entry.""" - return {"sensor": YAML_INPUT} - - @pytest.fixture def mock_pyloadapi() -> Generator[MagicMock]: """Mock PyLoadAPI.""" diff --git a/tests/components/pyload/test_config_flow.py b/tests/components/pyload/test_config_flow.py index 5ada856d78e..492e4a4b652 100644 --- a/tests/components/pyload/test_config_flow.py +++ b/tests/components/pyload/test_config_flow.py @@ -6,11 +6,11 @@ from pyloadapi.exceptions import CannotConnect, InvalidAuth, ParserError import pytest from homeassistant.components.pyload.const import DEFAULT_NAME, DOMAIN -from homeassistant.config_entries import SOURCE_IMPORT, SOURCE_USER +from homeassistant.config_entries import SOURCE_USER from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType -from .conftest import NEW_INPUT, REAUTH_INPUT, USER_INPUT, YAML_INPUT +from .conftest import NEW_INPUT, REAUTH_INPUT, USER_INPUT from tests.common import MockConfigEntry @@ -103,69 +103,6 @@ async def test_flow_user_already_configured( assert result["reason"] == "already_configured" -async def test_flow_import( - hass: HomeAssistant, - mock_pyloadapi: AsyncMock, -) -> None: - """Test that we can import a YAML config.""" - - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_IMPORT}, - data=YAML_INPUT, - ) - - assert result["type"] is FlowResultType.CREATE_ENTRY - assert result["title"] == "test-name" - assert result["data"] == USER_INPUT - - -async def test_flow_import_already_configured( - hass: HomeAssistant, config_entry: MockConfigEntry, mock_pyloadapi: AsyncMock -) -> None: - """Test we abort import data set when entry is already configured.""" - - config_entry.add_to_hass(hass) - - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_IMPORT}, - data=YAML_INPUT, - ) - - assert result["type"] is FlowResultType.ABORT - assert result["reason"] == "already_configured" - - -@pytest.mark.parametrize( - ("exception", "reason"), - [ - (InvalidAuth, "invalid_auth"), - (CannotConnect, "cannot_connect"), - (ParserError, "cannot_connect"), - (ValueError, "unknown"), - ], -) -async def test_flow_import_errors( - hass: HomeAssistant, - config_entry: MockConfigEntry, - mock_pyloadapi: AsyncMock, - exception: Exception, - reason: str, -) -> None: - """Test we abort import data set when entry is already configured.""" - - mock_pyloadapi.login.side_effect = exception - result = await hass.config_entries.flow.async_init( - DOMAIN, - context={"source": SOURCE_IMPORT}, - data=YAML_INPUT, - ) - - assert result["type"] is FlowResultType.ABORT - assert result["reason"] == reason - - async def test_reauth( hass: HomeAssistant, config_entry: MockConfigEntry, diff --git a/tests/components/pyload/test_sensor.py b/tests/components/pyload/test_sensor.py index 8c194a111ea..33ad3435083 100644 --- a/tests/components/pyload/test_sensor.py +++ b/tests/components/pyload/test_sensor.py @@ -8,15 +8,11 @@ from pyloadapi.exceptions import CannotConnect, InvalidAuth, ParserError import pytest from syrupy.assertion import SnapshotAssertion -from homeassistant.components.pyload.const import DOMAIN from homeassistant.components.pyload.coordinator import SCAN_INTERVAL -from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN from homeassistant.config_entries import ConfigEntryState from homeassistant.const import Platform -from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant -from homeassistant.helpers import entity_registry as er, issue_registry as ir -from homeassistant.helpers.typing import ConfigType -from homeassistant.setup import async_setup_component +from homeassistant.core import HomeAssistant +from homeassistant.helpers import entity_registry as er from tests.common import MockConfigEntry, async_fire_time_changed, snapshot_platform @@ -101,64 +97,6 @@ async def test_sensor_invalid_auth( ) -async def test_platform_setup_triggers_import_flow( - hass: HomeAssistant, - pyload_config: ConfigType, - mock_setup_entry: AsyncMock, - mock_pyloadapi: AsyncMock, -) -> None: - """Test if an issue is created when attempting setup from yaml config.""" - - assert await async_setup_component(hass, SENSOR_DOMAIN, pyload_config) - await hass.async_block_till_done() - - assert len(mock_setup_entry.mock_calls) == 1 - - -@pytest.mark.parametrize( - ("exception", "reason"), - [ - (InvalidAuth, "invalid_auth"), - (CannotConnect, "cannot_connect"), - (ParserError, "cannot_connect"), - (ValueError, "unknown"), - ], -) -async def test_deprecated_yaml_import_issue( - hass: HomeAssistant, - issue_registry: ir.IssueRegistry, - pyload_config: ConfigType, - mock_pyloadapi: AsyncMock, - exception: Exception, - reason: str, -) -> None: - """Test an issue is created when attempting setup from yaml config and an error happens.""" - - mock_pyloadapi.login.side_effect = exception - await async_setup_component(hass, SENSOR_DOMAIN, pyload_config) - await hass.async_block_till_done() - - assert issue_registry.async_get_issue( - domain=DOMAIN, issue_id=f"deprecated_yaml_import_issue_{reason}" - ) - - -async def test_deprecated_yaml( - hass: HomeAssistant, - issue_registry: ir.IssueRegistry, - pyload_config: ConfigType, - mock_pyloadapi: AsyncMock, -) -> None: - """Test an issue is created when we import from yaml config.""" - - await async_setup_component(hass, SENSOR_DOMAIN, pyload_config) - await hass.async_block_till_done() - - assert issue_registry.async_get_issue( - domain=HOMEASSISTANT_DOMAIN, issue_id=f"deprecated_yaml_{DOMAIN}" - ) - - async def test_pyload_pre_0_5_0( hass: HomeAssistant, config_entry: MockConfigEntry,