From eb5e90aded9a7259ddecc94d9244393fa5abd2e6 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Sat, 4 Feb 2023 14:18:18 +0100 Subject: moving some variables around --- scripts/tibber_prices.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'scripts/tibber_prices.py') 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) -- cgit v1.2.3