aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/yr.py
diff options
context:
space:
mode:
authorDennis Eriksen <d@ennis.no>2023-02-04 14:18:18 +0100
committerDennis Eriksen <d@ennis.no>2023-02-04 14:18:18 +0100
commiteb5e90aded9a7259ddecc94d9244393fa5abd2e6 (patch)
tree8e166a3bec6435c1490cff04cd704ae847b47eba /scripts/yr.py
parentqueue sleep as variable (diff)
downloadenergyscripts-eb5e90aded9a7259ddecc94d9244393fa5abd2e6.tar.gz
moving some variables around
Diffstat (limited to 'scripts/yr.py')
-rw-r--r--scripts/yr.py17
1 files changed, 2 insertions, 15 deletions
diff --git a/scripts/yr.py b/scripts/yr.py
index 3a6c8a7..deb248b 100644
--- a/scripts/yr.py
+++ b/scripts/yr.py
@@ -5,15 +5,11 @@ import os
import sys
import requests
-from common import dbi
+import common
lat = str(os.environ['el_yr_lat'])
lon = str(os.environ['el_yr_lon'])
-pg_db = os.environ['el_pg_db']
-pg_host = os.environ['el_pg_host']
-pg_table = "yr"
-
apiUrl = "https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=" + lat + "&lon=" + lon
### Get the data
@@ -46,13 +42,4 @@ for item in data["properties"]["timeseries"]:
details = item["data"]["instant"]["details"]
values.append((item["time"],details["air_temperature"],details["air_pressure_at_sea_level"],details["cloud_area_fraction"],details["relative_humidity"],details["wind_from_direction"],details["wind_speed"]))
-sql = "INSERT INTO " + pg_table + """ VALUES(%s,%s,%s,%s,%s,%s,%s) ON CONFLICT (time) DO UPDATE SET
- air_temperature=EXCLUDED.air_temperature,
- air_pressure_at_sea_level=EXCLUDED.air_pressure_at_sea_level,
- cloud_area_fraction=EXCLUDED.cloud_area_fraction,
- relative_humidity=EXCLUDED.relative_humidity,
- wind_from_direction=EXCLUDED.wind_from_direction,
- wind_speed=EXCLUDED.wind_speed,
- updated=now()"""
-
-dbi(sql, values, verbose=True)
+common.dbi(common.sql[common.name], values, verbose=True)