2019-10-18 00:04:27 +00:00
|
|
|
"""Modesl used by multiple MQTT modules."""
|
2019-12-08 17:15:26 +00:00
|
|
|
from typing import Callable, Union
|
2019-10-18 00:04:27 +00:00
|
|
|
|
|
|
|
import attr
|
|
|
|
|
|
|
|
PublishPayloadType = Union[str, bytes, int, float, None]
|
|
|
|
|
|
|
|
|
|
|
|
@attr.s(slots=True, frozen=True)
|
|
|
|
class Message:
|
|
|
|
"""MQTT Message."""
|
|
|
|
|
|
|
|
topic = attr.ib(type=str)
|
|
|
|
payload = attr.ib(type=PublishPayloadType)
|
|
|
|
qos = attr.ib(type=int)
|
|
|
|
retain = attr.ib(type=bool)
|
2020-04-06 17:25:09 +00:00
|
|
|
subscribed_topic = attr.ib(type=str, default=None)
|
2019-10-18 00:04:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
MessageCallbackType = Callable[[Message], None]
|