mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Use json_loads_object in arwn (#88611)
This commit is contained in:
parent
9fc6700c5a
commit
95dd62186e
@ -1,7 +1,6 @@
|
|||||||
"""Support for collecting data from the ARWN project."""
|
"""Support for collecting data from the ARWN project."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components import mqtt
|
from homeassistant.components import mqtt
|
||||||
@ -11,6 +10,7 @@ from homeassistant.core import HomeAssistant, callback
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
from homeassistant.util import slugify
|
from homeassistant.util import slugify
|
||||||
|
from homeassistant.util.json import json_loads_object
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ async def async_setup_platform(
|
|||||||
"""Set up the ARWN platform."""
|
"""Set up the ARWN platform."""
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_sensor_event_received(msg):
|
def async_sensor_event_received(msg: mqtt.ReceiveMessage) -> None:
|
||||||
"""Process events as sensors.
|
"""Process events as sensors.
|
||||||
|
|
||||||
When a new event on our topic (arwn/#) is received we map it
|
When a new event on our topic (arwn/#) is received we map it
|
||||||
@ -115,7 +115,7 @@ async def async_setup_platform(
|
|||||||
This lets us dynamically incorporate sensors without any
|
This lets us dynamically incorporate sensors without any
|
||||||
configuration on our side.
|
configuration on our side.
|
||||||
"""
|
"""
|
||||||
event = json.loads(msg.payload)
|
event = json_loads_object(msg.payload)
|
||||||
sensors = discover_sensors(msg.topic, event)
|
sensors = discover_sensors(msg.topic, event)
|
||||||
if not sensors:
|
if not sensors:
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user