Skip to content

Commit

Permalink
Adding additional data checks for unavailibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse committed Jan 28, 2018
1 parent f8012af commit c5e5ef1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions teslajsonpy/Charger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion teslajsonpy/GPS.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit c5e5ef1

Please sign in to comment.