Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion custom_components/pyscript/decorators/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@

import json
import logging
from typing import TYPE_CHECKING

import voluptuous as vol

from homeassistant.components import mqtt
from homeassistant.core import CALLBACK_TYPE
from homeassistant.helpers.importlib import async_import_module

from ..decorator_abc import DispatchData, TriggerDecorator
from .base import AutoKwargsDecorator, ExpressionDecorator

if TYPE_CHECKING:
from homeassistant.components import mqtt

_LOGGER = logging.getLogger(__name__)


Expand Down Expand Up @@ -54,6 +58,7 @@ async def start(self) -> None:
"""Start the MQTT trigger."""
await super().start()
topic = self.args[0]
mqtt = await async_import_module(self.dm.hass, "homeassistant.components.mqtt")
self.remove_listener_callback = await mqtt.async_subscribe(
self.dm.hass,
topic,
Expand Down
Loading