Mobile App integration to use tag integration (#38757)

This commit is contained in:
Paulus Schoutsen 2020-08-11 14:23:47 +02:00 committed by GitHub
parent 1d9a469f84
commit d1780b8d7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -4,7 +4,7 @@
"config_flow": true, "config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/mobile_app", "documentation": "https://www.home-assistant.io/integrations/mobile_app",
"requirements": ["PyNaCl==1.3.0", "emoji==0.5.4"], "requirements": ["PyNaCl==1.3.0", "emoji==0.5.4"],
"dependencies": ["http", "webhook", "person"], "dependencies": ["http", "webhook", "person", "tag"],
"after_dependencies": ["cloud", "camera"], "after_dependencies": ["cloud", "camera"],
"codeowners": ["@robbiet480"], "codeowners": ["@robbiet480"],
"quality_scale": "internal" "quality_scale": "internal"

View File

@ -8,6 +8,7 @@ from aiohttp.web import HTTPBadRequest, Request, Response, json_response
from nacl.secret import SecretBox from nacl.secret import SecretBox
import voluptuous as vol import voluptuous as vol
from homeassistant.components import tag
from homeassistant.components.binary_sensor import ( from homeassistant.components.binary_sensor import (
DEVICE_CLASSES as BINARY_SENSOR_CLASSES, DEVICE_CLASSES as BINARY_SENSOR_CLASSES,
) )
@ -544,9 +545,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."""
hass.bus.async_fire( await tag.async_scan_tag(
"tag_scanned", hass,
{"tag_id": data["tag_id"], "device_id": config_entry.data[ATTR_DEVICE_ID]}, data["tag_id"],
context=registration_context(config_entry.data), config_entry.data[ATTR_DEVICE_ID],
registration_context(config_entry.data),
) )
return empty_okay_response() return empty_okay_response()