aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/tibber_prices.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/tibber_prices.py
parentqueue sleep as variable (diff)
downloadenergyscripts-eb5e90aded9a7259ddecc94d9244393fa5abd2e6.tar.gz
moving some variables around
Diffstat (limited to 'scripts/tibber_prices.py')
-rw-r--r--scripts/tibber_prices.py9
1 files changed, 2 insertions, 7 deletions
diff --git a/scripts/tibber_prices.py b/scripts/tibber_prices.py
index a2e9dda..985a068 100644
--- a/scripts/tibber_prices.py
+++ b/scripts/tibber_prices.py
@@ -8,17 +8,13 @@ from datetime import timedelta
from tzlocal import get_localzone
import requests
-from common import dbi
+import common
# variables
apiKey = os.environ['el_tibber_token']
apiUrl = "https://api.tibber.com/v1-beta/gql"
-pg_db = os.environ['el_pg_db']
-pg_host = os.environ['el_pg_host']
-pg_table = "tibber_prices"
-
startTime = datetime.now(get_localzone()) - timedelta(days = 1)
startTime = startTime.isoformat('T')
@@ -72,5 +68,4 @@ for item in data["data"]["viewer"]["homes"][0]["currentSubscription"]["priceInfo
for item in data["data"]["viewer"]["homes"][0]["currentSubscription"]["priceInfo"]["tomorrow"]:
prices.append((item["startsAt"],item["total"],item["energy"],item["tax"],item["level"]))
-
-dbi("INSERT INTO " + pg_table + " VALUES(%s,%s,%s,%s,%s) ON CONFLICT (startsat) DO NOTHING", prices, verbose=True)
+common.dbi(common.sql[common.name], prices, verbose=True)