Google local sdk: Set right port, correct device id and add base url (#34358)

pull/34434/head
Bram Kragten 2020-04-18 05:59:49 +02:00 committed by GitHub
parent 42b6ec2fb5
commit 01599d44f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 3 deletions

View File

@ -423,8 +423,9 @@ class GoogleEntity:
device["otherDeviceIds"] = [{"deviceId": self.entity_id}]
device["customData"] = {
"webhookId": self.config.local_sdk_webhook_id,
"httpPort": self.hass.config.api.port,
"httpPort": self.hass.http.server_port,
"httpSSL": self.hass.config.api.use_ssl,
"baseUrl": self.hass.config.api.base_url,
"proxyDeviceId": agent_user_id,
}

View File

@ -48,6 +48,8 @@ def async_enable_report_state(hass: HomeAssistant, google_config: AbstractConfig
if entity_data == old_entity.query_serialize():
return
_LOGGER.debug("Reporting state for %s: %s", changed_entity, entity_data)
await google_config.async_report_state_all(
{"devices": {"states": {changed_entity: entity_data}}}
)

View File

@ -96,6 +96,8 @@ async def async_devices_sync(hass, data, payload):
await data.config.async_connect_agent_user(agent_user_id)
_LOGGER.debug("Syncing entities response: %s", response)
return response
@ -243,7 +245,7 @@ async def async_devices_identify(hass, data: RequestData, payload):
"""
return {
"device": {
"id": data.context.user_id,
"id": data.config.get_agent_user_id(data.context),
"isLocalOnly": True,
"isProxy": True,
"deviceInfo": {

View File

@ -24,7 +24,8 @@ from tests.common import (
async def test_google_entity_sync_serialize_with_local_sdk(hass):
"""Test sync serialize attributes of a GoogleEntity."""
hass.states.async_set("light.ceiling_lights", "off")
hass.config.api = Mock(port=1234, use_ssl=True)
hass.config.api = Mock(port=1234, use_ssl=True, base_url="https://hostname:1234")
hass.http = Mock(server_port=1234)
config = MockConfig(
hass=hass,
local_sdk_webhook_id="mock-webhook-id",
@ -45,6 +46,7 @@ async def test_google_entity_sync_serialize_with_local_sdk(hass):
"httpSSL": True,
"proxyDeviceId": None,
"webhookId": "mock-webhook-id",
"baseUrl": "https://hostname:1234",
}
for device_type in NOT_EXPOSE_LOCAL: