Skip to content

Commit

Permalink
improved stability when values are around 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Heiko Bauer committed Mar 5, 2024
1 parent a821bec commit e2a8924
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "smart_meter_to_openhab"
version = "0.2.10"
version = "0.3.0"
description = "Pushing data of ISKRA MT175 smart meter to openhab"
authors = ["Heiko Bauer <heiko_bauer@icloud.com>"]
repository = "https://github.com/die-bauerei/smart-meter-to-openhab"
Expand Down
4 changes: 3 additions & 1 deletion smart_meter_to_openhab/openhab.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ def _get_persistence_values(self, oh_item_names : Tuple[str, ...], timedelta : d
def check_if_updated(self, oh_item_names : Tuple[str, ...], timedelta : datetime.timedelta) -> bool:
pers_values=self._get_persistence_values(oh_item_names, timedelta)
for values in pers_values:
if all(i == values[0] for i in values):
if not values:
return False
elif values[0] > 5.0 and all(i == values[0] for i in values):
return False
return True

Expand Down
3 changes: 2 additions & 1 deletion smart_meter_to_openhab_scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ def main() -> None:
logger.info(f"Starting smart_meter_to_openhab version {__version__}")
logger.setLevel(log_level_from_arg(args.verbose))
try:
process_start_time=datetime.now()
while True:
_run(datetime.now(), logger, args.smart_meter_read_count, args.interval_in_sec, args.ping_in_min, args.uhubctl)
_run(process_start_time, logger, args.smart_meter_read_count, args.interval_in_sec, args.ping_in_min, args.uhubctl)
except Exception as e:
logger.exception("Caught Exception: " + str(e))
except:
Expand Down

0 comments on commit e2a8924

Please sign in to comment.