Avoid creating a task on callback in owntracks when using mqtt (#90548)

Nothing was being awaited in the callback. It did not
need to be a coro
This commit is contained in:
J. Nick Koston 2023-03-30 21:05:56 -10:00 committed by GitHub
parent 3a3c738945
commit ed673a1b35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,7 @@ from homeassistant.helpers.dispatcher import (
) )
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from homeassistant.setup import async_when_setup from homeassistant.setup import async_when_setup
from homeassistant.util.json import json_loads
from .config_flow import CONF_SECRET from .config_flow import CONF_SECRET
from .const import DOMAIN from .const import DOMAIN
@ -133,10 +134,11 @@ async def async_connect_mqtt(hass, component):
"""Subscribe to MQTT topic.""" """Subscribe to MQTT topic."""
context = hass.data[DOMAIN]["context"] context = hass.data[DOMAIN]["context"]
async def async_handle_mqtt_message(msg): @callback
def async_handle_mqtt_message(msg):
"""Handle incoming OwnTracks message.""" """Handle incoming OwnTracks message."""
try: try:
message = json.loads(msg.payload) message = json_loads(msg.payload)
except ValueError: except ValueError:
# If invalid JSON # If invalid JSON
_LOGGER.error("Unable to parse payload as JSON: %s", msg.payload) _LOGGER.error("Unable to parse payload as JSON: %s", msg.payload)