Update API object to support SSL
This commit is contained in:
parent
f4238ca242
commit
b33e9fe6d9
2 changed files with 7 additions and 3 deletions
|
@ -76,7 +76,8 @@ def setup(hass, config):
|
|||
threading.Thread(target=server.start, daemon=True).start())
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -51,11 +51,14 @@ class API(object):
|
|||
""" Object to pass around Home Assistant API location and credentials. """
|
||||
# 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.port = port or SERVER_PORT
|
||||
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._headers = {}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue