Skip to content

Commit

Permalink
Interface unification
Browse files Browse the repository at this point in the history
  • Loading branch information
zabuldon committed Feb 7, 2018
1 parent 9453433 commit 6c25e1a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 4 additions & 3 deletions teslajsonpy/BatterySensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ def update(self):
def has_battery():
return False

def battery_level(self):
def get_value(self):
return self.__battery_level


class Range(VehicleDevice):
def __init__(self, data, controller):
super().__init__(data, controller)
Expand All @@ -55,15 +56,15 @@ def update(self):
if data:
if data['gui_distance_units'] == "mi/hr":
self.measurement = 'LENGTH_MILES'
else: #"km/hr"
else:
self.measurement = 'LENGTH_KILOMETERS'
self.__rated = (data['gui_range_display'] == "Rated")

@staticmethod
def has_battery():
return False

def range_level(self):
def get_value(self):
if self.__rated:
return self.__battery_range
else:
Expand Down
8 changes: 5 additions & 3 deletions teslajsonpy/GPS.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def update(self):
def has_battery():
return False


class Odometer(VehicleDevice):
def __init__(self, data, controller):
super().__init__(data, controller)
Expand All @@ -50,6 +51,7 @@ def __init__(self, data, controller):
self.uniq_name = self._uniq_name()
self.bin_type = 0xB
self.update()
self.__rated = True

def update(self):
self._controller.update(self._id)
Expand All @@ -60,13 +62,13 @@ def update(self):
if data:
if data['gui_distance_units'] == "mi/hr":
self.measurement = 'LENGTH_MILES'
else: #"km/hr"
else:
self.measurement = 'LENGTH_KILOMETERS'
self.__rated = (data['gui_range_display'] == "Rated")

@staticmethod
def has_battery():
return False

def mileage(self):
return self.__odometer
def get_value(self):
return round(self.__odometer, 1)

0 comments on commit 6c25e1a

Please sign in to comment.