From 5a40322cda8a508107ade5746201458ea01e3b91 Mon Sep 17 00:00:00 2001
From: epenet <6771947+epenet@users.noreply.github.com>
Date: Mon, 22 Nov 2021 11:48:06 +0100
Subject: [PATCH] Use ZeroconfServiceInfo in volumio (#60116)

Co-authored-by: epenet <epenet@users.noreply.github.com>
---
 .../components/volumio/config_flow.py         | 13 ++++++++-----
 tests/components/volumio/test_config_flow.py  | 19 ++++++++++---------
 2 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/homeassistant/components/volumio/config_flow.py b/homeassistant/components/volumio/config_flow.py
index a499b7827b5..e77aad05df2 100644
--- a/homeassistant/components/volumio/config_flow.py
+++ b/homeassistant/components/volumio/config_flow.py
@@ -10,6 +10,7 @@ from homeassistant import config_entries, exceptions
 from homeassistant.components import zeroconf
 from homeassistant.const import CONF_HOST, CONF_ID, CONF_NAME, CONF_PORT
 from homeassistant.core import callback
+from homeassistant.data_entry_flow import FlowResult
 from homeassistant.helpers.aiohttp_client import async_get_clientsession
 
 from .const import DOMAIN
@@ -93,12 +94,14 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
             step_id="user", data_schema=DATA_SCHEMA, errors=errors
         )
 
-    async def async_step_zeroconf(self, discovery_info: zeroconf.ZeroconfServiceInfo):
+    async def async_step_zeroconf(
+        self, discovery_info: zeroconf.ZeroconfServiceInfo
+    ) -> FlowResult:
         """Handle zeroconf discovery."""
-        self._host = discovery_info["host"]
-        self._port = discovery_info["port"]
-        self._name = discovery_info["properties"]["volumioName"]
-        self._uuid = discovery_info["properties"]["UUID"]
+        self._host = discovery_info[zeroconf.ATTR_HOST]
+        self._port = discovery_info[zeroconf.ATTR_PORT]
+        self._name = discovery_info[zeroconf.ATTR_PROPERTIES]["volumioName"]
+        self._uuid = discovery_info[zeroconf.ATTR_PROPERTIES]["UUID"]
 
         await self._set_uid_and_abort()
 
diff --git a/tests/components/volumio/test_config_flow.py b/tests/components/volumio/test_config_flow.py
index b4b3c8f24ed..f217ed9919b 100644
--- a/tests/components/volumio/test_config_flow.py
+++ b/tests/components/volumio/test_config_flow.py
@@ -2,6 +2,7 @@
 from unittest.mock import patch
 
 from homeassistant import config_entries
+from homeassistant.components import zeroconf
 from homeassistant.components.volumio.config_flow import CannotConnectError
 from homeassistant.components.volumio.const import DOMAIN
 
@@ -16,17 +17,17 @@ TEST_CONNECTION = {
 }
 
 
-TEST_DISCOVERY = {
-    "host": "1.1.1.1",
-    "port": 3000,
-    "properties": {"volumioName": "discovered", "UUID": "2222-2222-2222-2222"},
-}
+TEST_DISCOVERY = zeroconf.ZeroconfServiceInfo(
+    host="1.1.1.1",
+    port=3000,
+    properties={"volumioName": "discovered", "UUID": "2222-2222-2222-2222"},
+)
 
 TEST_DISCOVERY_RESULT = {
-    "host": TEST_DISCOVERY["host"],
-    "port": TEST_DISCOVERY["port"],
-    "id": TEST_DISCOVERY["properties"]["UUID"],
-    "name": TEST_DISCOVERY["properties"]["volumioName"],
+    "host": TEST_DISCOVERY[zeroconf.ATTR_HOST],
+    "port": TEST_DISCOVERY[zeroconf.ATTR_PORT],
+    "id": TEST_DISCOVERY[zeroconf.ATTR_PROPERTIES]["UUID"],
+    "name": TEST_DISCOVERY[zeroconf.ATTR_PROPERTIES]["volumioName"],
 }
 
 
-- 
GitLab