From 4ffb0b8380100d008f044fa5340b67f2d4127e0a Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 24 Nov 2021 09:40:52 +0100 Subject: [PATCH] Use UsbServiceInfo in modem_callerid (#60268) Co-authored-by: epenet --- .../components/modem_callerid/config_flow.py | 4 ++-- .../modem_callerid/test_config_flow.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/modem_callerid/config_flow.py b/homeassistant/components/modem_callerid/config_flow.py index 70fd3969e02d..2bc857a16f43 100644 --- a/homeassistant/components/modem_callerid/config_flow.py +++ b/homeassistant/components/modem_callerid/config_flow.py @@ -32,10 +32,10 @@ class PhoneModemFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): async def async_step_usb(self, discovery_info: usb.UsbServiceInfo) -> FlowResult: """Handle USB Discovery.""" - device = discovery_info["device"] + device = discovery_info.device dev_path = await self.hass.async_add_executor_job(usb.get_serial_by_id, device) - unique_id = f"{discovery_info['vid']}:{discovery_info['pid']}_{discovery_info['serial_number']}_{discovery_info['manufacturer']}_{discovery_info['description']}" + unique_id = f"{discovery_info.vid}:{discovery_info.pid}_{discovery_info.serial_number}_{discovery_info.manufacturer}_{discovery_info.description}" if ( await self.validate_device_errors(dev_path=dev_path, unique_id=unique_id) is None diff --git a/tests/components/modem_callerid/test_config_flow.py b/tests/components/modem_callerid/test_config_flow.py index 4d76ae8a944f..0956a8fe1b79 100644 --- a/tests/components/modem_callerid/test_config_flow.py +++ b/tests/components/modem_callerid/test_config_flow.py @@ -17,14 +17,14 @@ from homeassistant.data_entry_flow import ( from . import _patch_config_flow_modem -DISCOVERY_INFO = { - "device": phone_modem.DEFAULT_PORT, - "pid": "1340", - "vid": "0572", - "serial_number": "1234", - "description": "modem", - "manufacturer": "Connexant", -} +DISCOVERY_INFO = usb.UsbServiceInfo( + device=phone_modem.DEFAULT_PORT, + pid="1340", + vid="0572", + serial_number="1234", + description="modem", + manufacturer="Connexant", +) def _patch_setup():