This repository has been archived by the owner on Oct 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
blescanmulti - improve scanners options (#56)
* Helpful utils that will allow to reduce common code * Update config with new options for blescanmulti * Default values for blescanmulti if not provided by config file * Allow to configure scan behavior * Allow to configure returned payload * Initial version of saving last state * Support class that will remember last status of device * Add docs for available options * Move scanner to instance, this will prevent recreating it each time it is required to scan * Use items instead of values. We require here to have pair of key and value, not just value * Make sure that mac address is in lower case * Optimize searching for devices, use hash maps * Remove unused method * Because YAML is already doing some conversions this change will allow to always get proper value * Fix issue. Mac address and name was provided in wrong order * Use worker to format topic * Send also RSSI info
- Loading branch information
1 parent
716ea45
commit c6a068f
Showing
3 changed files
with
98 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
true_statement = ('y', 'yes', 'on', '1', 'true', 't', ) | ||
|
||
|
||
def booleanize(value) -> bool: | ||
""" | ||
This function will try to assume that provided string value is boolean in some way. It will accept a wide range | ||
of values for strings like ('y', 'yes', 'on', '1', 'true' and 't'. Any other value will be treated as false | ||
:param value: any value | ||
:return: boolean statement | ||
""" | ||
if isinstance(value, str): | ||
return value.lower() in true_statement | ||
return bool(value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters