aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/common/__init__.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/common/__init__.py
parentqueue sleep as variable (diff)
downloadenergyscripts-eb5e90aded9a7259ddecc94d9244393fa5abd2e6.tar.gz
moving some variables around
Diffstat (limited to 'scripts/common/__init__.py')
-rw-r--r--scripts/common/__init__.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/scripts/common/__init__.py b/scripts/common/__init__.py
index f6c02d3..440b9a0 100644
--- a/scripts/common/__init__.py
+++ b/scripts/common/__init__.py
@@ -2,9 +2,78 @@
''' common functions and stuff '''
import os
+import sys
QUEUE = bool(os.environ.get('el_QUEUE', False))
+name = os.path.splitext(os.path.split(sys.argv[0])[-1])[0]
+
+sql = {
+ 'elvia': """
+ INSERT INTO
+ elvia
+ VALUES(%s, %s, %s, %s, %s, %s)
+ ON CONFLICT (startTime,endTime) DO NOTHING""",
+
+ 'elvia_gridtariff': """
+ INSERT INTO
+ elvia_gridtariff
+ VALUES(%s, %s, %s, %s, %s, %s, %s)
+ ON CONFLICT (meteringPointId,startTime,endTime) DO NOTHING""",
+
+ 'entsoe': """
+ INSERT INTO
+ entsoe
+ VALUES(%s, %s, %s)
+ ON CONFLICT (starttime, zone) DO NOTHING""",
+
+ 'nb': """
+ INSERT INTO
+ nbex
+ VALUES(%s, %s, %s, %s)
+ ON CONFLICT (startdate,base_cur,quote_cur) DO NOTHING""",
+
+ 'neohub': """
+ INSERT INTO
+ neohub
+ (timestamp,
+ time,
+ device_id,
+ away,
+ heat_mode,
+ heat_on,
+ current_floor_temperature,
+ target_temperature,
+ temperature)
+ VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s)""",
+
+ 'tibber_consumption': """
+ INSERT INTO
+ tibber_consumption
+ VALUES(%s, %s, %s, %s, %s, %s, %s)
+ ON CONFLICT (startTime,endTime) DO NOTHING""",
+
+
+ 'tibber_prices': """
+ INSERT INTO
+ tibber_prices
+ VALUES(%s, %s, %s, %s, %s)
+ ON CONFLICT (startsat) DO NOTHING""",
+
+ 'yr': """
+ INSERT INTO
+ yr
+ 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()""",
+}
+
# Initialize queue
if QUEUE is True:
from .queue import dbi