githubDante / deye-controller

DEYE Hybrid inverters library
MIT License
31 stars 5 forks source link

Generator Port Values and settings #14

Closed markusdunckert closed 1 month ago

markusdunckert commented 1 month ago

Hi,

I cannot access the GeneratorTotalPower in the Class HoldingRegisters. Could you please explain how to access the values here? Thanks in advance

githubDante commented 1 month ago

Hi,

Try with this

>>> from deye_controller import HoldingRegisters 
>>> from pysolarmanv5 import PySolarmanV5

>>> gen_total_p = HoldingRegisters.GeneratorTotalPower
>>> sol = PySolarmanV5('192.168.100.138', 27123456789, auto_reconnect=True)
>>> gen_total_p.value = sol.read_holding_registers(gen_total_p.address, gen_total_p.len)[0]
>>> gen_total_p.format()
0
githubDante commented 1 month ago

With #15 it should be even easier

>>> from deye_controller import HoldingRegisters 
>>> from deye_controller.utils import monkey_patch
>>> from pysolarmanv5 import PySolarmanV5

>>> monkey_patch()
>>> gen_total_p = HoldingRegisters.GeneratorTotalPower
>>> sol = PySolarmanV5('192.168.100.138', 27123456789, auto_reconnect=True)
>>> sol.read_holding_registers(gen_total_p)
>>> gen_total_p.format()
0
markusdunckert commented 1 month ago

Thank you for the advice, but unfortunately it doesnt work. The first one breaks with: gen_total_p = HoldingRegisters.GeneratorTotalPower AttributeError: type object 'HoldingRegisters' has no attribute 'GeneratorTotalPower'

The second example: there is no function monkey_patch.

Any ideas?

githubDante commented 1 month ago

Hi,

Ensure that you are at the latest version 0.1.5 (pip3 install --upgrade deye-conroller). The grenerator related register were added after 0.1.4

As for the monkey_patch call it is not even merged in the main branch yet. It will be available in the next PyPI release.

markusdunckert commented 1 month ago

great, that was the solution!