Import tag via hass.components in mobile_app (#82138)
* Import tag via hass.components in mobile_app * Update webhook.py
This commit is contained in:
parent
ab5c99fe22
commit
af9ac9022b
1 changed files with 11 additions and 2 deletions
|
@ -1,17 +1,20 @@
|
|||
"""Webhook handlers for mobile_app."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from contextlib import suppress
|
||||
from functools import wraps
|
||||
from http import HTTPStatus
|
||||
import logging
|
||||
import secrets
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from aiohttp.web import HTTPBadRequest, Request, Response, json_response
|
||||
from nacl.exceptions import CryptoError
|
||||
from nacl.secret import SecretBox
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import camera, cloud, notify as hass_notify, tag
|
||||
from homeassistant.components import camera, cloud, notify as hass_notify
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASSES as BINARY_SENSOR_CLASSES,
|
||||
)
|
||||
|
@ -111,6 +114,10 @@ from .helpers import (
|
|||
webhook_response,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from homeassistant.components.tag import TagProtocol
|
||||
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DELAY_SAVE = 10
|
||||
|
@ -681,8 +688,10 @@ async def webhook_get_config(hass, config_entry, data):
|
|||
@validate_schema({vol.Required("tag_id"): cv.string})
|
||||
async def webhook_scan_tag(hass, config_entry, data):
|
||||
"""Handle a fire event webhook."""
|
||||
# Importing tag via hass.components in case it is overridden
|
||||
# in a custom_components (custom_components.tag)
|
||||
tag: TagProtocol = hass.components.tag
|
||||
await tag.async_scan_tag(
|
||||
hass,
|
||||
data["tag_id"],
|
||||
config_entry.data[ATTR_DEVICE_ID],
|
||||
registration_context(config_entry.data),
|
||||
|
|
Loading…
Add table
Reference in a new issue