First, thank a lot for sun2000_modbus.
I am using it with Python 3.9, so in sun2000_modbus/datatypes.py I had to replace the match/case/case... by if/elif/elif.../else in decode().
I also found very convenient to modify sun2000_modbus/inverter.py in order to benefit from the locale formatting in read_formatted(). To achieve this goal, I modified it in the following way:
def read_formatted(self, register, use_locale=False): # added the argument use_locale
# (...)
if register.value.unit is not None:
if use_locale:
return f'{value:n} {register.value.unit}' # added the :n to format according to the locale's thousand separator, decimal sign
else:
return f'{value} {register.value.unit}'
# (...)
Maybe you could consider worth to include these modifications in your sources.
Hi @hchiper, thanks for your contribution.
What do you think about creating a Pull Request containing your changes?
After a review I could simply merge it and create a new release.
First, thank a lot for sun2000_modbus. I am using it with Python 3.9, so in sun2000_modbus/datatypes.py I had to replace the match/case/case... by if/elif/elif.../else in decode(). I also found very convenient to modify sun2000_modbus/inverter.py in order to benefit from the locale formatting in read_formatted(). To achieve this goal, I modified it in the following way:
Maybe you could consider worth to include these modifications in your sources.