From 9cbdd36082d8a8fcb3158def63886e81744086f2 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 26 Jan 2022 00:34:48 -0800 Subject: [PATCH] Expose if HTTP is configured for SSL (#64940) --- homeassistant/components/cloud/http_api.py | 10 ++++++---- tests/components/cloud/test_http_api.py | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/cloud/http_api.py b/homeassistant/components/cloud/http_api.py index 028960bffed..517d6b2bb9b 100644 --- a/homeassistant/components/cloud/http_api.py +++ b/homeassistant/components/cloud/http_api.py @@ -21,6 +21,7 @@ from homeassistant.components.google_assistant import helpers as google_helpers from homeassistant.components.http import HomeAssistantView from homeassistant.components.http.data_validator import RequestDataValidator from homeassistant.components.websocket_api import const as ws_const +from homeassistant.core import HomeAssistant from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.util.location import async_detect_location_info @@ -288,7 +289,7 @@ async def websocket_cloud_status(hass, connection, msg): """ cloud = hass.data[DOMAIN] connection.send_message( - websocket_api.result_message(msg["id"], await _account_data(cloud)) + websocket_api.result_message(msg["id"], await _account_data(hass, cloud)) ) @@ -414,7 +415,7 @@ async def websocket_hook_delete(hass, connection, msg): connection.send_message(websocket_api.result_message(msg["id"])) -async def _account_data(cloud): +async def _account_data(hass: HomeAssistant, cloud: Cloud): """Generate the auth data JSON response.""" if not cloud.is_logged_in: @@ -445,6 +446,7 @@ async def _account_data(cloud): "remote_certificate": certificate, "remote_connected": remote.is_connected, "remote_domain": remote.instance_domain, + "http_use_ssl": hass.config.api.use_ssl, } @@ -457,7 +459,7 @@ async def websocket_remote_connect(hass, connection, msg): """Handle request for connect remote.""" cloud = hass.data[DOMAIN] await cloud.client.prefs.async_update(remote_enabled=True) - connection.send_result(msg["id"], await _account_data(cloud)) + connection.send_result(msg["id"], await _account_data(hass, cloud)) @websocket_api.require_admin @@ -469,7 +471,7 @@ async def websocket_remote_disconnect(hass, connection, msg): """Handle request for disconnect remote.""" cloud = hass.data[DOMAIN] await cloud.client.prefs.async_update(remote_enabled=False) - connection.send_result(msg["id"], await _account_data(cloud)) + connection.send_result(msg["id"], await _account_data(hass, cloud)) @websocket_api.require_admin diff --git a/tests/components/cloud/test_http_api.py b/tests/components/cloud/test_http_api.py index d3d71666bf2..07b87632f19 100644 --- a/tests/components/cloud/test_http_api.py +++ b/tests/components/cloud/test_http_api.py @@ -427,6 +427,7 @@ async def test_websocket_status( "remote_domain": None, "remote_connected": False, "remote_certificate": None, + "http_use_ssl": False, }