Skip to content

Commit

Permalink
Merge pull request lumapu#238 from chehrlic/chris_vz
Browse files Browse the repository at this point in the history
RPI: use a requests seesion for the volkszaehler plugin...
  • Loading branch information
aschiffler authored Sep 4, 2022
2 parents 0148108 + ddbb35e commit d52e38d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion tools/rpi/hoymiles/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def poll_inverter(inverter, retries=4):
# Handle the response data if any
if response:
c_datetime = datetime.now()
print(f'{c_datetime} Payload: ' + hoymiles.hexify_payload(response))
if hoymiles.HOYMILES_DEBUG_LOGGING:
print(f'{c_datetime} Payload: ' + hoymiles.hexify_payload(response))
decoder = hoymiles.ResponseDecoder(response,
request=com.request,
inverter_ser=inverter_ser
Expand Down
3 changes: 2 additions & 1 deletion tools/rpi/hoymiles/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def __init__(self, config, **params):
"""
super().__init__(**params)

self.session = requests.Session()
self.baseurl = config.get('url', 'http://localhost/middleware/')
self.channels = dict()
for channel in config.get('channels', []):
Expand Down Expand Up @@ -271,7 +272,7 @@ def try_publish(self, ts, ctype, value):
uid = self.channels[ctype]
url = f'{self.baseurl}/data/{uid}.json?operation=add&ts={ts}&value={value}'
try:
r = requests.get(url)
r = self.session.get(url)
if r.status_code != 200:
raise ValueError('Could not send request (%s)' % url)
except ConnectionError as e:
Expand Down

0 comments on commit d52e38d

Please sign in to comment.