2 Commits

Author SHA1 Message Date
Hauke Petersen
cb3e651983 verbump to 0.0.5 2022-09-15 09:40:22 +02:00
Hauke Petersen
3005dbe7e7 verbump to 0.0.4 2022-09-02 11:16:41 +02:00
2 changed files with 9 additions and 10 deletions

View File

@@ -21,7 +21,7 @@
import setuptools
name = "steckie"
ver = "0.0.3"
ver = "0.0.5"
desc = 'Read state from Tasmota smart plugs'
setuptools.setup(

View File

@@ -20,6 +20,7 @@ import sys
import json
import pytz
import logging
import dateutil
import urllib.request
from datetime import datetime
from deichapp import Deichapp
@@ -57,9 +58,7 @@ class Steckie(Deichapp):
f'ORDER BY DESC LIMIT 1'
res = self.db.query(query, None)
for p in res.get_points():
print(p)
last = pytz.UTC.localize(datetime.utcfromtimestamp(p["time"] / 1e9))
self.counters[name]["last"] = last
self.counters[name]["last"] = dateutil.parser.isoparse(p["time"])
total = p["e_total_kwh"]
self.counters[name]["year"] = total - p["e_year_kwh"]
self.counters[name]["month"] = total - p["e_month_kwh"]
@@ -97,14 +96,14 @@ class Steckie(Deichapp):
now_local = now.astimezone(pytz.timezone("Europe/Berlin"))
last_local = cnt["last"].astimezone(pytz.timezone("Europe/Berlin"))
if now_local.date().year != last_local.date().year:
self.cnt["year"] = total
self.cnt["month"] = total
self.cnt["day"] = total
cnt["year"] = total
cnt["month"] = total
cnt["day"] = total
elif now_local.date().month != last_local.date().month:
self.cnt["month"] = total
self.cnt["day"] = total
cnt["month"] = total
cnt["day"] = total
elif now_local.date().day != last_local.date().day:
self.cnt["day"] = total
cnt["day"] = total
cnt["last"] = now
# write data to DB