diff --git a/teslajsonpy/Charger.py b/teslajsonpy/Charger.py index 0d8dac2d..d1f71c90 100644 --- a/teslajsonpy/Charger.py +++ b/teslajsonpy/Charger.py @@ -26,14 +26,14 @@ def update(self): def start_charge(self): if not self.__charger_state: data = self._controller.command(self._id, 'charge_start') - if data['response']['result']: + if data and data['response']['result']: self.__charger_state = True self.__manual_update_time = time.time() def stop_charge(self): if self.__charger_state: data = self._controller.command(self._id, 'charge_stop') - if data['response']['result']: + if data and data['response']['result']: self.__charger_state = False self.__manual_update_time = time.time() diff --git a/teslajsonpy/GPS.py b/teslajsonpy/GPS.py index e13c78dc..258079b6 100644 --- a/teslajsonpy/GPS.py +++ b/teslajsonpy/GPS.py @@ -30,7 +30,7 @@ def update(self): self.__longitude = data['longitude'] self.__latitude = data['latitude'] self.__heading = data['heading'] - if data['latitude'] and data['longitude'] and data['heading']: + if self.__longitude and self.__latitude and self.__heading: self.__location = {'longitude': self.__longitude, 'latitude': self.__latitude, 'heading': self.__heading}