diff --git a/.media/41N1IH9jwoL._AC_SL1024_.jpg b/.media/41N1IH9jwoL._AC_SL1024_.jpg index 7da6d4f..6a9cafb 100644 Binary files a/.media/41N1IH9jwoL._AC_SL1024_.jpg and b/.media/41N1IH9jwoL._AC_SL1024_.jpg differ diff --git a/README.md b/README.md index b31c84a..75b446d 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,14 @@ Python gateway for the [custom firmware](https://github.com/atc1441/ATC_MiThermo ![](.media/41N1IH9jwoL._AC_SL1024_.jpg) +**Features:** +- [DONE] Make in runnable in a docker container (because only cool people are using docker) + **TODOs:** - [WIP] Can run on Raspberry Pi (3, 4, zero w) or any other Linux driven hardware which has BLE and WiFi support - [WIP] Storing temperature, humidity and battery state as json in a text file - [WIP] Implement a loop for fetching the data every x minute -- [DONE] Make in runnable in a docker container (because only cool people are using docker) +- [WIP] Make discoveries async - [TODO] Make docker image smaller. I mean shiiit 1GB D: should be possible to be under 500MB - [TODO] Make a microPython version for using the raspberry pico w or any other microcontroller with BLE and WiFi support - [TODO] Collect data from multiple devices/gateways @@ -55,3 +58,7 @@ Run docker container. Killing the hosts bluetooth service is needed to access it ```bash sudo sh run_docker.sh ``` + +### MicroPython for MicroController + +Coming when I develop it... diff --git a/bluetooth tools/search_for_blc.py b/bluetooth tools/search_for_blc.py new file mode 100644 index 0000000..e69de29 diff --git a/bluetooth tools/search_for_ble.py b/bluetooth tools/search_for_ble.py new file mode 100644 index 0000000..e69de29 diff --git a/python/requierements.txt b/python/requierements.txt index 1a6a99d..d99d203 100644 --- a/python/requierements.txt +++ b/python/requierements.txt @@ -1 +1,2 @@ -bluepy \ No newline at end of file +bluepy +pyyaml \ No newline at end of file diff --git a/python/src/devices.py b/python/src/devices.py new file mode 100644 index 0000000..31e56f0 --- /dev/null +++ b/python/src/devices.py @@ -0,0 +1,2 @@ +import yaml + diff --git a/python/src/devices.yml b/python/src/devices.yml new file mode 100644 index 0000000..ce23077 --- /dev/null +++ b/python/src/devices.yml @@ -0,0 +1,8 @@ +devices: + - "A4:C1:38:83:05:E8": + name: "My Sensor" + room: "My Room" + + - "...": + name: "..." + room: "..." diff --git a/python/src/discovery.py b/python/src/discovery.py index c391264..d01ff82 100644 --- a/python/src/discovery.py +++ b/python/src/discovery.py @@ -1,3 +1,5 @@ +import asyncio +from threading import Thread from bluepy.btle import DefaultDelegate from bluepy.btle import Scanner from datetime import datetime @@ -16,9 +18,10 @@ class ScanDelegate(DefaultDelegate): global devices for (sdid, desc, val) in dev.getScanData(): - if self.is_temperature(sdid, val) and self.is_atc_device(dev): + if self.is_temperature(sdid, val): data_obj = Data(self.parse_data(val)) - devices.append([dev, data_obj]) + if self.is_atc_device(dev, data_obj): + devices.append([dev, data_obj]) @staticmethod def is_temperature(sdid, val): @@ -27,14 +30,13 @@ class ScanDelegate(DefaultDelegate): return True @staticmethod - def is_atc_device(dev): + def is_atc_device(dev, data_obj): global devices if 'A4:C1:38' not in dev.addr.upper(): return False - device_found = False - # print(devices.count(dev.addr.upper())) for device in devices: if str(device[0].addr) == str(dev.addr): return False print("Device %s (%s), RSSI=%d dB" % (dev.addr.upper(), dev.addrType, dev.rssi)) + print(f'\tTemp: {data_obj.temperature}°C, Humid: {data_obj.humidity}%, Batt: {data_obj.battery_percent}%\n') return True @staticmethod diff --git a/python/src/main.py b/python/src/main.py index ea8c109..8f018a1 100644 --- a/python/src/main.py +++ b/python/src/main.py @@ -10,7 +10,7 @@ if len(devices) > 0: device = device_list[0] data:Data - print(f'Temp: {data.temperature}°C, Humid: {data.humidity}%, Batt: {data.battery_percent}%') + # print(f'Temp: {data.temperature}°C, Humid: {data.humidity}%, Batt: {data.battery_percent}%') else: