mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
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,17 +1,20 @@
|
|||||||
"""Webhook handlers for mobile_app."""
|
"""Webhook handlers for mobile_app."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
import logging
|
import logging
|
||||||
import secrets
|
import secrets
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from aiohttp.web import HTTPBadRequest, Request, Response, json_response
|
from aiohttp.web import HTTPBadRequest, Request, Response, json_response
|
||||||
from nacl.exceptions import CryptoError
|
from nacl.exceptions import CryptoError
|
||||||
from nacl.secret import SecretBox
|
from nacl.secret import SecretBox
|
||||||
import voluptuous as vol
|
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 (
|
from homeassistant.components.binary_sensor import (
|
||||||
DEVICE_CLASSES as BINARY_SENSOR_CLASSES,
|
DEVICE_CLASSES as BINARY_SENSOR_CLASSES,
|
||||||
)
|
)
|
||||||
@ -111,6 +114,10 @@ from .helpers import (
|
|||||||
webhook_response,
|
webhook_response,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from homeassistant.components.tag import TagProtocol
|
||||||
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DELAY_SAVE = 10
|
DELAY_SAVE = 10
|
||||||
@ -681,8 +688,10 @@ async def webhook_get_config(hass, config_entry, data):
|
|||||||
@validate_schema({vol.Required("tag_id"): cv.string})
|
@validate_schema({vol.Required("tag_id"): cv.string})
|
||||||
async def webhook_scan_tag(hass, config_entry, data):
|
async def webhook_scan_tag(hass, config_entry, data):
|
||||||
"""Handle a fire event webhook."""
|
"""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(
|
await tag.async_scan_tag(
|
||||||
hass,
|
|
||||||
data["tag_id"],
|
data["tag_id"],
|
||||||
config_entry.data[ATTR_DEVICE_ID],
|
config_entry.data[ATTR_DEVICE_ID],
|
||||||
registration_context(config_entry.data),
|
registration_context(config_entry.data),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user