Use dataclass for mqtt TimestampedPublishMessage (#101124)
This commit is contained in:
parent
a19c6fe9ff
commit
257e608c13
1 changed files with 7 additions and 8 deletions
|
@ -3,12 +3,11 @@ from __future__ import annotations
|
||||||
|
|
||||||
from collections import deque
|
from collections import deque
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
|
from dataclasses import dataclass
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from typing import TYPE_CHECKING, Any
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
import attr
|
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
from homeassistant.helpers.typing import DiscoveryInfoType
|
from homeassistant.helpers.typing import DiscoveryInfoType
|
||||||
|
@ -49,15 +48,15 @@ def log_messages(
|
||||||
return _decorator
|
return _decorator
|
||||||
|
|
||||||
|
|
||||||
@attr.s(slots=True, frozen=True)
|
@dataclass
|
||||||
class TimestampedPublishMessage:
|
class TimestampedPublishMessage:
|
||||||
"""MQTT Message."""
|
"""MQTT Message."""
|
||||||
|
|
||||||
topic: str = attr.ib()
|
topic: str
|
||||||
payload: PublishPayloadType = attr.ib()
|
payload: PublishPayloadType
|
||||||
qos: int = attr.ib()
|
qos: int
|
||||||
retain: bool = attr.ib()
|
retain: bool
|
||||||
timestamp: dt.datetime = attr.ib(default=None)
|
timestamp: dt.datetime
|
||||||
|
|
||||||
|
|
||||||
def log_message(
|
def log_message(
|
||||||
|
|
Loading…
Add table
Reference in a new issue