Remove deprecated hass.components
from mysensors (#113611)
This commit is contained in:
parent
6ee273a548
commit
4be9d3e7f6
1 changed files with 4 additions and 5 deletions
|
@ -17,6 +17,8 @@ from homeassistant.components.mqtt import (
|
|||
DOMAIN as MQTT_DOMAIN,
|
||||
ReceiveMessage as MQTTReceiveMessage,
|
||||
ReceivePayloadType,
|
||||
async_publish,
|
||||
async_subscribe,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_DEVICE, EVENT_HOMEASSISTANT_STOP
|
||||
|
@ -171,13 +173,10 @@ async def _get_gateway(
|
|||
# Naive check that doesn't consider config entry state.
|
||||
if MQTT_DOMAIN not in hass.config.components:
|
||||
return None
|
||||
mqtt = hass.components.mqtt
|
||||
|
||||
def pub_callback(topic: str, payload: str, qos: int, retain: bool) -> None:
|
||||
"""Call MQTT publish function."""
|
||||
hass.async_create_task(
|
||||
mqtt.async_publish(hass, topic, payload, qos, retain)
|
||||
)
|
||||
hass.async_create_task(async_publish(hass, topic, payload, qos, retain))
|
||||
|
||||
def sub_callback(
|
||||
topic: str, sub_cb: Callable[[str, ReceivePayloadType, int], None], qos: int
|
||||
|
@ -189,7 +188,7 @@ async def _get_gateway(
|
|||
"""Call callback."""
|
||||
sub_cb(msg.topic, msg.payload, msg.qos)
|
||||
|
||||
hass.async_create_task(mqtt.async_subscribe(topic, internal_callback, qos))
|
||||
hass.async_create_task(async_subscribe(hass, topic, internal_callback, qos))
|
||||
|
||||
gateway = mysensors.AsyncMQTTGateway(
|
||||
pub_callback,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue