From ac9eb970e9d2eab001de67fd6c8208afff280cd4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 20 Jul 2024 16:46:52 -0700 Subject: [PATCH 1/2] build: pre-commit autoupdate (#1011) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> From 74f29861ffc6d7d1a3512f351dae24dc57ae04b6 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 10 Aug 2024 19:08:48 -0500 Subject: [PATCH 2/2] fix: fix api proxy cert blocking the event loop (#1030) --- custom_components/tesla_custom/__init__.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/custom_components/tesla_custom/__init__.py b/custom_components/tesla_custom/__init__.py index b162a37..c5636bb 100644 --- a/custom_components/tesla_custom/__init__.py +++ b/custom_components/tesla_custom/__init__.py @@ -142,14 +142,17 @@ async def async_setup_entry(hass, config_entry): # Because users can have multiple accounts, we always # create a new session so they have separate cookies - if config.get(CONF_API_PROXY_CERT): + if api_proxy_cert := config.get(CONF_API_PROXY_CERT): try: - SSL_CONTEXT.load_verify_locations(config[CONF_API_PROXY_CERT]) - _LOGGER.debug("Trusting CA: %s", SSL_CONTEXT.get_ca_certs()[-1]) + await hass.async_add_executor_job( + SSL_CONTEXT.load_verify_locations, api_proxy_cert + ) + if _LOGGER.isEnabledFor(logging.DEBUG): + _LOGGER.debug("Trusting CA: %s", SSL_CONTEXT.get_ca_certs()[-1]) except (FileNotFoundError, ssl.SSLError): _LOGGER.warning( "Unable to load custom SSL certificate from %s", - config[CONF_API_PROXY_CERT], + api_proxy_cert, ) async_client = httpx.AsyncClient( @@ -181,7 +184,6 @@ async def async_setup_entry(hass, config_entry): polling_policy=config_entry.options.get( CONF_POLLING_POLICY, DEFAULT_POLLING_POLICY ), - api_proxy_cert=config.get(CONF_API_PROXY_CERT), api_proxy_url=config.get(CONF_API_PROXY_URL), client_id=config.get(CONF_CLIENT_ID), )