From 2f35ad2a8a0b98ad29307dc98dd29b8fd2885bea Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Sat, 16 May 2026 18:59:46 -0400 Subject: [PATCH] Disable USB discovery for teleinfo (#170933) --- .../components/teleinfo/config_flow.py | 24 +++++++++++-------- .../components/teleinfo/manifest.json | 12 +--------- homeassistant/generated/usb.py | 10 -------- tests/components/teleinfo/test_config_flow.py | 20 ++++++++++++++++ 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/homeassistant/components/teleinfo/config_flow.py b/homeassistant/components/teleinfo/config_flow.py index dd19ece346d3..64b2e6581901 100644 --- a/homeassistant/components/teleinfo/config_flow.py +++ b/homeassistant/components/teleinfo/config_flow.py @@ -92,16 +92,6 @@ class TeleinfoConfigFlow(ConfigFlow, domain=DOMAIN): usb.get_serial_by_id, discovery_info.device ) - # Validate by reading a real Teleinfo frame — silent abort on failure - errors, decoded_data = await self._validate_serial_port(dev_path) - if errors or decoded_data is None: - return self.async_abort(reason="not_teleinfo_device") - - # Use ADCO (meter serial number) as unique_id — same as manual entry - adco = decoded_data["ADCO"] - await self.async_set_unique_id(adco) - self._abort_if_unique_id_configured(updates={CONF_SERIAL_PORT: dev_path}) - self._discovered_device = dev_path self.context["title_placeholders"] = { "name": human_readable_device_name( @@ -122,6 +112,20 @@ class TeleinfoConfigFlow(ConfigFlow, domain=DOMAIN): if TYPE_CHECKING: assert self._discovered_device is not None if user_input is not None: + # Validate by reading a real Teleinfo frame — silent abort on failure + errors, decoded_data = await self._validate_serial_port( + self._discovered_device + ) + if errors or decoded_data is None: + return self.async_abort(reason="not_teleinfo_device") + + # Use ADCO (meter serial number) as unique_id — same as manual entry + adco = decoded_data["ADCO"] + await self.async_set_unique_id(adco) + self._abort_if_unique_id_configured( + updates={CONF_SERIAL_PORT: self._discovered_device} + ) + return self.async_create_entry( title=f"Teleinfo ({self._discovered_device})", data={CONF_SERIAL_PORT: self._discovered_device}, diff --git a/homeassistant/components/teleinfo/manifest.json b/homeassistant/components/teleinfo/manifest.json index 32b72035a528..5bb7f8615311 100644 --- a/homeassistant/components/teleinfo/manifest.json +++ b/homeassistant/components/teleinfo/manifest.json @@ -8,15 +8,5 @@ "integration_type": "device", "iot_class": "local_polling", "quality_scale": "silver", - "requirements": ["pyteleinfo==0.4.0"], - "usb": [ - { - "pid": "6015", - "vid": "0403" - }, - { - "pid": "EA60", - "vid": "10C4" - } - ] + "requirements": ["pyteleinfo==0.4.0"] } diff --git a/homeassistant/generated/usb.py b/homeassistant/generated/usb.py index 70da80846d8f..d1974f23d6e5 100644 --- a/homeassistant/generated/usb.py +++ b/homeassistant/generated/usb.py @@ -58,16 +58,6 @@ USB = [ "pid": "0003", "vid": "04B4", }, - { - "domain": "teleinfo", - "pid": "6015", - "vid": "0403", - }, - { - "domain": "teleinfo", - "pid": "EA60", - "vid": "10C4", - }, { "domain": "velbus", "pid": "0B1B", diff --git a/tests/components/teleinfo/test_config_flow.py b/tests/components/teleinfo/test_config_flow.py index 393400276af9..2bddc5c7ac5b 100644 --- a/tests/components/teleinfo/test_config_flow.py +++ b/tests/components/teleinfo/test_config_flow.py @@ -170,6 +170,11 @@ async def test_usb_discovery_not_teleinfo( data=USB_DISCOVERY_INFO, ) + assert result["type"] is FlowResultType.FORM + assert result["step_id"] == "usb_confirm" + + result = await hass.config_entries.flow.async_configure(result["flow_id"], {}) + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "not_teleinfo_device" @@ -202,6 +207,11 @@ async def test_usb_discovery_already_configured_updates_path( ), ) + assert result["type"] is FlowResultType.FORM + assert result["step_id"] == "usb_confirm" + + result = await hass.config_entries.flow.async_configure(result["flow_id"], {}) + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" # Path should be updated to the new device path @@ -225,6 +235,11 @@ async def test_usb_discovery_manual_entry_duplicate( data=USB_DISCOVERY_INFO, ) + assert result["type"] is FlowResultType.FORM + assert result["step_id"] == "usb_confirm" + + result = await hass.config_entries.flow.async_configure(result["flow_id"], {}) + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" @@ -244,5 +259,10 @@ async def test_usb_discovery_decode_error_aborts( data=USB_DISCOVERY_INFO, ) + assert result["type"] is FlowResultType.FORM + assert result["step_id"] == "usb_confirm" + + result = await hass.config_entries.flow.async_configure(result["flow_id"], {}) + assert result["type"] is FlowResultType.ABORT assert result["reason"] == "not_teleinfo_device"