Skip to content

Commit

Permalink
Merge pull request #585 from PaeserBastelstube/main
Browse files Browse the repository at this point in the history
RPi: transport attributes to ResponseDecoder-Class
  • Loading branch information
lumapu authored Jan 13, 2023
2 parents b53018f + eb0f3b3 commit a09b9c2
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
34 changes: 34 additions & 0 deletions tools/rpi/ahoy.service
Original file line number Diff line number Diff line change
@@ -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 changes: 7 additions & 1 deletion tools/rpi/hoymiles/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand All @@ -164,7 +167,10 @@ def decode(self):

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:
Expand Down
7 changes: 6 additions & 1 deletion tools/rpi/hoymiles/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit a09b9c2

Please sign in to comment.