Skip to content

Commit

Permalink
changed meter stream timeout from 5s to 60s
Browse files Browse the repository at this point in the history
added warning if it takes longer than 5s
fixes #7
  • Loading branch information
mr-manuel committed Dec 4, 2023
1 parent fd0eb30 commit bee13f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## v0.2.1
* Changed: Increased timeout for fetch_meter_stream() from 5 seconds to 60 seconds. Output a warning, if it take longer than 5 seconds

## v0.2.0
* Added: StatusCode: 7 = Running; 8 = Standby (if power below 5 W)

Expand Down
9 changes: 6 additions & 3 deletions dbus-enphase-envoy/dbus-enphase-envoy.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,15 +363,15 @@ def fetch_meter_stream():
response = requests.get(
url,
stream=True,
timeout=5,
timeout=60,
headers=request_headers,
verify=False
)
else:
response = requests.get(
url,
stream=True,
timeout=5,
timeout=60,
auth=HTTPDigestAuth('installer', config['ENVOY']['password'])
)

Expand All @@ -381,6 +381,9 @@ def fetch_meter_stream():
keep_running = False
sys.exit()

if response.elapsed.total_seconds() > 5:
logging.warning("--> fetch_meter_stream(): HTTP request took longer than 5 seconds: %s seconds" % response.elapsed.total_seconds())

for row in response.iter_lines():

if keep_running is False:
Expand Down Expand Up @@ -1330,7 +1333,7 @@ def __init__(
self._dbusservice.add_path('/ProductId', 0xFFFF)
self._dbusservice.add_path('/ProductName', productname)
self._dbusservice.add_path('/CustomName', productname)
self._dbusservice.add_path('/FirmwareVersion', '0.2.0 (20231107)')
self._dbusservice.add_path('/FirmwareVersion', '0.2.1 (20231204)')
self._dbusservice.add_path('/HardwareVersion', hardware)
self._dbusservice.add_path('/Connected', 1)

Expand Down

0 comments on commit bee13f5

Please sign in to comment.