mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Improve MQTT Callable
type hints (#87838)
This commit is contained in:
parent
1a35c2d805
commit
71b67e20e4
@ -134,7 +134,7 @@ class Trigger:
|
|||||||
|
|
||||||
async def add_trigger(
|
async def add_trigger(
|
||||||
self, action: TriggerActionType, trigger_info: TriggerInfo
|
self, action: TriggerActionType, trigger_info: TriggerInfo
|
||||||
) -> Callable:
|
) -> Callable[[], None]:
|
||||||
"""Add MQTT trigger."""
|
"""Add MQTT trigger."""
|
||||||
instance = TriggerInstance(action, trigger_info, self)
|
instance = TriggerInstance(action, trigger_info, self)
|
||||||
self.trigger_instances.append(instance)
|
self.trigger_instances.append(instance)
|
||||||
|
@ -37,6 +37,7 @@ from .const import (
|
|||||||
from .debug_info import log_messages
|
from .debug_info import log_messages
|
||||||
from .mixins import MQTT_ENTITY_COMMON_SCHEMA, MqttEntity, async_setup_entry_helper
|
from .mixins import MQTT_ENTITY_COMMON_SCHEMA, MqttEntity, async_setup_entry_helper
|
||||||
from .models import (
|
from .models import (
|
||||||
|
MessageCallbackType,
|
||||||
MqttCommandTemplate,
|
MqttCommandTemplate,
|
||||||
MqttValueTemplate,
|
MqttValueTemplate,
|
||||||
PublishPayloadType,
|
PublishPayloadType,
|
||||||
@ -173,7 +174,7 @@ class MqttTextEntity(MqttEntity, TextEntity):
|
|||||||
topics: dict[str, Any] = {}
|
topics: dict[str, Any] = {}
|
||||||
|
|
||||||
def add_subscription(
|
def add_subscription(
|
||||||
topics: dict[str, Any], topic: str, msg_callback: Callable
|
topics: dict[str, Any], topic: str, msg_callback: MessageCallbackType
|
||||||
) -> None:
|
) -> None:
|
||||||
if self._config.get(topic) is not None:
|
if self._config.get(topic) is not None:
|
||||||
topics[topic] = {
|
topics[topic] = {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
"""Configure update platform in a device through MQTT topic."""
|
"""Configure update platform in a device through MQTT topic."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable
|
|
||||||
import functools
|
import functools
|
||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
@ -35,7 +34,7 @@ from .const import (
|
|||||||
)
|
)
|
||||||
from .debug_info import log_messages
|
from .debug_info import log_messages
|
||||||
from .mixins import MQTT_ENTITY_COMMON_SCHEMA, MqttEntity, async_setup_entry_helper
|
from .mixins import MQTT_ENTITY_COMMON_SCHEMA, MqttEntity, async_setup_entry_helper
|
||||||
from .models import MqttValueTemplate, ReceiveMessage
|
from .models import MessageCallbackType, MqttValueTemplate, ReceiveMessage
|
||||||
from .util import get_mqtt_data, valid_publish_topic, valid_subscribe_topic
|
from .util import get_mqtt_data, valid_publish_topic, valid_subscribe_topic
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
@ -148,7 +147,7 @@ class MqttUpdate(MqttEntity, UpdateEntity, RestoreEntity):
|
|||||||
topics: dict[str, Any] = {}
|
topics: dict[str, Any] = {}
|
||||||
|
|
||||||
def add_subscription(
|
def add_subscription(
|
||||||
topics: dict[str, Any], topic: str, msg_callback: Callable
|
topics: dict[str, Any], topic: str, msg_callback: MessageCallbackType
|
||||||
) -> None:
|
) -> None:
|
||||||
if self._config.get(topic) is not None:
|
if self._config.get(topic) is not None:
|
||||||
topics[topic] = {
|
topics[topic] = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user