Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
5a40322c
Unverified
Commit
5a40322c
authored
3 years ago
by
epenet
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Use ZeroconfServiceInfo in volumio (#60116)
Co-authored-by:
epenet
<
epenet@users.noreply.github.com
>
parent
bac3c1fd
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
homeassistant/components/volumio/config_flow.py
+8
-5
8 additions, 5 deletions
homeassistant/components/volumio/config_flow.py
tests/components/volumio/test_config_flow.py
+10
-9
10 additions, 9 deletions
tests/components/volumio/test_config_flow.py
with
18 additions
and
14 deletions
homeassistant/components/volumio/config_flow.py
+
8
−
5
View file @
5a40322c
...
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
tests/components/volumio/test_config_flow.py
+
10
−
9
View file @
5a40322c
...
...
@@ -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
"
],
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment