Skip to content

Commit

Permalink
fix: #494
Browse files Browse the repository at this point in the history
  • Loading branch information
m4dm4rtig4n committed Feb 12, 2024
1 parent c484d4b commit 6af83f1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/models/export_influxdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from init import INFLUXDB, DB

from datetime import datetime
from models.stat import Stat


def forceRound(x, n):
Expand All @@ -24,6 +25,7 @@ def __init__(self, influxdb_config, usage_point_config, measurement_direction="c
self.usage_point_config = usage_point_config
self.usage_point_id = self.usage_point_config.usage_point_id
self.measurement_direction = measurement_direction
self.stat = Stat(self.usage_point_id, measurement_direction=measurement_direction)
self.time_format = "%Y-%m-%dT%H:%M:%SZ"
if "timezone" not in self.influxdb_config or self.influxdb_config["timezone"] == "UTC":
self.tz = pytz.UTC
Expand Down Expand Up @@ -121,7 +123,8 @@ def detail(self, measurement_direction="consumption"):
watth = watt / (60 / detail.interval)
kwatth = watth / 1000
if measurement_direction == "consumption":
if detail.measure_type == "HP":
measure_type = self.stat.get_mesure_type(date)
if measure_type == "HP":
euro = kwatth * self.usage_point_config.consumption_price_hp
else:
euro = kwatth * self.usage_point_config.consumption_price_hc
Expand All @@ -135,7 +138,7 @@ def detail(self, measurement_direction="consumption"):
"year": detail.date.strftime("%Y"),
"month": detail.date.strftime("%m"),
"internal": detail.interval,
"measure_type": detail.measure_type,
"measure_type": measure_type,
},
fields={
"W": float(watt),
Expand Down

0 comments on commit 6af83f1

Please sign in to comment.