3 Commits

Author SHA1 Message Date
Hauke Petersen
f8fb9fcadb verbump to 0.0.7 2022-10-10 12:52:57 +02:00
Hauke Petersen
a22b344028 verbump to 0.0.6 2022-09-21 11:21:21 +02:00
Hauke Petersen
cb3e651983 verbump to 0.0.5 2022-09-15 09:40:22 +02:00
2 changed files with 12 additions and 13 deletions

View File

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

View File

@@ -21,14 +21,12 @@ import json
import pytz
import logging
import dateutil
import urllib.request
import urllib
from datetime import datetime
from deichapp import Deichapp
from deichflux import Deichflux
from deichfluxx import Deichfluxx
from apscheduler.schedulers.blocking import BlockingScheduler
import dateutil
CONFIG_DEFAULT = {
"interval": 5.0,
}
@@ -39,7 +37,7 @@ class Steckie(Deichapp):
super().__init__(cfg_file, CONFIG_DEFAULT)
self.scheduler = BlockingScheduler()
self.db = Deichflux(self.cfg["db"])
self.db = Deichfluxx.init(self.cfg["db"])
logging.warning("Steckie V0.72 - loaded...")
@@ -78,7 +76,8 @@ class Steckie(Deichapp):
now = pytz.UTC.localize(datetime.utcnow())
try:
with urllib.request.urlopen(f'{url}/cm?cmnd=Status%208') as raw:
with urllib.request.urlopen(f'{url}/cm?cmnd=Status%208',
timeout=self.cfg["timeout"]) as raw:
resp = json.loads(raw.read().decode("utf-8"))
except Exception as e:
logging.warning(f'{name} - no response: {e}')
@@ -96,14 +95,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