Add some debug

This commit is contained in:
Scott Wallace 2021-06-16 16:23:24 +01:00
parent 26a396f8da
commit 5e5277e152
Signed by: scott
GPG key ID: AA742FDC5AFE2A72

View file

@ -7,9 +7,13 @@ from datetime import datetime
import bluetooth._bluetooth as bluez import bluetooth._bluetooth as bluez
import paho.mqtt.publish as publish import paho.mqtt.publish as publish
from bluetooth_utils.bluetooth_utils import (disable_le_scan, enable_le_scan, from bluetooth_utils.bluetooth_utils import (
parse_le_advertising_events, disable_le_scan,
raw_packet_to_str, toggle_device) enable_le_scan,
parse_le_advertising_events,
raw_packet_to_str,
toggle_device,
)
def send_to_mqtt(data: dict): def send_to_mqtt(data: dict):
@ -43,15 +47,16 @@ def le_advertise_packet_handler(mac: str, _, data: bytes, __):
temp = int(data_str[22:26], 16) / 10 temp = int(data_str[22:26], 16) / 10
hum = int(data_str[26:28], 16) hum = int(data_str[26:28], 16)
batt = int(data_str[28:30], 16) batt = int(data_str[28:30], 16)
send_to_mqtt( mqtt_data = {
{ 'timestamp': datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
'timestamp': datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'mac': mac,
'mac': mac, 'temperature': temp,
'temperature': temp, 'humidity': hum,
'humidity': hum, 'battery': batt,
'battery': batt, }
} send_to_mqtt(mqtt_data)
) print('Sending to MQTT:')
print(mqtt_data)
if __name__ == '__main__': if __name__ == '__main__':