Skip to content

Commit 442fcca

Browse files
committed
minor improvements
1 parent b5dc9dc commit 442fcca

4 files changed

Lines changed: 14 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ uv run python ./demos/test-serial.py /tmp/serial 1
9292
## How to run mongodb collector
9393

9494
```bash
95-
uv run poller 192.168.1.7 --mongo-url mongodb://mongodb.local:27017 --interval 1000 --interval 5
95+
uv run poller 192.168.1.7 --mongo-url mongodb://mongodb.local:27017 --interval 1000
9696
```
9797

9898
# Hardware wiring

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "python-pylontech-ext"
3-
version = "0.4.5"
3+
version = "0.4.6"
44
description = "Interfaces with Pylontech Batteries using RS485 protocol"
55
authors = [
66
{ name = "Frank Villaro-Dixon", email = "frank@villaro-dixon.eu" },

src/pylontechpoller/poller.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def run(argv: list[str]):
9696
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p', level=level)
9797

9898
cc = 0
99+
errs = 0
99100
spinner = ['|', '/', '-', '\\']
100101

101102
reporters = []
@@ -117,7 +118,7 @@ def run(argv: list[str]):
117118
))
118119

119120
hass_url = args.hass_url
120-
print(hass_url)
121+
121122
if hass_url:
122123
reporters.append(HassReporter(
123124
hass_url,
@@ -147,18 +148,24 @@ def run(argv: list[str]):
147148
for reporter in reporters:
148149
reporter.report_state(mb)
149150

151+
if cc % 1000 == 0:
152+
logging.info("Updates submitted since startup: %d", cc)
150153
if cc % 86400 == 0:
151154
for reporter in reporters:
152155
reporter.cleanup()
153156

154157
time.sleep(args.interval / 1000.0)
158+
errs = 0
155159
except (KeyboardInterrupt, SystemExit):
156160
exit(0)
157161
except BaseException as e:
162+
errs += 1
158163
logging.error("Exception occured: %s", e)
159-
160-
161-
164+
if errs > 10:
165+
logging.error("Too many exceptions in a row, exiting just in casej")
166+
exit(1)
167+
else:
168+
time.sleep(args.interval / 1000.0)
162169
def main():
163170
import sys
164171
run(sys.argv)

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)