mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 05:47:10 +00:00
Fix group integration with py3.11 (#88089)
In py3.11 `Passing coroutines is forbidden, use tasks explicitly`
This commit is contained in:
parent
d8ee60ee44
commit
f11ba1b7cb
@ -2,7 +2,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections.abc import Coroutine, Mapping
|
from collections.abc import Mapping
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
@ -68,16 +68,18 @@ class GroupNotifyPlatform(BaseNotificationService):
|
|||||||
payload: dict[str, Any] = {ATTR_MESSAGE: message}
|
payload: dict[str, Any] = {ATTR_MESSAGE: message}
|
||||||
payload.update({key: val for key, val in kwargs.items() if val})
|
payload.update({key: val for key, val in kwargs.items() if val})
|
||||||
|
|
||||||
tasks: list[Coroutine[Any, Any, bool | None]] = []
|
tasks: list[asyncio.Task[bool | None]] = []
|
||||||
for entity in self.entities:
|
for entity in self.entities:
|
||||||
sending_payload = deepcopy(payload.copy())
|
sending_payload = deepcopy(payload.copy())
|
||||||
if (data := entity.get(ATTR_DATA)) is not None:
|
if (data := entity.get(ATTR_DATA)) is not None:
|
||||||
update(sending_payload, data)
|
update(sending_payload, data)
|
||||||
tasks.append(
|
tasks.append(
|
||||||
|
asyncio.create_task(
|
||||||
self.hass.services.async_call(
|
self.hass.services.async_call(
|
||||||
DOMAIN, entity[ATTR_SERVICE], sending_payload
|
DOMAIN, entity[ATTR_SERVICE], sending_payload
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if tasks:
|
if tasks:
|
||||||
await asyncio.wait(tasks)
|
await asyncio.wait(tasks)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user