Update temp.py

This commit is contained in:
2024-05-02 00:09:41 -05:00
parent 86286daa6a
commit bd694e8728

View File

@@ -5,7 +5,7 @@ from datetime import datetime, timedelta
import pytz import pytz
# Fetch data from NOAA Radar API # Fetch data from NOAA Radar API
response = requests.get('https://api.weather.gov/radar/stations/SITE') response = requests.get('https://api.weather.gov/radar/stations/KBIS')
data = response.json() data = response.json()
# Extract relevant information # Extract relevant information
@@ -27,7 +27,7 @@ measurement = 'radar_station'
time = current_time.isoformat() time = current_time.isoformat()
# Create InfluxDB client # Create InfluxDB client
client = InfluxDBClient(url="", token="", org="") client = InfluxDBClient(url="http://10.10.3.212:8086", token="TOKEN GOES HERE", org="ORG NAME HERE")
# Create write API # Create write API
write_api = client.write_api(write_options=SYNCHRONOUS) write_api = client.write_api(write_options=SYNCHRONOUS)
@@ -49,7 +49,7 @@ fields = {
"data_age_minutes": data_age, "data_age_minutes": data_age,
# Check if volume_coverage_pattern starts with 'R' or 'L', remove prefix if exists and convert to float # Check if volume_coverage_pattern starts with 'R' or 'L', remove prefix if exists and convert to float
"vcp": float(str(radar_data["rda"]["properties"]["volumeCoveragePattern"])[1:]) if str(radar_data["rda"]["properties"]["volumeCoveragePattern"]).startswith('R') or str(radar_data["rda"]["properties"]["volumeCoveragePattern"]).startswith('L') else float(rad> "vcp": float(str(radar_data["rda"]["properties"]["volumeCoveragePattern"])[1:]) if str(radar_data["rda"]["properties"]["volumeCoveragePattern"]).startswith('R') or str(radar_data["rda"]["properties"]["volumeCoveragePattern"]).startswith('L') else float(radar_data["rda"]["properties"]["volumeCoveragePattern"]),
# Add more fields as needed # Add more fields as needed
} }
@@ -58,4 +58,4 @@ fields = {
point = Point(measurement).time(time).tag("id", radar_data["id"]) point = Point(measurement).time(time).tag("id", radar_data["id"])
for field, value in fields.items(): for field, value in fields.items():
point.field(field, value) point.field(field, value)
write_api.write("Bucket", "Org", point) write_api.write("BUCKET NAME HERE", "ORG NAME HERE", point)