mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
Update API object to support SSL
This commit is contained in:
parent
f4238ca242
commit
b33e9fe6d9
@ -76,7 +76,8 @@ def setup(hass, config):
|
|||||||
threading.Thread(target=server.start, daemon=True).start())
|
threading.Thread(target=server.start, daemon=True).start())
|
||||||
|
|
||||||
hass.http = server
|
hass.http = server
|
||||||
hass.config.api = rem.API(util.get_local_ip(), api_password, server_port)
|
hass.config.api = rem.API(util.get_local_ip(), api_password, server_port,
|
||||||
|
certificate is not None)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -51,11 +51,14 @@ class API(object):
|
|||||||
""" Object to pass around Home Assistant API location and credentials. """
|
""" Object to pass around Home Assistant API location and credentials. """
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
|
|
||||||
def __init__(self, host, api_password=None, port=None):
|
def __init__(self, host, api_password=None, port=None, use_ssl=False):
|
||||||
self.host = host
|
self.host = host
|
||||||
self.port = port or SERVER_PORT
|
self.port = port or SERVER_PORT
|
||||||
self.api_password = api_password
|
self.api_password = api_password
|
||||||
self.base_url = "http://{}:{}".format(host, self.port)
|
if use_ssl:
|
||||||
|
self.base_url = "https://{}:{}".format(host, self.port)
|
||||||
|
else:
|
||||||
|
self.base_url = "http://{}:{}".format(host, self.port)
|
||||||
self.status = None
|
self.status = None
|
||||||
self._headers = {}
|
self._headers = {}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user