Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -862,24 +862,24 @@ class DataIntegrator:
|
|
| 862 |
if GEOPY_AVAILABLE:
|
| 863 |
self.geolocator = Nominatim(user_agent="plantscope_app")
|
| 864 |
|
| 865 |
-
|
| 866 |
-
|
| 867 |
-
|
| 868 |
-
|
| 869 |
-
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
|
| 873 |
-
|
| 874 |
-
|
| 875 |
-
|
| 876 |
-
|
| 877 |
-
|
| 878 |
-
|
| 879 |
-
|
| 880 |
-
|
| 881 |
-
|
| 882 |
-
|
| 883 |
|
| 884 |
def post_adafruit_data(self, feed_name: str, value: Any) -> bool:
|
| 885 |
"""Posts a new data point to an Adafruit IO feed."""
|
|
|
|
| 862 |
if GEOPY_AVAILABLE:
|
| 863 |
self.geolocator = Nominatim(user_agent="plantscope_app")
|
| 864 |
|
| 865 |
+
def get_adafruit_data(self, feed_name: str, limit: int = 1000) -> Optional[List[Dict]]:
|
| 866 |
+
"""Fetches data from an Adafruit IO feed - up to 1000 records without time limits."""
|
| 867 |
+
if not self.aio:
|
| 868 |
+
print("Adafruit IO not available or failed to initialize, skipping data fetch.")
|
| 869 |
+
return None
|
| 870 |
+
try:
|
| 871 |
+
feed = self.aio.feeds(feed_name)
|
| 872 |
+
data = self.aio.receive(feed.key, limit=limit)
|
| 873 |
+
|
| 874 |
+
print(f"谞诪砖讻讜 {len(data) if data else 0} 谞转讜谞讬诐 诪讛驻讬讚 {feed_name}")
|
| 875 |
+
return data
|
| 876 |
+
|
| 877 |
+
except APIError as e:
|
| 878 |
+
print(f"Adafruit API Error fetching data from {feed_name}: {e}. Check your feed key or network connection.")
|
| 879 |
+
return None
|
| 880 |
+
except Exception as e:
|
| 881 |
+
print(f"General Adafruit API Error: {e}")
|
| 882 |
+
return None
|
| 883 |
|
| 884 |
def post_adafruit_data(self, feed_name: str, value: Any) -> bool:
|
| 885 |
"""Posts a new data point to an Adafruit IO feed."""
|