mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Clean up ssl usage (#33960)
* Clean up ssl usage * Revert config[CONF_SSL] from sonarr, radarr and mfi
This commit is contained in:
parent
cfef8ee961
commit
8198970af9
@ -43,7 +43,7 @@ def get_scanner(hass, config):
|
|||||||
config[CONF_HOST],
|
config[CONF_HOST],
|
||||||
config[CONF_USERNAME],
|
config[CONF_USERNAME],
|
||||||
config[CONF_PASSWORD],
|
config[CONF_PASSWORD],
|
||||||
config.get(CONF_SSL),
|
config[CONF_SSL],
|
||||||
config.get(CONF_VERIFY_SSL),
|
config.get(CONF_VERIFY_SSL),
|
||||||
)
|
)
|
||||||
if not controller.is_logged_in():
|
if not controller.is_logged_in():
|
||||||
|
@ -71,7 +71,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
host = config.get(CONF_HOST)
|
host = config.get(CONF_HOST)
|
||||||
key = config.get(CONF_API_KEY)
|
key = config.get(CONF_API_KEY)
|
||||||
port = config.get(CONF_PORT)
|
port = config.get(CONF_PORT)
|
||||||
ssl = config.get(CONF_SSL)
|
ssl = config[CONF_SSL]
|
||||||
|
|
||||||
if port is None:
|
if port is None:
|
||||||
port = DEFAULT_SSL_PORT if ssl else DEFAULT_PORT
|
port = DEFAULT_SSL_PORT if ssl else DEFAULT_PORT
|
||||||
|
@ -107,7 +107,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
port=config.get(CONF_PORT),
|
port=config.get(CONF_PORT),
|
||||||
username=config.get(CONF_USERNAME),
|
username=config.get(CONF_USERNAME),
|
||||||
password=config.get(CONF_PASSWORD),
|
password=config.get(CONF_PASSWORD),
|
||||||
is_https=config.get(CONF_SSL),
|
is_https=config[CONF_SSL],
|
||||||
prefer_picon=config.get(CONF_USE_CHANNEL_ICON),
|
prefer_picon=config.get(CONF_USE_CHANNEL_ICON),
|
||||||
mac_address=config.get(CONF_MAC_ADDRESS),
|
mac_address=config.get(CONF_MAC_ADDRESS),
|
||||||
turn_off_to_deep=config.get(CONF_DEEP_STANDBY),
|
turn_off_to_deep=config.get(CONF_DEEP_STANDBY),
|
||||||
|
@ -90,7 +90,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
host = config.get(CONF_HOST)
|
host = config.get(CONF_HOST)
|
||||||
port = config.get(CONF_PORT)
|
port = config.get(CONF_PORT)
|
||||||
ssl = config.get(CONF_SSL)
|
ssl = config[CONF_SSL]
|
||||||
|
|
||||||
epson_proj = EpsonProjector(
|
epson_proj = EpsonProjector(
|
||||||
async_get_clientsession(hass, verify_ssl=False), name, host, port, ssl
|
async_get_clientsession(hass, verify_ssl=False), name, host, port, ssl
|
||||||
|
@ -90,10 +90,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
|
|
||||||
customize = config.get(CONF_CUSTOMIZE)
|
customize = config.get(CONF_CUSTOMIZE)
|
||||||
|
|
||||||
if config.get(CONF_SSL):
|
protocol = "https" if config[CONF_SSL] else "http"
|
||||||
protocol = "https"
|
|
||||||
else:
|
|
||||||
protocol = "http"
|
|
||||||
|
|
||||||
url = f"{protocol}://{host}"
|
url = f"{protocol}://{host}"
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ def setup(hass, config):
|
|||||||
"password": rconfig.get(CONF_PASSWORD),
|
"password": rconfig.get(CONF_PASSWORD),
|
||||||
"callbackip": rconfig.get(CONF_CALLBACK_IP),
|
"callbackip": rconfig.get(CONF_CALLBACK_IP),
|
||||||
"callbackport": rconfig.get(CONF_CALLBACK_PORT),
|
"callbackport": rconfig.get(CONF_CALLBACK_PORT),
|
||||||
"ssl": rconfig.get(CONF_SSL),
|
"ssl": rconfig[CONF_SSL],
|
||||||
"verify_ssl": rconfig.get(CONF_VERIFY_SSL),
|
"verify_ssl": rconfig.get(CONF_VERIFY_SSL),
|
||||||
"connect": True,
|
"connect": True,
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
"host": config[CONF_HOST],
|
"host": config[CONF_HOST],
|
||||||
"password": config.get(CONF_PASSWORD),
|
"password": config.get(CONF_PASSWORD),
|
||||||
"port": config.get(CONF_PORT),
|
"port": config.get(CONF_PORT),
|
||||||
"ssl": config.get(CONF_SSL),
|
"ssl": config[CONF_SSL],
|
||||||
"username": config.get(CONF_USERNAME),
|
"username": config.get(CONF_USERNAME),
|
||||||
"verify_ssl": config.get(CONF_VERIFY_SSL),
|
"verify_ssl": config.get(CONF_VERIFY_SSL),
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ class InfluxSensorData:
|
|||||||
points = list(self.influx.query(self.query).get_points())
|
points = list(self.influx.query(self.query).get_points())
|
||||||
if not points:
|
if not points:
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Query returned no points, sensor state set to UNKNOWN: %s", self.query,
|
"Query returned no points, sensor state set to UNKNOWN: %s", self.query
|
||||||
)
|
)
|
||||||
self.value = None
|
self.value = None
|
||||||
else:
|
else:
|
||||||
|
@ -198,7 +198,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
config.get(CONF_NAME),
|
config.get(CONF_NAME),
|
||||||
config.get(CONF_HOST),
|
config.get(CONF_HOST),
|
||||||
config.get(CONF_PORT),
|
config.get(CONF_PORT),
|
||||||
config.get(CONF_SSL),
|
config[CONF_SSL],
|
||||||
add_entities,
|
add_entities,
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
@ -40,7 +40,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
host = config.get(CONF_HOST)
|
host = config.get(CONF_HOST)
|
||||||
username = config.get(CONF_USERNAME)
|
username = config.get(CONF_USERNAME)
|
||||||
password = config.get(CONF_PASSWORD)
|
password = config.get(CONF_PASSWORD)
|
||||||
use_tls = config.get(CONF_SSL)
|
use_tls = config[CONF_SSL]
|
||||||
verify_tls = config.get(CONF_VERIFY_SSL)
|
verify_tls = config.get(CONF_VERIFY_SSL)
|
||||||
default_port = 6443 if use_tls else 6080
|
default_port = 6443 if use_tls else 6080
|
||||||
port = int(config.get(CONF_PORT, default_port))
|
port = int(config.get(CONF_PORT, default_port))
|
||||||
|
@ -144,9 +144,9 @@ def setup(hass, config):
|
|||||||
|
|
||||||
for printer in config[DOMAIN]:
|
for printer in config[DOMAIN]:
|
||||||
name = printer[CONF_NAME]
|
name = printer[CONF_NAME]
|
||||||
ssl = "s" if printer[CONF_SSL] else ""
|
protocol = "https" if printer[CONF_SSL] else "http"
|
||||||
base_url = (
|
base_url = (
|
||||||
f"http{ssl}://{printer[CONF_HOST]}:{printer[CONF_PORT]}"
|
f"{protocol}://{printer[CONF_HOST]}:{printer[CONF_PORT]}"
|
||||||
f"{printer[CONF_PATH]}api/"
|
f"{printer[CONF_PATH]}api/"
|
||||||
)
|
)
|
||||||
api_key = printer[CONF_API_KEY]
|
api_key = printer[CONF_API_KEY]
|
||||||
|
@ -64,7 +64,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
CONF_NAME: device_config.get(CONF_NAME),
|
CONF_NAME: device_config.get(CONF_NAME),
|
||||||
CONF_HOST: device_config.get(CONF_HOST),
|
CONF_HOST: device_config.get(CONF_HOST),
|
||||||
CONF_PORT: device_config.get(CONF_PORT),
|
CONF_PORT: device_config.get(CONF_PORT),
|
||||||
CONF_SSL: device_config.get(CONF_SSL),
|
CONF_SSL: device_config[CONF_SSL],
|
||||||
CONF_VERIFY_SSL: device_config.get(CONF_VERIFY_SSL),
|
CONF_VERIFY_SSL: device_config.get(CONF_VERIFY_SSL),
|
||||||
CONF_DEVICE_KEY: device_config.get(CONF_DEVICE_KEY),
|
CONF_DEVICE_KEY: device_config.get(CONF_DEVICE_KEY),
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ class OpenGarageCover(CoverDevice):
|
|||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
"""Initialize the cover."""
|
"""Initialize the cover."""
|
||||||
self.opengarage_url = (
|
self.opengarage_url = (
|
||||||
f"http{'s' if args[CONF_SSL] else ''}://"
|
f"{'https' if args[CONF_SSL] else 'http'}://"
|
||||||
f"{args[CONF_HOST]}:{args[CONF_PORT]}"
|
f"{args[CONF_HOST]}:{args[CONF_PORT]}"
|
||||||
)
|
)
|
||||||
self._name = args[CONF_NAME]
|
self._name = args[CONF_NAME]
|
||||||
|
@ -100,10 +100,10 @@ def _async_setup_plex(hass, config):
|
|||||||
if MP_DOMAIN in server_config:
|
if MP_DOMAIN in server_config:
|
||||||
hass.data.setdefault(PLEX_MEDIA_PLAYER_OPTIONS, server_config.pop(MP_DOMAIN))
|
hass.data.setdefault(PLEX_MEDIA_PLAYER_OPTIONS, server_config.pop(MP_DOMAIN))
|
||||||
if CONF_HOST in server_config:
|
if CONF_HOST in server_config:
|
||||||
prefix = "https" if server_config.pop(CONF_SSL) else "http"
|
protocol = "https" if server_config.pop(CONF_SSL) else "http"
|
||||||
server_config[
|
server_config[
|
||||||
CONF_URL
|
CONF_URL
|
||||||
] = f"{prefix}://{server_config.pop(CONF_HOST)}:{server_config.pop(CONF_PORT)}"
|
] = f"{protocol}://{server_config.pop(CONF_HOST)}:{server_config.pop(CONF_PORT)}"
|
||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
hass.config_entries.flow.async_init(
|
hass.config_entries.flow.async_init(
|
||||||
PLEX_DOMAIN,
|
PLEX_DOMAIN,
|
||||||
|
@ -51,12 +51,12 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
"""Set up the pyLoad sensors."""
|
"""Set up the pyLoad sensors."""
|
||||||
host = config.get(CONF_HOST)
|
host = config.get(CONF_HOST)
|
||||||
port = config.get(CONF_PORT)
|
port = config.get(CONF_PORT)
|
||||||
ssl = "s" if config.get(CONF_SSL) else ""
|
protocol = "https" if config[CONF_SSL] else "http"
|
||||||
name = config.get(CONF_NAME)
|
name = config.get(CONF_NAME)
|
||||||
username = config.get(CONF_USERNAME)
|
username = config.get(CONF_USERNAME)
|
||||||
password = config.get(CONF_PASSWORD)
|
password = config.get(CONF_PASSWORD)
|
||||||
monitored_types = config.get(CONF_MONITORED_VARIABLES)
|
monitored_types = config.get(CONF_MONITORED_VARIABLES)
|
||||||
url = f"http{ssl}://{host}:{port}/api/"
|
url = f"{protocol}://{host}:{port}/api/"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pyloadapi = PyLoadAPI(api_url=url, username=username, password=password)
|
pyloadapi = PyLoadAPI(api_url=url, username=username, password=password)
|
||||||
|
@ -175,7 +175,7 @@ class QNAPStatsAPI:
|
|||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
"""Initialize the API wrapper."""
|
"""Initialize the API wrapper."""
|
||||||
|
|
||||||
protocol = "https" if config.get(CONF_SSL) else "http"
|
protocol = "https" if config[CONF_SSL] else "http"
|
||||||
self._api = QNAPStats(
|
self._api = QNAPStats(
|
||||||
"{}://{}".format(protocol, config.get(CONF_HOST)),
|
"{}://{}".format(protocol, config.get(CONF_HOST)),
|
||||||
config.get(CONF_PORT),
|
config.get(CONF_PORT),
|
||||||
|
@ -53,11 +53,11 @@ SENSOR_TYPES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ENDPOINTS = {
|
ENDPOINTS = {
|
||||||
"diskspace": "http{0}://{1}:{2}/{3}api/diskspace",
|
"diskspace": "{0}://{1}:{2}/{3}api/diskspace",
|
||||||
"upcoming": "http{0}://{1}:{2}/{3}api/calendar?start={4}&end={5}",
|
"upcoming": "{0}://{1}:{2}/{3}api/calendar?start={4}&end={5}",
|
||||||
"movies": "http{0}://{1}:{2}/{3}api/movie",
|
"movies": "{0}://{1}:{2}/{3}api/movie",
|
||||||
"commands": "http{0}://{1}:{2}/{3}api/command",
|
"commands": "{0}://{1}:{2}/{3}api/command",
|
||||||
"status": "http{0}://{1}:{2}/{3}api/system/status",
|
"status": "{0}://{1}:{2}/{3}api/system/status",
|
||||||
}
|
}
|
||||||
|
|
||||||
# Support to Yottabytes for the future, why not
|
# Support to Yottabytes for the future, why not
|
||||||
@ -110,7 +110,7 @@ class RadarrSensor(Entity):
|
|||||||
self.apikey = conf.get(CONF_API_KEY)
|
self.apikey = conf.get(CONF_API_KEY)
|
||||||
self.included = conf.get(CONF_INCLUDED)
|
self.included = conf.get(CONF_INCLUDED)
|
||||||
self.days = int(conf.get(CONF_DAYS))
|
self.days = int(conf.get(CONF_DAYS))
|
||||||
self.ssl = "s" if conf.get(CONF_SSL) else ""
|
self.ssl = "https" if conf.get(CONF_SSL) else "http"
|
||||||
self._state = None
|
self._state = None
|
||||||
self.data = []
|
self.data = []
|
||||||
self._tz = timezone(str(hass.config.time_zone))
|
self._tz = timezone(str(hass.config.time_zone))
|
||||||
|
@ -134,7 +134,7 @@ async def async_setup(hass, config):
|
|||||||
|
|
||||||
conf = config.get(DOMAIN)
|
conf = config.get(DOMAIN)
|
||||||
if conf is not None:
|
if conf is not None:
|
||||||
use_ssl = conf.get(CONF_SSL)
|
use_ssl = conf[CONF_SSL]
|
||||||
name = conf.get(CONF_NAME)
|
name = conf.get(CONF_NAME)
|
||||||
api_key = conf.get(CONF_API_KEY)
|
api_key = conf.get(CONF_API_KEY)
|
||||||
await async_configure_sabnzbd(hass, conf, use_ssl, name, api_key)
|
await async_configure_sabnzbd(hass, conf, use_ssl, name, api_key)
|
||||||
|
@ -131,7 +131,8 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
session = async_get_clientsession(hass, verify_ssl=config[CONF_VERIFY_SSL])
|
session = async_get_clientsession(hass, verify_ssl=config[CONF_VERIFY_SSL])
|
||||||
grp = config[CONF_GROUP]
|
grp = config[CONF_GROUP]
|
||||||
|
|
||||||
url = "http{}://{}".format("s" if config[CONF_SSL] else "", config[CONF_HOST])
|
protocol = "https" if config[CONF_SSL] else "http"
|
||||||
|
url = f"{protocol}://{config[CONF_HOST]}"
|
||||||
|
|
||||||
sma = pysma.SMA(session, url, config[CONF_PASSWORD], group=grp)
|
sma = pysma.SMA(session, url, config[CONF_PASSWORD], group=grp)
|
||||||
|
|
||||||
|
@ -52,13 +52,13 @@ SENSOR_TYPES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ENDPOINTS = {
|
ENDPOINTS = {
|
||||||
"diskspace": "http{0}://{1}:{2}/{3}api/diskspace",
|
"diskspace": "{0}://{1}:{2}/{3}api/diskspace",
|
||||||
"queue": "http{0}://{1}:{2}/{3}api/queue",
|
"queue": "{0}://{1}:{2}/{3}api/queue",
|
||||||
"upcoming": "http{0}://{1}:{2}/{3}api/calendar?start={4}&end={5}",
|
"upcoming": "{0}://{1}:{2}/{3}api/calendar?start={4}&end={5}",
|
||||||
"wanted": "http{0}://{1}:{2}/{3}api/wanted/missing",
|
"wanted": "{0}://{1}:{2}/{3}api/wanted/missing",
|
||||||
"series": "http{0}://{1}:{2}/{3}api/series",
|
"series": "{0}://{1}:{2}/{3}api/series",
|
||||||
"commands": "http{0}://{1}:{2}/{3}api/command",
|
"commands": "{0}://{1}:{2}/{3}api/command",
|
||||||
"status": "http{0}://{1}:{2}/{3}api/system/status",
|
"status": "{0}://{1}:{2}/{3}api/system/status",
|
||||||
}
|
}
|
||||||
|
|
||||||
# Support to Yottabytes for the future, why not
|
# Support to Yottabytes for the future, why not
|
||||||
@ -111,7 +111,7 @@ class SonarrSensor(Entity):
|
|||||||
self.apikey = conf.get(CONF_API_KEY)
|
self.apikey = conf.get(CONF_API_KEY)
|
||||||
self.included = conf.get(CONF_INCLUDED)
|
self.included = conf.get(CONF_INCLUDED)
|
||||||
self.days = int(conf.get(CONF_DAYS))
|
self.days = int(conf.get(CONF_DAYS))
|
||||||
self.ssl = "s" if conf.get(CONF_SSL) else ""
|
self.ssl = "https" if conf.get(CONF_SSL) else "http"
|
||||||
self._state = None
|
self._state = None
|
||||||
self.data = []
|
self.data = []
|
||||||
self._tz = timezone(str(hass.config.time_zone))
|
self._tz = timezone(str(hass.config.time_zone))
|
||||||
|
@ -70,7 +70,7 @@ def setup(hass, config):
|
|||||||
host = conf.get(CONF_HOST)
|
host = conf.get(CONF_HOST)
|
||||||
port = conf.get(CONF_PORT)
|
port = conf.get(CONF_PORT)
|
||||||
token = conf.get(CONF_TOKEN)
|
token = conf.get(CONF_TOKEN)
|
||||||
use_ssl = conf.get(CONF_SSL)
|
use_ssl = conf[CONF_SSL]
|
||||||
verify_ssl = conf.get(CONF_VERIFY_SSL)
|
verify_ssl = conf.get(CONF_VERIFY_SSL)
|
||||||
name = conf.get(CONF_NAME)
|
name = conf.get(CONF_NAME)
|
||||||
entity_filter = conf[CONF_FILTER]
|
entity_filter = conf[CONF_FILTER]
|
||||||
|
@ -59,7 +59,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
|||||||
api_key = config[CONF_API_KEY]
|
api_key = config[CONF_API_KEY]
|
||||||
monitored_conditions = config.get(CONF_MONITORED_CONDITIONS)
|
monitored_conditions = config.get(CONF_MONITORED_CONDITIONS)
|
||||||
user = config.get(CONF_MONITORED_USERS)
|
user = config.get(CONF_MONITORED_USERS)
|
||||||
use_ssl = config.get(CONF_SSL)
|
use_ssl = config[CONF_SSL]
|
||||||
verify_ssl = config.get(CONF_VERIFY_SSL)
|
verify_ssl = config.get(CONF_VERIFY_SSL)
|
||||||
|
|
||||||
session = async_get_clientsession(hass, verify_ssl)
|
session = async_get_clientsession(hass, verify_ssl)
|
||||||
|
@ -82,10 +82,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
timeout = config.get(CONF_TIMEOUT)
|
timeout = config.get(CONF_TIMEOUT)
|
||||||
humidifier = config.get(CONF_HUMIDIFIER)
|
humidifier = config.get(CONF_HUMIDIFIER)
|
||||||
|
|
||||||
if config.get(CONF_SSL):
|
protocol = "https" if config[CONF_SSL] else "http"
|
||||||
proto = "https"
|
|
||||||
else:
|
|
||||||
proto = "http"
|
|
||||||
|
|
||||||
client = VenstarColorTouch(
|
client = VenstarColorTouch(
|
||||||
addr=host,
|
addr=host,
|
||||||
@ -93,7 +90,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
user=username,
|
user=username,
|
||||||
password=password,
|
password=password,
|
||||||
pin=pin,
|
pin=pin,
|
||||||
proto=proto,
|
proto=protocol,
|
||||||
)
|
)
|
||||||
|
|
||||||
add_entities([VenstarThermostat(client, humidifier)], True)
|
add_entities([VenstarThermostat(client, humidifier)], True)
|
||||||
|
@ -40,12 +40,9 @@ def setup(hass, config):
|
|||||||
"""Set up the Zabbix component."""
|
"""Set up the Zabbix component."""
|
||||||
|
|
||||||
conf = config[DOMAIN]
|
conf = config[DOMAIN]
|
||||||
if conf[CONF_SSL]:
|
protocol = "https" if config[CONF_SSL] else "http"
|
||||||
schema = "https"
|
|
||||||
else:
|
|
||||||
schema = "http"
|
|
||||||
|
|
||||||
url = urljoin("{}://{}".format(schema, conf[CONF_HOST]), conf[CONF_PATH])
|
url = urljoin(f"{protocol}://{conf[CONF_HOST]}", conf[CONF_PATH])
|
||||||
username = conf.get(CONF_USERNAME)
|
username = conf.get(CONF_USERNAME)
|
||||||
password = conf.get(CONF_PASSWORD)
|
password = conf.get(CONF_PASSWORD)
|
||||||
|
|
||||||
|
@ -58,13 +58,10 @@ def setup(hass, config):
|
|||||||
success = True
|
success = True
|
||||||
|
|
||||||
for conf in config[DOMAIN]:
|
for conf in config[DOMAIN]:
|
||||||
if conf[CONF_SSL]:
|
protocol = "https" if config[CONF_SSL] else "http"
|
||||||
schema = "https"
|
|
||||||
else:
|
|
||||||
schema = "http"
|
|
||||||
|
|
||||||
host_name = conf[CONF_HOST]
|
host_name = conf[CONF_HOST]
|
||||||
server_origin = f"{schema}://{host_name}"
|
server_origin = f"{protocol}://{host_name}"
|
||||||
zm_client = ZoneMinder(
|
zm_client = ZoneMinder(
|
||||||
server_origin,
|
server_origin,
|
||||||
conf.get(CONF_USERNAME),
|
conf.get(CONF_USERNAME),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user