From 6776401525e121252aa118fc1653f1b4b8bf2c6f Mon Sep 17 00:00:00 2001 From: Tero Paloheimo Date: Tue, 26 Nov 2024 08:32:46 +0200 Subject: [PATCH] fix: correct typo in argument name search_duration_sec (#262) --- CHANGELOG.md | 1 + developer_notes.md | 2 +- ruuvitag_sensor/ruuvi.py | 22 +++++++++++----------- verification.py | 4 ++-- verification_async.py | 4 ++-- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28ed36e..05c137e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/developer_notes.md b/developer_notes.md index 13e42b8..65f5b48 100644 --- a/developer_notes.md +++ b/developer_notes.md @@ -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) ``` diff --git a/ruuvitag_sensor/ruuvi.py b/ruuvitag_sensor/ruuvi.py index 77b695c..a17a14a 100644 --- a/ruuvitag_sensor/ruuvi.py +++ b/ruuvitag_sensor/ruuvi.py @@ -125,14 +125,14 @@ 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 @@ -140,12 +140,12 @@ def get_data_for_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 @@ -153,14 +153,14 @@ def get_data_for_sensors( @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 @@ -168,7 +168,7 @@ async def get_data_for_sensors_async( 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] = {} @@ -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 @@ -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]: @@ -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 @@ -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 diff --git a/verification.py b/verification.py index 64f3e47..ce9a339 100644 --- a/verification.py +++ b/verification.py @@ -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: @@ -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: diff --git a/verification_async.py b/verification_async.py index 8d0b968..8ef86f6 100644 --- a/verification_async.py +++ b/verification_async.py @@ -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: @@ -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: