Browse Source

Merge pull request #585 from PaeserBastelstube/main

RPi: transport attributes to ResponseDecoder-Class
pull/587/head
Lukas Pusch 2 years ago
committed by GitHub
parent
commit
a09b9c25ba
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 34
      tools/rpi/ahoy.service
  2. 8
      tools/rpi/hoymiles/__init__.py
  3. 7
      tools/rpi/hoymiles/__main__.py

34
tools/rpi/ahoy.service

@ -0,0 +1,34 @@
######################################################################
# systemd.service configuration for ahoy (lumapu)
# users can modify the lines:
# - Description
# - ExecStart (for example: name of config file)
# - WorkingDirectory
# To change other configs, please consult systemd documentation
#
# to activate this service, create a link like:
# $ mkdir -p $HOME/.config/systemd/user && ln -sf $(pwd)/ahoy/tools/rpi/ahoy.service -t $HOME/.config/systemd/user
# $ systemctl --user status ahoy
# $ systemctl --user enable ahoy
# $ systemctl --user start ahoy
#
# 2023.01 <PaeserBastelstube>
######################################################################
[Unit]
Description=ahoy (lumapu) as Service
After=network.target local-fs.target time-sync.target
[Service]
ExecStart=/usr/bin/env python3 -um hoymiles --log-transactions --verbose --config ahoy.yml
RestartSec=10
Restart=on-failure
Type=simple
# WorkingDirectory must be an absolute path - not relative path
WorkingDirectory=/home/pi/ahoy/tools/rpi
EnvironmentFile=/etc/environment
[Install]
WantedBy=default.target

8
tools/rpi/hoymiles/__init__.py

@ -144,6 +144,9 @@ class ResponseDecoder(ResponseDecoderFactory):
def __init__(self, response, **params):
"""Initialize ResponseDecoder"""
ResponseDecoderFactory.__init__(self, response, **params)
self.inv_name=params.get('inverter_name', None)
self.dtu_ser=params.get('dtu_ser', None)
self.strings=params.get('strings', None)
def decode(self):
"""
@ -164,7 +167,10 @@ class ResponseDecoder(ResponseDecoderFactory):
return device(self.response,
time_rx=self.time_rx,
inverter_ser=self.inverter_ser
inverter_ser=self.inverter_ser,
inverter_name=self.inv_name,
dtu_ser=self.dtu_ser,
strings=self.strings
)
class InverterPacketFragment:

7
tools/rpi/hoymiles/__main__.py

@ -118,6 +118,8 @@ def poll_inverter(inverter, dtu_ser, do_init, retries):
:type retries: int
"""
inverter_ser = inverter.get('serial')
inverter_name = inverter.get('name')
inverter_strings = inverter.get('strings')
# Queue at least status data request
inv_str = str(inverter_ser)
@ -161,7 +163,10 @@ def poll_inverter(inverter, dtu_ser, do_init, retries):
logging.debug(f'{c_datetime} Payload: ' + hoymiles.hexify_payload(response))
decoder = hoymiles.ResponseDecoder(response,
request=com.request,
inverter_ser=inverter_ser
inverter_ser=inverter_ser,
inverter_name=inverter_name,
dtu_ser=dtu_ser,
strings=inverter_strings
)
result = decoder.decode()
if isinstance(result, hoymiles.decoders.StatusResponse):

Loading…
Cancel
Save