From b33e9fe6d9be501f7dc0d812f44887b5a22294c2 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 6 Dec 2015 14:13:35 -0800 Subject: [PATCH] Update API object to support SSL --- homeassistant/components/http.py | 3 ++- homeassistant/remote.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/http.py b/homeassistant/components/http.py index 1201f5b8528..144dbafba3c 100644 --- a/homeassistant/components/http.py +++ b/homeassistant/components/http.py @@ -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 diff --git a/homeassistant/remote.py b/homeassistant/remote.py index 72f95ca389a..3b47b60365c 100644 --- a/homeassistant/remote.py +++ b/homeassistant/remote.py @@ -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 = {}