Remove port from Elgato configuration flow (#132961)

This commit is contained in:
Franck Nijhof 2024-12-11 20:48:55 +01:00 committed by GitHub
parent 833557fad5
commit 73e68971e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 10 additions and 27 deletions

View File

@ -9,7 +9,7 @@ import voluptuous as vol
from homeassistant.components import onboarding, zeroconf
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_PORT
from homeassistant.const import CONF_HOST, CONF_MAC
from homeassistant.core import callback
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -34,7 +34,6 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
return self._async_show_setup_form()
self.host = user_input[CONF_HOST]
self.port = user_input[CONF_PORT]
try:
await self._get_elgato_serial_number(raise_on_progress=False)
@ -49,7 +48,6 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
"""Handle zeroconf discovery."""
self.host = discovery_info.host
self.mac = discovery_info.properties.get("id")
self.port = discovery_info.port or 9123
try:
await self._get_elgato_serial_number()
@ -81,7 +79,6 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
data_schema=vol.Schema(
{
vol.Required(CONF_HOST): str,
vol.Optional(CONF_PORT, default=9123): int,
}
),
errors=errors or {},
@ -93,7 +90,6 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
title=self.serial_number,
data={
CONF_HOST: self.host,
CONF_PORT: self.port,
CONF_MAC: self.mac,
},
)
@ -103,7 +99,6 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
session = async_get_clientsession(self.hass)
elgato = Elgato(
host=self.host,
port=self.port,
session=session,
)
info = await elgato.info()
@ -113,7 +108,7 @@ class ElgatoFlowHandler(ConfigFlow, domain=DOMAIN):
info.serial_number, raise_on_progress=raise_on_progress
)
self._abort_if_unique_id_configured(
updates={CONF_HOST: self.host, CONF_PORT: self.port, CONF_MAC: self.mac}
updates={CONF_HOST: self.host, CONF_MAC: self.mac}
)
self.serial_number = info.serial_number

View File

@ -5,7 +5,7 @@ from dataclasses import dataclass
from elgato import BatteryInfo, Elgato, ElgatoConnectionError, Info, Settings, State
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
@ -34,7 +34,6 @@ class ElgatoDataUpdateCoordinator(DataUpdateCoordinator[ElgatoData]):
self.config_entry = entry
self.client = Elgato(
entry.data[CONF_HOST],
port=entry.data[CONF_PORT],
session=async_get_clientsession(hass),
)
super().__init__(

View File

@ -5,10 +5,7 @@ rules:
brands: done
common-modules: done
config-flow-test-coverage: done
config-flow:
status: todo
comment: |
The data_description for port is missing.
config-flow: done
dependency-transparency: done
docs-actions: done
docs-high-level-description: done

View File

@ -5,8 +5,7 @@
"user": {
"description": "Set up your Elgato Light to integrate with Home Assistant.",
"data": {
"host": "[%key:common::config_flow::data::host%]",
"port": "[%key:common::config_flow::data::port%]"
"host": "[%key:common::config_flow::data::host%]"
},
"data_description": {
"host": "The hostname or IP address of your Elgato device."

View File

@ -7,7 +7,7 @@ from elgato import BatteryInfo, ElgatoNoBatteryError, Info, Settings, State
import pytest
from homeassistant.components.elgato.const import DOMAIN
from homeassistant.const import CONF_HOST, CONF_MAC, CONF_PORT
from homeassistant.const import CONF_HOST, CONF_MAC
from homeassistant.core import HomeAssistant
from tests.common import MockConfigEntry, get_fixture_path, load_fixture
@ -35,7 +35,6 @@ def mock_config_entry() -> MockConfigEntry:
data={
CONF_HOST: "127.0.0.1",
CONF_MAC: "AA:BB:CC:DD:EE:FF",
CONF_PORT: 9123,
},
unique_id="CN11A1A00001",
)

View File

@ -8,7 +8,6 @@
'data': dict({
'host': '127.0.0.1',
'mac': None,
'port': 9123,
}),
'description': None,
'description_placeholders': None,
@ -21,7 +20,6 @@
'data': dict({
'host': '127.0.0.1',
'mac': None,
'port': 9123,
}),
'disabled_by': None,
'discovery_keys': dict({
@ -53,7 +51,6 @@
'data': dict({
'host': '127.0.0.1',
'mac': 'AA:BB:CC:DD:EE:FF',
'port': 9123,
}),
'description': None,
'description_placeholders': None,
@ -66,7 +63,6 @@
'data': dict({
'host': '127.0.0.1',
'mac': 'AA:BB:CC:DD:EE:FF',
'port': 9123,
}),
'disabled_by': None,
'discovery_keys': dict({
@ -97,7 +93,6 @@
'data': dict({
'host': '127.0.0.1',
'mac': 'AA:BB:CC:DD:EE:FF',
'port': 9123,
}),
'description': None,
'description_placeholders': None,
@ -110,7 +105,6 @@
'data': dict({
'host': '127.0.0.1',
'mac': 'AA:BB:CC:DD:EE:FF',
'port': 9123,
}),
'disabled_by': None,
'discovery_keys': dict({

View File

@ -10,7 +10,7 @@ from syrupy.assertion import SnapshotAssertion
from homeassistant.components import zeroconf
from homeassistant.components.elgato.const import DOMAIN
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_SOURCE
from homeassistant.const import CONF_HOST, CONF_SOURCE
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
@ -33,7 +33,7 @@ async def test_full_user_flow_implementation(
assert result.get("step_id") == "user"
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_HOST: "127.0.0.1", CONF_PORT: 9123}
result["flow_id"], user_input={CONF_HOST: "127.0.0.1"}
)
assert result2.get("type") is FlowResultType.CREATE_ENTRY
@ -94,7 +94,7 @@ async def test_connection_error(
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_USER},
data={CONF_HOST: "127.0.0.1", CONF_PORT: 9123},
data={CONF_HOST: "127.0.0.1"},
)
assert result.get("type") is FlowResultType.FORM
@ -135,7 +135,7 @@ async def test_user_device_exists_abort(
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": SOURCE_USER},
data={CONF_HOST: "127.0.0.1", CONF_PORT: 9123},
data={CONF_HOST: "127.0.0.1"},
)
assert result.get("type") is FlowResultType.ABORT