Use dataclass instead of attr slots for mqtt PublishMessage and ReceiveMessage (#101062)
Use dataclass instead of attr slots
This commit is contained in:
parent
77c519220d
commit
0ded0ef4ee
2 changed files with 17 additions and 17 deletions
|
@ -11,8 +11,6 @@ from enum import StrEnum
|
|||
import logging
|
||||
from typing import TYPE_CHECKING, Any, TypedDict
|
||||
|
||||
import attr
|
||||
|
||||
from homeassistant.const import ATTR_ENTITY_ID, ATTR_NAME
|
||||
from homeassistant.core import CALLBACK_TYPE, HomeAssistant, callback
|
||||
from homeassistant.helpers import template
|
||||
|
@ -44,26 +42,26 @@ ATTR_THIS = "this"
|
|||
PublishPayloadType = str | bytes | int | float | None
|
||||
|
||||
|
||||
@attr.s(slots=True, frozen=True)
|
||||
@dataclass
|
||||
class PublishMessage:
|
||||
"""MQTT Message."""
|
||||
"""MQTT Message for publishing."""
|
||||
|
||||
topic: str = attr.ib()
|
||||
payload: PublishPayloadType = attr.ib()
|
||||
qos: int = attr.ib()
|
||||
retain: bool = attr.ib()
|
||||
topic: str
|
||||
payload: PublishPayloadType
|
||||
qos: int
|
||||
retain: bool
|
||||
|
||||
|
||||
@attr.s(slots=True, frozen=True)
|
||||
@dataclass
|
||||
class ReceiveMessage:
|
||||
"""MQTT Message."""
|
||||
"""MQTT Message received."""
|
||||
|
||||
topic: str = attr.ib()
|
||||
payload: ReceivePayloadType = attr.ib()
|
||||
qos: int = attr.ib()
|
||||
retain: bool = attr.ib()
|
||||
subscribed_topic: str = attr.ib(default=None)
|
||||
timestamp: dt.datetime = attr.ib(default=None)
|
||||
topic: str
|
||||
payload: ReceivePayloadType
|
||||
qos: int
|
||||
retain: bool
|
||||
subscribed_topic: str
|
||||
timestamp: dt.datetime
|
||||
|
||||
|
||||
AsyncMessageCallbackType = Callable[[ReceiveMessage], Coroutine[Any, Any, None]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue