Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a22b344028 | ||
|
|
cb3e651983 |
2
setup.py
2
setup.py
@@ -21,7 +21,7 @@
|
|||||||
import setuptools
|
import setuptools
|
||||||
|
|
||||||
name = "steckie"
|
name = "steckie"
|
||||||
ver = "0.0.4"
|
ver = "0.0.6"
|
||||||
desc = 'Read state from Tasmota smart plugs'
|
desc = 'Read state from Tasmota smart plugs'
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
|
|||||||
@@ -21,14 +21,12 @@ import json
|
|||||||
import pytz
|
import pytz
|
||||||
import logging
|
import logging
|
||||||
import dateutil
|
import dateutil
|
||||||
import urllib.request
|
import urllib
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from deichapp import Deichapp
|
from deichapp import Deichapp
|
||||||
from deichflux import Deichflux
|
from deichflux import Deichflux
|
||||||
from apscheduler.schedulers.blocking import BlockingScheduler
|
from apscheduler.schedulers.blocking import BlockingScheduler
|
||||||
|
|
||||||
import dateutil
|
|
||||||
|
|
||||||
CONFIG_DEFAULT = {
|
CONFIG_DEFAULT = {
|
||||||
"interval": 5.0,
|
"interval": 5.0,
|
||||||
}
|
}
|
||||||
@@ -78,7 +76,8 @@ class Steckie(Deichapp):
|
|||||||
now = pytz.UTC.localize(datetime.utcnow())
|
now = pytz.UTC.localize(datetime.utcnow())
|
||||||
|
|
||||||
try:
|
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"))
|
resp = json.loads(raw.read().decode("utf-8"))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.warning(f'{name} - no response: {e}')
|
logging.warning(f'{name} - no response: {e}')
|
||||||
@@ -96,14 +95,14 @@ class Steckie(Deichapp):
|
|||||||
now_local = now.astimezone(pytz.timezone("Europe/Berlin"))
|
now_local = now.astimezone(pytz.timezone("Europe/Berlin"))
|
||||||
last_local = cnt["last"].astimezone(pytz.timezone("Europe/Berlin"))
|
last_local = cnt["last"].astimezone(pytz.timezone("Europe/Berlin"))
|
||||||
if now_local.date().year != last_local.date().year:
|
if now_local.date().year != last_local.date().year:
|
||||||
self.cnt["year"] = total
|
cnt["year"] = total
|
||||||
self.cnt["month"] = total
|
cnt["month"] = total
|
||||||
self.cnt["day"] = total
|
cnt["day"] = total
|
||||||
elif now_local.date().month != last_local.date().month:
|
elif now_local.date().month != last_local.date().month:
|
||||||
self.cnt["month"] = total
|
cnt["month"] = total
|
||||||
self.cnt["day"] = total
|
cnt["day"] = total
|
||||||
elif now_local.date().day != last_local.date().day:
|
elif now_local.date().day != last_local.date().day:
|
||||||
self.cnt["day"] = total
|
cnt["day"] = total
|
||||||
cnt["last"] = now
|
cnt["last"] = now
|
||||||
|
|
||||||
# write data to DB
|
# write data to DB
|
||||||
|
|||||||
Reference in New Issue
Block a user