Skip to content

Commit b1778c7

Browse files
committed
bugfix: Handle label cases better in the detection script
1 parent 9e872a9 commit b1778c7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

alpaca/device.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
CLIENT_TIMEOUT_SECONDS = 300 # 5 Minutes
1616

1717
# Import from sibling modules
18-
from .config import AlpacaConfig, get_current_time
18+
from .config import AlpacaConfig, get_current_time, ALL_CLOUD_CONDITIONS
1919
# Assuming detect.py is in the root path or installed as a package
2020
from detect import CloudDetector, Config as DetectConfig, HADiscoveryManager
2121

@@ -230,6 +230,14 @@ def _run_single_detection(self, initial: bool = False):
230230
result = self.cloud_detector.detect(return_image=True)
231231
result['timestamp'] = get_current_time(self.alpaca_config.timezone)
232232

233+
# FIX: Normalize class name case to match configuration (Title Case preference)
234+
# This handles cases where detection returns "mostly cloudy" but config expects "Mostly Cloudy"
235+
raw_class = result.get('class_name', '')
236+
for known_cond in ALL_CLOUD_CONDITIONS:
237+
if known_cond.lower() == raw_class.lower():
238+
result['class_name'] = known_cond
239+
break
240+
233241
# OPTIMIZATION: Convert to bytes immediately and drop the PIL Object
234242
image_bytes = None
235243
if 'image' in result:

0 commit comments

Comments
 (0)