Skip to content

Commit

Permalink
Formatting strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Mulliken committed Jun 18, 2021
1 parent 17dfbc0 commit 9eef746
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[metadata]
# replace with your username:
name = wyzeapy
version = 0.0.31-beta.13
version = 0.0.31-beta.14
author = Mulliken LLC
author_email = [email protected]
description = Python client for private Wyze API
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sonar.organization=joshuamulliken

# This is the name and version displayed in the SonarCloud UI.
sonar.projectName=wyzeapy
sonar.projectVersion=0.0.31-beta.13
sonar.projectVersion=0.0.31-beta.14

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
#sonar.sources=.
Expand Down
15 changes: 6 additions & 9 deletions src/wyzeapy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ async def get_sensors(self, force_update: bool = False) -> List[Sensor]:
return self._latest_sensors

async def get_sensor_state(self, sensor: Sensor) -> Sensor:
_LOGGER.debug(f"Getting latest cached sensor")
_LOGGER.debug(f"Sensor: Getting latest")

current_update_time = time.time() # Time value to check if the current value is fresh

if current_update_time - self._last_sensor_update >= self.sensor_update_interval:
_LOGGER.debug(f"Refreshing sensor information")
_LOGGER.debug(f"Sensor: Refreshing information")

start_time = time.time()
self._latest_sensors = await self.get_sensors(force_update=True)
Expand All @@ -121,11 +121,9 @@ async def get_sensor_state(self, sensor: Sensor) -> Sensor:
self.sensor_update_interval = (sum(self.previous_sensor_update_times) / len(
self.previous_sensor_update_times)) + BLINK_TIME # Freshness calculation

_LOGGER.debug(f"Current sensor update interval: {self.sensor_update_interval}")
_LOGGER.debug(f"Sensor: Update interval: {self.sensor_update_interval}")

self._last_sensor_update = current_update_time
else:
_LOGGER.debug(f"Returning old sensor info")

for i in self._latest_sensors:
if i.mac == sensor.mac:
Expand Down Expand Up @@ -260,11 +258,11 @@ async def get_latest_event(self, device: Device) -> Optional[Event]:
return None

async def get_cached_latest_event(self, device: Device) -> Optional[Event]:
_LOGGER.debug(f"Getting latest cached event")
_LOGGER.debug(f"Event: Getting latest")
current_update_time = time.time() # Time value to check if the current value is fresh

if self._latest_events is None or current_update_time - self._last_event_update > self.event_update_interval:
_LOGGER.debug(f"Refreshing data")
_LOGGER.debug(f"Sensor: Refreshing information")

start_time = time.time()
raw_events = (await self.net_client.get_full_event_list(10))['data']['event_list']
Expand All @@ -278,13 +276,12 @@ async def get_cached_latest_event(self, device: Device) -> Optional[Event]:
self.event_update_interval = (sum(self.previous_event_update_times) / len(
self.previous_event_update_times)) + BLINK_TIME # Freshness calculation

_LOGGER.debug(f"Current event update interval: {self.event_update_interval}")
_LOGGER.debug(f"Sensor: Update interval: {self.event_update_interval}")

self._last_event_update = current_update_time

return self.return_event_for_device(device, self._latest_events)

_LOGGER.debug(f"Providing old device info")
return self.return_event_for_device(device, self._latest_events)


Expand Down

0 comments on commit 9eef746

Please sign in to comment.