Files
Adam Strojek c6a068f811 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
2019-03-03 09:12:00 +01:00

15 lines
494 B
Python

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)