vdbg / hubibtpresence

Bluetooth scanner for Hubitat
MIT License
0 stars 0 forks source link

KeyError when running main.py if lower case characters used in MAC addresses entered in config.yaml #8

Open ArtSpaziano opened 5 months ago

ArtSpaziano commented 5 months ago

Full error here; pi@raspberrypi:~/hubibtpresence $ python3 main.py 2024-03-23 08:09:27,086 - INFO - Connecting to hubitat Maker API app http://192.168.1.106/apps/api/798 2024-03-23 08:09:27,092 - INFO - Running bluetooth scanning up to 3 time(s)... 2024-03-23 08:09:38,034 - ERROR - 'C8:13:AB:8F:F3:5F' Traceback (most recent call last): File "/home/pi/hubibtpresence/main.py", line 95, in main report(scan_count, devices, hubitat) File "/home/pi/hubibtpresence/main.py", line 34, in report data = devices[name] KeyError: 'C8:13:AB:8F:F3:5F'

config.yaml looks like this: devices: "c4:e8:c6:69:cc:0c": # The mac address of a device to monitor. name: "Pepper" # Friendly name used in logs. hubitatId: 937 # Optionally update the presnce of this virtual presence sensor in Hubitat. minRSSI: -50 # Optionally use RSSI value to consider the device "present". Remove this line to consider the device present as soon as it's "seen". "c8:13:ab:8f:f3:5f": # Mac address of another device to monitor. name: "Baby" # Friendly name used in logs. hubitatId: 938 # Optionally update the presnce of this virtual presence sensor in Hubitat. minRSSI: -50 # Optionally use RSSI value to consider the device "present". Remove this line to consider the device present as soon as it's "seen".

I don't see any special, hidden characters in the config.yaml file and haven't made any changes to the rest of the code. Using Python 3.9.2

vdbg commented 5 months ago

Do you have the spaces?

devices:
  "C8:13:AB:8F:F3:5F":  # 2 spaces
    name: "Pepper"      # 4 spaces
    hubitatId: 937      # 4 spaces
ArtSpaziano commented 5 months ago

I do now, but I still get the same error after adding the appropriate spaces. Updated config:

devices: "c4:e8:c6:69:cc:0c": # The mac address of a device to monitor. name: "Pepper" # Friendly name used in logs. hubitatId: 937 # Optionally update the presnce of this virtual presence sensor in Hubitat. minRSSI: -50 # Optionally use RSSI value to consider the device "present". Remove this line to consider the device present as soon as it's "seen". "c8:13:ab:8f:f3:5f": # Mac address of another device to monitor. name: "Baby" # Friendly name used in logs. hubitatId: 938 # Optionally update the presnce of this virtual presence sensor in Hubitat. minRSSI: -50 # Optionally use RSSI value to consider the device "present". Remove this line to consider the device present as soon as it's "seen".

ArtSpaziano commented 5 months ago

I figured it out. The MAC address needs to be all uppercase characters. 'seems to me that it should be more forgiving than that but that should be part of the instructions.

Thanks.