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
d228df6d
Unverified
Commit
d228df6d
authored
1 year ago
by
Erik J. Olson
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix Notify Group payload data mis-merge (#90253)
Co-authored-by:
Erik Montnemery
<
erik@montnemery.com
>
parent
8e7013b0
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/group/notify.py
+11
-13
11 additions, 13 deletions
homeassistant/components/group/notify.py
tests/components/group/test_notify.py
+24
-3
24 additions, 3 deletions
tests/components/group/test_notify.py
with
35 additions
and
16 deletions
homeassistant/components/group/notify.py
+
11
−
13
View file @
d228df6d
...
...
@@ -32,18 +32,16 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
)
def
update
(
input_dict
:
dict
[
str
,
Any
],
update_source
:
dict
[
str
,
Any
])
->
dict
[
str
,
Any
]:
"""
Deep update a dictionary.
Async friendly.
"""
for
key
,
val
in
update_source
.
items
():
def
add_defaults
(
input_data
:
dict
[
str
,
Any
],
default_data
:
dict
[
str
,
Any
]
)
->
dict
[
str
,
Any
]:
"""
Deep update a dictionary with default values.
"""
for
key
,
val
in
default_data
.
items
():
if
isinstance
(
val
,
Mapping
):
recurse
=
update
(
input_dict
.
get
(
key
,
{}),
val
)
# type: ignore[arg-type]
input_dict
[
key
]
=
recurse
else
:
input_dict
[
key
]
=
update_source
[
key
]
return
input_dict
input_data
[
key
]
=
add_defaults
(
input_data
.
get
(
key
,
{}),
val
)
# type: ignore[arg-type]
elif
key
not
in
input_data
:
input_data
[
key
]
=
val
return
input_data
async
def
async_get_service
(
...
...
@@ -71,8 +69,8 @@ class GroupNotifyPlatform(BaseNotificationService):
tasks
:
list
[
asyncio
.
Task
[
bool
|
None
]]
=
[]
for
entity
in
self
.
entities
:
sending_payload
=
deepcopy
(
payload
.
copy
())
if
(
data
:
=
entity
.
get
(
ATTR_DATA
))
is
not
None
:
update
(
sending_payload
,
data
)
if
(
default_
data
:
=
entity
.
get
(
ATTR_DATA
))
is
not
None
:
add_defaults
(
sending_payload
,
default_
data
)
tasks
.
append
(
asyncio
.
create_task
(
self
.
hass
.
services
.
async_call
(
...
...
This diff is collapsed.
Click to expand it.
tests/components/group/test_notify.py
+
24
−
3
View file @
d228df6d
...
...
@@ -54,14 +54,14 @@ async def test_send_message_with_data(hass: HomeAssistant) -> None:
"
service
"
:
"
demo2
"
,
"
data
"
:
{
"
target
"
:
"
unnamed device
"
,
"
data
"
:
{
"
test
"
:
"
message
"
},
"
data
"
:
{
"
test
"
:
"
message
"
,
"
default
"
:
"
default
"
},
},
},
]
},
)
"""
Test sending a message
with
to a notify group.
"""
"""
Test sending a message to a notify group.
"""
await
service
.
async_send_message
(
"
Hello
"
,
title
=
"
Test notification
"
,
data
=
{
"
hello
"
:
"
world
"
}
)
...
...
@@ -77,7 +77,28 @@ async def test_send_message_with_data(hass: HomeAssistant) -> None:
assert
service2
.
send_message
.
mock_calls
[
0
][
2
]
==
{
"
target
"
:
[
"
unnamed device
"
],
"
title
"
:
"
Test notification
"
,
"
data
"
:
{
"
hello
"
:
"
world
"
,
"
test
"
:
"
message
"
},
"
data
"
:
{
"
hello
"
:
"
world
"
,
"
test
"
:
"
message
"
,
"
default
"
:
"
default
"
},
}
"""
Test sending a message which overrides service defaults to a notify group.
"""
await
service
.
async_send_message
(
"
Hello
"
,
title
=
"
Test notification
"
,
data
=
{
"
hello
"
:
"
world
"
,
"
default
"
:
"
override
"
},
)
await
hass
.
async_block_till_done
()
assert
service1
.
send_message
.
mock_calls
[
1
][
1
][
0
]
==
"
Hello
"
assert
service1
.
send_message
.
mock_calls
[
1
][
2
]
==
{
"
title
"
:
"
Test notification
"
,
"
data
"
:
{
"
hello
"
:
"
world
"
,
"
default
"
:
"
override
"
},
}
assert
service2
.
send_message
.
mock_calls
[
1
][
1
][
0
]
==
"
Hello
"
assert
service2
.
send_message
.
mock_calls
[
1
][
2
]
==
{
"
target
"
:
[
"
unnamed device
"
],
"
title
"
:
"
Test notification
"
,
"
data
"
:
{
"
hello
"
:
"
world
"
,
"
test
"
:
"
message
"
,
"
default
"
:
"
override
"
},
}
...
...
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