diff options
author | Dennis Eriksen <d@ennis.no> | 2023-02-04 14:18:18 +0100 |
---|---|---|
committer | Dennis Eriksen <d@ennis.no> | 2023-02-04 14:18:18 +0100 |
commit | eb5e90aded9a7259ddecc94d9244393fa5abd2e6 (patch) | |
tree | 8e166a3bec6435c1490cff04cd704ae847b47eba /scripts/tibber_consumption.py | |
parent | queue sleep as variable (diff) | |
download | energyscripts-eb5e90aded9a7259ddecc94d9244393fa5abd2e6.tar.gz |
moving some variables around
Diffstat (limited to 'scripts/tibber_consumption.py')
-rw-r--r-- | scripts/tibber_consumption.py | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/scripts/tibber_consumption.py b/scripts/tibber_consumption.py index fa5169e..ea38bcb 100644 --- a/scripts/tibber_consumption.py +++ b/scripts/tibber_consumption.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_consumption" - startTime = datetime.now(get_localzone()) - timedelta(days = 1) startTime = startTime.isoformat('T') @@ -73,4 +69,4 @@ for item in data["data"]["viewer"]["homes"][0]["consumption"]["nodes"]: if item["consumption"] is not None: values.append((item["from"],item["to"],item["consumption"],item["consumptionUnit"],item["cost"],item["unitPrice"],item["unitPriceVAT"])) -dbi("INSERT INTO " + pg_table + " VALUES(%s,%s,%s,%s,%s,%s,%s) ON CONFLICT (startTime,endTime) DO NOTHING", values, verbose=True) +common.dbi(common.sql[common.name], values, verbose=True) |