Use dataclass for mqtt Subscription (#101064)
This commit is contained in:
parent
f733c43900
commit
77c519220d
1 changed files with 7 additions and 7 deletions
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from collections.abc import Callable, Coroutine, Iterable
|
from collections.abc import Callable, Coroutine, Iterable
|
||||||
|
from dataclasses import dataclass
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from itertools import chain, groupby
|
from itertools import chain, groupby
|
||||||
import logging
|
import logging
|
||||||
|
@ -12,7 +13,6 @@ import time
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import attr
|
|
||||||
import certifi
|
import certifi
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
|
@ -212,15 +212,15 @@ def subscribe(
|
||||||
return remove
|
return remove
|
||||||
|
|
||||||
|
|
||||||
@attr.s(slots=True, frozen=True)
|
@dataclass(frozen=True)
|
||||||
class Subscription:
|
class Subscription:
|
||||||
"""Class to hold data about an active subscription."""
|
"""Class to hold data about an active subscription."""
|
||||||
|
|
||||||
topic: str = attr.ib()
|
topic: str
|
||||||
matcher: Any = attr.ib()
|
matcher: Any
|
||||||
job: HassJob[[ReceiveMessage], Coroutine[Any, Any, None] | None] = attr.ib()
|
job: HassJob[[ReceiveMessage], Coroutine[Any, Any, None] | None]
|
||||||
qos: int = attr.ib(default=0)
|
qos: int = 0
|
||||||
encoding: str | None = attr.ib(default="utf-8")
|
encoding: str | None = "utf-8"
|
||||||
|
|
||||||
|
|
||||||
class MqttClientSetup:
|
class MqttClientSetup:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue