mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 22:07:10 +00:00
Fix broken core integration Smart Meter Texas by switching it to use HA's SSL Context (#140694)
* Update __init__.py to use HA's SSLContext * Update config_flow.py to use HA's SSLContext * Use default context for config_flow.py * Use default context instead in __init__.py Co-authored-by: Josef Zweck <josef@zweck.dev> * Fix import in __init__.py * Fix import in config_flow.py --------- Co-authored-by: Josef Zweck <josef@zweck.dev>
This commit is contained in:
parent
426be3c11b
commit
776495dfa2
@ -3,7 +3,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import ssl
|
import ssl
|
||||||
|
|
||||||
from smart_meter_texas import Account, Client, ClientSSLContext
|
from smart_meter_texas import Account, Client
|
||||||
from smart_meter_texas.exceptions import (
|
from smart_meter_texas.exceptions import (
|
||||||
SmartMeterTexasAPIError,
|
SmartMeterTexasAPIError,
|
||||||
SmartMeterTexasAuthError,
|
SmartMeterTexasAuthError,
|
||||||
@ -16,6 +16,7 @@ from homeassistant.exceptions import ConfigEntryNotReady
|
|||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
from homeassistant.helpers.debounce import Debouncer
|
from homeassistant.helpers.debounce import Debouncer
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
|
from homeassistant.util.ssl import get_default_context
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
DATA_COORDINATOR,
|
DATA_COORDINATOR,
|
||||||
@ -38,8 +39,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
account = Account(username, password)
|
account = Account(username, password)
|
||||||
|
|
||||||
client_ssl_context = ClientSSLContext()
|
ssl_context = get_default_context()
|
||||||
ssl_context = await client_ssl_context.get_ssl_context()
|
|
||||||
|
|
||||||
smart_meter_texas_data = SmartMeterTexasData(hass, entry, account, ssl_context)
|
smart_meter_texas_data = SmartMeterTexasData(hass, entry, account, ssl_context)
|
||||||
try:
|
try:
|
||||||
|
@ -4,7 +4,7 @@ import logging
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from aiohttp import ClientError
|
from aiohttp import ClientError
|
||||||
from smart_meter_texas import Account, Client, ClientSSLContext
|
from smart_meter_texas import Account, Client
|
||||||
from smart_meter_texas.exceptions import (
|
from smart_meter_texas.exceptions import (
|
||||||
SmartMeterTexasAPIError,
|
SmartMeterTexasAPIError,
|
||||||
SmartMeterTexasAuthError,
|
SmartMeterTexasAuthError,
|
||||||
@ -16,6 +16,7 @@ from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
|||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import aiohttp_client
|
from homeassistant.helpers import aiohttp_client
|
||||||
|
from homeassistant.util.ssl import get_default_context
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
@ -31,8 +32,7 @@ async def validate_input(hass: HomeAssistant, data):
|
|||||||
|
|
||||||
Data has the keys from DATA_SCHEMA with values provided by the user.
|
Data has the keys from DATA_SCHEMA with values provided by the user.
|
||||||
"""
|
"""
|
||||||
client_ssl_context = ClientSSLContext()
|
ssl_context = get_default_context()
|
||||||
ssl_context = await client_ssl_context.get_ssl_context()
|
|
||||||
client_session = aiohttp_client.async_get_clientsession(hass)
|
client_session = aiohttp_client.async_get_clientsession(hass)
|
||||||
account = Account(data["username"], data["password"])
|
account = Account(data["username"], data["password"])
|
||||||
client = Client(client_session, account, ssl_context)
|
client = Client(client_session, account, ssl_context)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user