diff --git a/ble_redis.py b/ble_redis.py new file mode 100644 index 0000000..45de8fe --- /dev/null +++ b/ble_redis.py @@ -0,0 +1,20 @@ + +import redis +import json +from config import * + +#################################################### +### Redis Functions +#################################################### +if enable_redis: + r = redis.Redis(host=bind_ip, port=redis_port) + +def update_redis(data): + # push data to redis + # Publish to the Redis channel that the WS server is listening on + r.publish('temp_hum', json.dumps(data)) + if debug_output: + print("=== Stats Redis Update ===") + print(json.dumps(data, indent=2)) + return True + diff --git a/scanner.py b/scanner.py index 048a55f..70567bc 100644 --- a/scanner.py +++ b/scanner.py @@ -8,7 +8,7 @@ from typing import Set, Iterable from config import * from sensors import * from ble import * -from ble-redis import * +from ble_redis import * # In-memory cache + thread-safe lock _mac_cache: Set[str] = set()