Skip to content

Commit

Permalink
fix: correct typo in argument name search_duration_sec (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
terop authored Nov 26, 2024
1 parent 6d604a8 commit 6776401
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* CHANGE: Async Bleak adapter as default adapter on all platforms
* CHANGE: Support only Python 3.9 and above
* FIX: Check if async adapter in use in RuuviTagReactive
* FIX: Correct typo in argument name search\_duration\_sec

## [2.3.1] - 2024-03-10
* ADD: Bluez as option to RUUVI_BLE_ADAPTER environment variable
Expand Down
2 changes: 1 addition & 1 deletion developer_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ ruuvitag_sensor.log.enable_console()
macs = []

while True:
data = RuuviTagSensor.get_data_for_sensors(macs, search_duratio_sec=5)
data = RuuviTagSensor.get_data_for_sensors(macs, search_duration_sec=5)
print(datetime.utcnow().isoformat())
print(data)
```
Expand Down
22 changes: 11 additions & 11 deletions ruuvitag_sensor/ruuvi.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,50 +125,50 @@ async def find_ruuvitags_async(bt_device: str = "") -> Dict[Mac, MacAndSensorDat

@staticmethod
def get_data_for_sensors(
macs: List[str] = [], search_duratio_sec: int = 5, bt_device: str = ""
macs: List[str] = [], search_duration_sec: int = 5, bt_device: str = ""
) -> Dict[Mac, SensorData]:
"""
Get latest data for sensors in the MAC address list.
Args:
macs (array): MAC addresses
search_duratio_sec (int): Search duration in seconds. Default 5
search_duration_sec (int): Search duration in seconds. Default 5
bt_device (string): Bluetooth device id
Returns:
dict: MAC and state of found sensors
"""
throw_if_not_sync_adapter(ble)

log.info("Get latest data for sensors. Stop with Ctrl+C.")
log.info("Stops automatically in %ss", search_duratio_sec)
log.info("Stops automatically in %ss", search_duration_sec)
log.info("MACs: %s", macs)

data: Dict[Mac, SensorData] = {}

for new_data in RuuviTagSensor._get_ruuvitag_data(macs, search_duratio_sec, bt_device=bt_device):
for new_data in RuuviTagSensor._get_ruuvitag_data(macs, search_duration_sec, bt_device=bt_device):
mac, sensor_data = new_data
data[mac] = sensor_data

return data

@staticmethod
async def get_data_for_sensors_async(
macs: List[str] = [], search_duratio_sec: int = 5, bt_device: str = ""
macs: List[str] = [], search_duration_sec: int = 5, bt_device: str = ""
) -> Dict[Mac, SensorData]:
"""
Get latest data for sensors in the MAC address list.
Args:
macs (array): MAC addresses
search_duratio_sec (int): Search duration in seconds. Default 5
search_duration_sec (int): Search duration in seconds. Default 5
bt_device (string): Bluetooth device id
Returns:
dict: MAC and state of found sensors
"""
throw_if_not_async_adapter(ble)

log.info("Get latest data for sensors. Stop with Ctrl+C.")
log.info("Stops automatically in %ss", search_duratio_sec)
log.info("Stops automatically in %ss", search_duration_sec)
log.info("MACs: %s", macs)

data: Dict[Mac, SensorData] = {}
Expand All @@ -177,7 +177,7 @@ async def get_data_for_sensors_async(
async for new_data in RuuviTagSensor.get_data_async(macs, bt_device):
mac, sensor_data = new_data
data[mac] = sensor_data
if search_duratio_sec and time.time() - start_time > search_duratio_sec:
if search_duration_sec and time.time() - start_time > search_duration_sec:
break

return data
Expand Down Expand Up @@ -252,7 +252,7 @@ def get_datas(
@staticmethod
def _get_ruuvitag_data(
macs: List[str] = [],
search_duratio_sec: Optional[int] = None,
search_duration_sec: Optional[int] = None,
run_flag: RunFlag = RunFlag(),
bt_device: str = "",
) -> Generator[MacAndSensorData, None, None]:
Expand All @@ -261,7 +261,7 @@ def _get_ruuvitag_data(
Args:
macs (list): MAC addresses. Default empty list
search_duratio_sec (int): Search duration in seconds. Default None
search_duration_sec (int): Search duration in seconds. Default None
run_flag (object): RunFlag object. Function executes while run_flag.running.
Default new RunFlag
bt_device (string): Bluetooth device id
Expand All @@ -275,7 +275,7 @@ def _get_ruuvitag_data(

for ble_data in data_iter:
# Check duration
if search_duratio_sec and time.time() - start_time > search_duratio_sec:
if search_duration_sec and time.time() - start_time > search_duration_sec:
data_iter.close()
break
# Check running flag
Expand Down
4 changes: 2 additions & 2 deletions verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def wait_for_finish(run_flag, name):
#
print_header("RuuviTagSensor.get_data_for_sensors")

data = RuuviTagSensor.get_data_for_sensors(search_duratio_sec=15)
data = RuuviTagSensor.get_data_for_sensors(search_duration_sec=15)
print(data)

if not data:
Expand All @@ -83,7 +83,7 @@ def wait_for_finish(run_flag, name):
#
print_header("RuuviTagSensor.get_data_for_sensors with macs")

data = RuuviTagSensor.get_data_for_sensors(list(data.keys())[0], search_duratio_sec=15)
data = RuuviTagSensor.get_data_for_sensors(list(data.keys())[0], search_duration_sec=15)
print(data)

if not data:
Expand Down
4 changes: 2 additions & 2 deletions verification_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def test_get_data_for_sensors_async() -> list[str]:
#
print_header("RuuviTagSensor.get_data_for_sensors_async")

data = await RuuviTagSensor.get_data_for_sensors_async(search_duratio_sec=5)
data = await RuuviTagSensor.get_data_for_sensors_async(search_duration_sec=5)
print(data)

if not data:
Expand All @@ -92,7 +92,7 @@ async def test_get_data_for_sensors_async_with_macs(mac: list[str]):
#
print_header("RuuviTagSensor.get_data_for_sensors with macs")

data = await RuuviTagSensor.get_data_for_sensors_async(mac, search_duratio_sec=5)
data = await RuuviTagSensor.get_data_for_sensors_async(mac, search_duration_sec=5)
print(data)

if not data:
Expand Down

0 comments on commit 6776401

Please sign in to comment.