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
e1b57d83
Unverified
Commit
e1b57d83
authored
3 years ago
by
epenet
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Adjust config entry matching in SamsungTV (#67842)
Co-authored-by:
epenet
<
epenet@users.noreply.github.com
>
parent
6f38eda1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
homeassistant/components/samsungtv/config_flow.py
+19
-15
19 additions, 15 deletions
homeassistant/components/samsungtv/config_flow.py
with
19 additions
and
15 deletions
homeassistant/components/samsungtv/config_flow.py
+
19
−
15
View file @
e1b57d83
...
...
@@ -113,9 +113,9 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""
Set the unique id from the udn.
"""
assert
self
.
_host
is
not
None
await
self
.
async_set_unique_id
(
self
.
_udn
,
raise_on_progress
=
raise_on_progress
)
if
(
entry
:
=
self
.
_async_update_existing_host_entry
())
and
_entry_is_complete
(
entry
):
if
(
entry
:
=
self
.
_async_update_existing_matching_entry
()
)
and
_entry_is_complete
(
entry
)
:
raise
data_entry_flow
.
AbortFlow
(
"
already_configured
"
)
def
_async_update_and_abort_for_matching_unique_id
(
self
)
->
None
:
...
...
@@ -215,21 +215,25 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
return
self
.
async_show_form
(
step_id
=
"
user
"
,
data_schema
=
DATA_SCHEMA
)
@callback
def
_async_update_existing_host_entry
(
self
)
->
config_entries
.
ConfigEntry
|
None
:
"""
Check existing entries and update them.
Returns the existing entry if it was updated.
"""
def
_async_get_existing_matching_entry
(
self
)
->
config_entries
.
ConfigEntry
|
None
:
"""
Get first existing matching entry.
"""
for
entry
in
self
.
_async_current_entries
(
include_ignore
=
False
):
mac
=
entry
.
data
.
get
(
CONF_MAC
)
mac_match
=
mac
and
self
.
_mac
and
mac
==
self
.
_mac
upnp_udn_match
=
self
.
_upnp_udn
and
self
.
_upnp_udn
==
entry
.
unique_id
if
(
entry
.
data
[
CONF_HOST
]
!=
self
.
_host
and
not
mac_match
and
not
upnp_udn_match
):
continue
if
entry
.
data
[
CONF_HOST
]
==
self
.
_host
or
mac_match
or
upnp_udn_match
:
return
entry
return
None
@callback
def
_async_update_existing_matching_entry
(
self
,
)
->
config_entries
.
ConfigEntry
|
None
:
"""
Check existing entries and update them.
Returns the existing entry if it was updated.
"""
if
entry
:
=
self
.
_async_get_existing_matching_entry
():
entry_kw_args
:
dict
=
{}
if
(
self
.
_udn
and
self
.
_upnp_udn
and
self
.
_upnp_udn
!=
self
.
_udn
)
or
(
self
.
unique_id
and
entry
.
unique_id
is
None
...
...
@@ -248,7 +252,7 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async
def
_async_start_discovery_with_mac_address
(
self
)
->
None
:
"""
Start discovery.
"""
assert
self
.
_host
is
not
None
if
(
entry
:
=
self
.
_async_update_existing_
host
_entry
())
and
entry
.
unique_id
:
if
(
entry
:
=
self
.
_async_update_existing_
matching
_entry
())
and
entry
.
unique_id
:
# If we have the unique id and the mac we abort
# as we do not need anything else
raise
data_entry_flow
.
AbortFlow
(
"
already_configured
"
)
...
...
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