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