Skip to content

Commit

Permalink
feat: add wake_if_asleep param to update
Browse files Browse the repository at this point in the history
  • Loading branch information
alandtse committed Feb 16, 2020
1 parent 4ec8d9b commit 500968a
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
8 changes: 4 additions & 4 deletions teslajsonpy/battery_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def __init__(self, data: Dict, controller) -> None:
self.uniq_name: Text = self._uniq_name()
self.bin_type: hex = 0x5

async def async_update(self) -> None:
async def async_update(self, wake_if_asleep=False) -> None:
"""Update the battery state."""
await super().async_update()
await super().async_update(wake_if_asleep=wake_if_asleep)
data = self._controller.get_charging_params(self._id)
if data:
self.__battery_level = data["battery_level"]
Expand Down Expand Up @@ -97,9 +97,9 @@ def __init__(self, data: Dict, controller) -> None:
self.uniq_name = self._uniq_name()
self.bin_type = 0xA

async def async_update(self):
async def async_update(self, wake_if_asleep=False) -> None:
"""Update the battery range state."""
await super().async_update()
await super().async_update(wake_if_asleep=wake_if_asleep)
data = self._controller.get_charging_params(self._id)
if data:
self.__battery_range = data["battery_range"]
Expand Down
12 changes: 6 additions & 6 deletions teslajsonpy/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ def __init__(self, data: Dict, controller):
self.uniq_name = self._uniq_name()
self.bin_type = 0x1

async def async_update(self):
async def async_update(self, wake_if_asleep=False) -> None:
"""Update the parking brake sensor."""
await super().async_update()
await super().async_update(wake_if_asleep=wake_if_asleep)
data = self._controller.get_drive_params(self._id)
if data:
self.attrs["shift_state"] = (
Expand Down Expand Up @@ -100,9 +100,9 @@ def __init__(self, data, controller):
self.uniq_name = self._uniq_name()
self.bin_type = 0x2

async def async_update(self):
async def async_update(self, wake_if_asleep=False) -> None:
"""Update the charger connection sensor."""
await super().async_update()
await super().async_update(wake_if_asleep=wake_if_asleep)
data = self._controller.get_charging_params(self._id)
if data:
self.attrs["charging_state"] = data["charging_state"]
Expand Down Expand Up @@ -144,9 +144,9 @@ def __init__(self, data: Dict, controller) -> None:
self.name: Text = self._name()
self.uniq_name: Text = self._uniq_name()

async def async_update(self) -> None:
async def async_update(self, wake_if_asleep=False) -> None:
"""Update the battery state."""
await super().async_update()
await super().async_update(wake_if_asleep=wake_if_asleep)
self.__online_state = self._controller.car_online[self._vin]
self.attrs["state"] = self._controller.car_state[self._vin].get("state")

Expand Down
12 changes: 6 additions & 6 deletions teslajsonpy/charger.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ def __init__(self, data, controller):
self.uniq_name = self._uniq_name()
self.bin_type = 0x8

async def async_update(self):
async def async_update(self, wake_if_asleep=False) -> None:
"""Update the charging state of the Tesla Vehicle."""
await super().async_update()
await super().async_update(wake_if_asleep=wake_if_asleep)
last_update = self._controller.get_last_update_time(self._id)
if last_update >= self.__manual_update_time:
data = self._controller.get_charging_params(self._id)
Expand Down Expand Up @@ -94,9 +94,9 @@ def __init__(self, data, controller):
self.uniq_name = self._uniq_name()
self.bin_type = 0x9

async def async_update(self):
async def async_update(self, wake_if_asleep=False) -> None:
"""Update the status of the range setting."""
await super().async_update()
await super().async_update(wake_if_asleep=wake_if_asleep)
last_update = self._controller.get_last_update_time(self._id)
if last_update >= self.__manual_update_time:
data = self._controller.get_charging_params(self._id)
Expand Down Expand Up @@ -161,9 +161,9 @@ def __init__(self, data: Dict, controller) -> None:
self.__charger_actual_current = None
self.__charger_voltage = None

async def async_update(self) -> None:
async def async_update(self, wake_if_asleep=False) -> None:
"""Update the battery state."""
await super().async_update()
await super().async_update(wake_if_asleep=wake_if_asleep)
data = self._controller.get_gui_params(self._id)
if data:
self.measurement = data["gui_distance_units"]
Expand Down
8 changes: 4 additions & 4 deletions teslajsonpy/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def get_fan_status(self):
"""Return fan status."""
return self.__fan_status

async def async_update(self):
async def async_update(self, wake_if_asleep=False) -> None:
"""Update the HVAC state."""
await super().async_update()
await super().async_update(wake_if_asleep=wake_if_asleep)
data = self._controller.get_climate_params(self._id)
if data:
last_update = self._controller.get_last_update_time(self._id)
Expand Down Expand Up @@ -180,9 +180,9 @@ def get_outside_temp(self):
"""Get outside temperature."""
return self.__outside_temp

async def async_update(self):
async def async_update(self, wake_if_asleep=False) -> None:
"""Update the temperature."""
await super().async_update()
await super().async_update(wake_if_asleep=wake_if_asleep)
data = self._controller.get_climate_params(self._id)
if data:
self.__inside_temp = (
Expand Down
8 changes: 4 additions & 4 deletions teslajsonpy/gps.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def get_location(self):
}
return self.__location

async def async_update(self):
async def async_update(self, wake_if_asleep=False) -> None:
"""Update the current GPS location."""
await super().async_update()
await super().async_update(wake_if_asleep=wake_if_asleep)
data = self._controller.get_drive_params(self._id)
if data:
self.__longitude = data["longitude"]
Expand Down Expand Up @@ -103,9 +103,9 @@ def __init__(self, data, controller):
self.bin_type = 0xB
self.__rated = True

async def async_update(self):
async def async_update(self, wake_if_asleep=False) -> None:
"""Update the odometer and the unit of measurement based on GUI."""
await super().async_update()
await super().async_update(wake_if_asleep=wake_if_asleep)
data = self._controller.get_state_params(self._id)
if data:
self.__odometer = data["odometer"]
Expand Down
8 changes: 4 additions & 4 deletions teslajsonpy/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ def __init__(self, data, controller):
self.uniq_name = self._uniq_name()
self.bin_type = 0x7

async def async_update(self):
async def async_update(self, wake_if_asleep=False) -> None:
"""Update the lock state."""
await super().async_update()
await super().async_update(wake_if_asleep=wake_if_asleep)
last_update = self._controller.get_last_update_time(self._id)
if last_update >= self.__manual_update_time:
data = self._controller.get_state_params(self._id)
Expand Down Expand Up @@ -116,9 +116,9 @@ def __init__(self, data, controller):
self.uniq_name = self._uniq_name()
self.bin_type = 0x7

async def async_update(self):
async def async_update(self, wake_if_asleep=False) -> None:
"""Update state of the charger lock."""
await super().async_update()
await super().async_update(wake_if_asleep=wake_if_asleep)
last_update = self._controller.get_last_update_time(self._id)
if last_update >= self.__manual_update_time:
data = self._controller.get_charging_params(self._id)
Expand Down
4 changes: 2 additions & 2 deletions teslajsonpy/vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ def assumed_state(self):
> self._controller.update_interval
)

async def async_update(self):
async def async_update(self, wake_if_asleep=False):
"""Update the car version."""
await self._controller.update(self.id(), wake_if_asleep=False)
await self._controller.update(self.id(), wake_if_asleep=wake_if_asleep)
state = self._controller.get_state_params(self.id())
if state and "car_version" in state:
self._car_version = state["car_version"]
Expand Down

0 comments on commit 500968a

Please sign in to comment.