mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Import tag (#64539)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
3380a15bbb
commit
e37402e1d5
@ -117,7 +117,7 @@ async def async_setup_entry( # noqa: C901
|
|||||||
port = entry.data[CONF_PORT]
|
port = entry.data[CONF_PORT]
|
||||||
password = entry.data[CONF_PASSWORD]
|
password = entry.data[CONF_PASSWORD]
|
||||||
noise_psk = entry.data.get(CONF_NOISE_PSK)
|
noise_psk = entry.data.get(CONF_NOISE_PSK)
|
||||||
device_id = None
|
device_id: str | None = None
|
||||||
|
|
||||||
zeroconf_instance = await zeroconf.async_get_instance(hass)
|
zeroconf_instance = await zeroconf.async_get_instance(hass)
|
||||||
|
|
||||||
@ -184,11 +184,12 @@ async def async_setup_entry( # noqa: C901
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Call native tag scan
|
# Call native tag scan
|
||||||
if service_name == "tag_scanned":
|
if service_name == "tag_scanned" and device_id is not None:
|
||||||
|
# Importing tag via hass.components in case it is overridden
|
||||||
|
# in a custom_components (custom_components.tag)
|
||||||
|
tag = hass.components.tag
|
||||||
tag_id = service_data["tag_id"]
|
tag_id = service_data["tag_id"]
|
||||||
hass.async_create_task(
|
hass.async_create_task(tag.async_scan_tag(tag_id, device_id))
|
||||||
hass.components.tag.async_scan_tag(tag_id, device_id)
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
hass.bus.async_fire(service.service, service_data)
|
hass.bus.async_fire(service.service, service_data)
|
||||||
|
@ -177,7 +177,10 @@ class MQTTTagScanner:
|
|||||||
if not tag_id: # No output from template, ignore
|
if not tag_id: # No output from template, ignore
|
||||||
return
|
return
|
||||||
|
|
||||||
await self.hass.components.tag.async_scan_tag(tag_id, self.device_id)
|
# Importing tag via hass.components in case it is overridden
|
||||||
|
# in a custom_components (custom_components.tag)
|
||||||
|
tag = self.hass.components.tag
|
||||||
|
await tag.async_scan_tag(tag_id, self.device_id)
|
||||||
|
|
||||||
self._sub_state = subscription.async_prepare_subscribe_topics(
|
self._sub_state = subscription.async_prepare_subscribe_topics(
|
||||||
self.hass,
|
self.hass,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user