Include hass device ID in mobile app get_config webhook (#121496)

pull/121507/head^2
Paulus Schoutsen 2024-07-08 11:00:21 +02:00 committed by GitHub
parent 00aafc0cf7
commit 1aa9588dcb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -721,10 +721,15 @@ async def webhook_get_config(
"""Handle a get config webhook."""
hass_config = hass.config.as_dict()
device: dr.DeviceEntry = hass.data[DOMAIN][DATA_DEVICES][
config_entry.data[CONF_WEBHOOK_ID]
]
resp = {
"latitude": hass_config["latitude"],
"longitude": hass_config["longitude"],
"elevation": hass_config["elevation"],
"hass_device_id": device.id,
"unit_system": hass_config["unit_system"],
"location_name": hass_config["location_name"],
"time_zone": hass_config["time_zone"],

View File

@ -10,7 +10,7 @@ from nacl.secret import SecretBox
import pytest
from homeassistant.components.camera import CameraEntityFeature
from homeassistant.components.mobile_app.const import CONF_SECRET, DOMAIN
from homeassistant.components.mobile_app.const import CONF_SECRET, DATA_DEVICES, DOMAIN
from homeassistant.components.tag import EVENT_TAG_SCANNED
from homeassistant.components.zone import DOMAIN as ZONE_DOMAIN
from homeassistant.const import (
@ -243,6 +243,7 @@ async def test_webhook_handle_get_config(
"""Test that we can get config properly."""
webhook_id = create_registrations[1]["webhook_id"]
webhook_url = f"/api/webhook/{webhook_id}"
device: dr.DeviceEntry = hass.data[DOMAIN][DATA_DEVICES][webhook_id]
# Create two entities
for sensor in (
@ -280,6 +281,7 @@ async def test_webhook_handle_get_config(
"latitude": hass_config["latitude"],
"longitude": hass_config["longitude"],
"elevation": hass_config["elevation"],
"hass_device_id": device.id,
"unit_system": hass_config["unit_system"],
"location_name": hass_config["location_name"],
"time_zone": hass_config["time_zone"],