* Proof of concept * remove notify platform * remove loose test * Add rework from #67912 (#1) * Move notify serviceupdater to Mixins * Move tag discovery handler to Mixins * fix tests * Add typing for async_load_platform_helper * Add add entry unload support for notify platform * Simplify discovery updates * Remove not needed extra logic * Cleanup inrelevant or duplicate code * reuse update_device and move to mixins * Remove notify platform * revert changes to notify platform * Rename update class * unify tag entry setup * Use shared code for device_trigger `update_device` * PoC shared dispatcher for device_trigger * Fix bugs * Improve typing - remove async_update * Unload config_entry and tests * Release dispatcher after setup and deduplicate * closures to methods, revert `in` to `=`, updates * Re-add update support for tag platform * Re-add update support for device-trigger platform * Cleanup rediscovery code revert related changes * Undo discovery code shift * Update homeassistant/components/mqtt/mixins.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/device_trigger.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/mqtt/mixins.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * revert doc string changes * move conditions * typing and check config_entry_id * Update homeassistant/components/mqtt/mixins.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * cleanup not used attribute * Remove entry_unload code and tests * update comment * add second comment Co-authored-by: Erik Montnemery <erik@montnemery.com>
37 lines
928 B
Python
37 lines
928 B
Python
"""Models used by multiple MQTT modules."""
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Awaitable, Callable
|
|
import datetime as dt
|
|
from typing import Union
|
|
|
|
import attr
|
|
|
|
PublishPayloadType = Union[str, bytes, int, float, None]
|
|
ReceivePayloadType = Union[str, bytes]
|
|
|
|
|
|
@attr.s(slots=True, frozen=True)
|
|
class PublishMessage:
|
|
"""MQTT Message."""
|
|
|
|
topic: str = attr.ib()
|
|
payload: PublishPayloadType = attr.ib()
|
|
qos: int = attr.ib()
|
|
retain: bool = attr.ib()
|
|
|
|
|
|
@attr.s(slots=True, frozen=True)
|
|
class ReceiveMessage:
|
|
"""MQTT Message."""
|
|
|
|
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)
|
|
|
|
|
|
AsyncMessageCallbackType = Callable[[ReceiveMessage], Awaitable[None]]
|
|
MessageCallbackType = Callable[[ReceiveMessage], None]
|