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 = {}