diff --git a/homeassistant/components/tesla.py b/homeassistant/components/tesla.py
index 915ebb6d4c3..86dc9c86792 100644
--- a/homeassistant/components/tesla.py
+++ b/homeassistant/components/tesla.py
@@ -6,8 +6,6 @@ https://home-assistant.io/components/tesla/
"""
from collections import defaultdict
import logging
-
-from urllib.error import HTTPError
import voluptuous as vol
from homeassistant.const import (
@@ -17,7 +15,7 @@ from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.util import slugify
-REQUIREMENTS = ['teslajsonpy==0.0.17']
+REQUIREMENTS = ['teslajsonpy==0.0.18']
DOMAIN = 'tesla'
@@ -45,7 +43,7 @@ TESLA_COMPONENTS = [
def setup(hass, base_config):
"""Set up of Tesla platform."""
- from teslajsonpy.controller import Controller as teslaApi
+ from teslajsonpy import Controller as teslaAPI, TeslaException
config = base_config.get(DOMAIN)
@@ -55,12 +53,12 @@ def setup(hass, base_config):
if hass.data.get(DOMAIN) is None:
try:
hass.data[DOMAIN] = {
- 'controller': teslaApi(
+ 'controller': teslaAPI(
email, password, update_interval),
'devices': defaultdict(list)
}
_LOGGER.debug("Connected to the Tesla API.")
- except HTTPError as ex:
+ except TeslaException as ex:
if ex.code == 401:
hass.components.persistent_notification.create(
"Error:
Please check username and password."
@@ -72,12 +70,11 @@ def setup(hass, base_config):
"Error:
Can't communicate with Tesla API.
"
"Error code: {} Reason: {}"
"You will need to restart Home Assistant after fixing."
- "".format(ex.code, ex.reason),
+ "".format(ex.code, ex.message),
title=NOTIFICATION_TITLE,
notification_id=NOTIFICATION_ID)
_LOGGER.error("Unable to communicate with Tesla API: %s",
- ex.reason)
-
+ ex.message)
return False
all_devices = hass.data[DOMAIN]['controller'].list_vehicles()
diff --git a/requirements_all.txt b/requirements_all.txt
index 31dfd3df3af..e4831f51443 100644
--- a/requirements_all.txt
+++ b/requirements_all.txt
@@ -1024,7 +1024,7 @@ tellduslive==0.3.4
temperusb==1.5.3
# homeassistant.components.tesla
-teslajsonpy==0.0.17
+teslajsonpy==0.0.18
# homeassistant.components.thingspeak
thingspeak==0.4.1