Code Monkey home page Code Monkey logo

epevermodbus's Introduction

Hi there ๐Ÿ‘‹

epevermodbus's People

Contributors

alexverrico avatar hrford avatar rafael2k avatar rosswarren avatar smithchart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

epevermodbus's Issues

Add switches to command line tool (filters, load control, etc.)

As the API might be starting to show all the information the API has to offer, I suggest we default to showing everything but could limit to certain sections by using switches.

I'm familiar with argparse and would like to implement this.
examples might include
--realtimedata, --batteryparameters or --load off

This would allow users without python knowledge to start using the API directly on the CLI.
It would also allow the command line tool to become the "demo" for your API.

Automated testing / test harness

It would be nice to have some automated tests, so that the library can be quickly regression tested against a fake modbus interface when changes are made. This would reduce the time to develop new features as the library gets more complex.

syntax error on raspberry pi 4

Everything installed: pip install epevermodbus

python --version

Python 3.7.3
Running gives:
epevermodbus -h
Traceback (most recent call last):
File "/usr/local/bin/epevermodbus", line 6, in
from epevermodbus.command_line import main
File "/usr/local/lib/python2.7/dist-packages/epevermodbus/command_line.py", line 18
print(f"Solar voltage: {controller.get_solar_voltage()}V")
^
SyntaxError: invalid syntax
On raspberry Phyton 2 and 3 are installed. How do I install epevermodbus on python3?

Write battery parameters

Hey, really enjoyed finding your project in amongst a few others, (from a bit too scriptey, to a bit too objectey.)
I really enjoy the abstraction you've done and the command line utility really shows off how your implementation is straight forward.

In the readme, it's stated "Write battery parameters this feature is a work in progress".

I have a Tracer 2206AN and have already written my values for a 12V 100Ah battery. It seems I chose values close to those in your example.

I've raised this issue to cover adding that functionality. Would you mind if I added that functionality and created a PR for you?

Incorrect Battery Type

BUG report:

Battery Parameters:
Rated charging current: 40A
Rated load current: 40A
Battery real rated voltage: 24V
Traceback (most recent call last):
File "/home/kali/.local/bin/epevermodbus", line 8, in
sys.exit(main())
File "/home/kali/.local/lib/python3.10/site-packages/epevermodbus/command_line.py", line 60, in main
print(f"Battery type: {controller.get_battery_type()}")
File "/home/kali/.local/lib/python3.10/site-packages/epevermodbus/driver.py", line 271, in get_battery_type
return {0: "USER_DEFINED", 1: "SEALED", 2: "GEL", 3: "FLOODED"}[
KeyError: 0.02

In file driver.py, line 272 should be:
self.retriable_read_register(0x9000, 0, 3)
instead of
self.retriable_read_register(0x9000, 2, 3)

regards
Pavel

Fix command-line tool solar power call, possibly use native power readings, add battery power.

  1. The "solar power" line shows the solar current but should be:
    print(f"Solar power: {controller.get_solar_power()}W")
  2. Is there any reason why the library makes two calls, one for voltage and one for current, when the power value is available as one call to the device? (Edit: Actually, it's two calls, or maybe even one call 0x10 for H & L, but I guess would be more accurate as the values for V and I would be calculated at the same time!?)
  3. I'd like to add a power call for the battery (0x3106 and 0x3107), as there's already functions for solar (0x3102/3) and load (0x310E/F) power.
  4. And a question about battery current. In another library, they use 0x3105 for current, but you use 0x331B/C. I'll try to get my head around this and see if we can make a two-register call using func 0x10.

This issue is for points 1 to 3

Read / Set controller clock

I've implemented functions to read/set the clock of the charge controller to get valid results for the daily/weekly statistics.

  def get_clock(self):
  
    def split_short(val):
      hext = '{0:04x}'.format(val)
      ha = hext[:-2]
      hb = hext[-2:]
      return (int(ha,16), int(hb,16))
  
    r = self.retriable_read_registers(0x9013,3,3)
    min, sec = split_short(r[0])
    day, hour = split_short(r[1])
    year, mon = split_short(r[2])
    year += 2000

    curDate = datetime(year,mon,day,hour,min,sec)
    return curDate
 def set_clock(self, time):
  
    def gen_hex(a, b):
      ha = '{0:02x}'.format(a)
      hb = '{0:02x}'.format(b)
      return ha + hb
  
    r3 = int(gen_hex(time.year-2000,time.month), 16)
    r2 = int(gen_hex(time.day,time.hour), 16)
    r1 = int(gen_hex(time.minute,time.second), 16)
    self.write_registers(0x9013,[r1, r2, r3])

Can you please include these 2 functions.

I did not create a pull request since I'm not sure if this meets your requirements for clean code.

Testing local changes

There should be a way to test local changes without having to publish to PyPI or making temporary changes to the code.
Currently, the import defaults to the installed version of the library.

Unsupported battery type?

First, thank you very much for creating and maintaining this tool; it's brilliant!

I get the following error on the latest release of epevermodbus:

Traceback (most recent call last):
  File "/home/alexandro/.local/bin/epevermodbus", line 8, in <module>
    sys.exit(main())
  File "/home/alexandro/.local/lib/python3.9/site-packages/epevermodbus/command_line.py", line 60, in main
    print(f"Battery type: {controller.get_battery_type()}")
  File "/home/alexandro/.local/lib/python3.9/site-packages/epevermodbus/driver.py", line 271, in get_battery_type
    return {0: "USER_DEFINED", 1: "SEALED", 2: "GEL", 3: "FLOODED"}[
KeyError: 4

My controller should be set to LiFePO4. The manual shows more types than just sealed/gel/flooded/user:
https://www.epever.com/wp-content/uploads/2021/05/Tracer-AN50-100A-Manual-EN-V3.1.pdf

image

However, it's not clear to me how you figure out which numerical values correspond to which types. Is it trial and error?

write other parameters

Hi

I like to not only read the temperature_compensation_coefficient I want to write it as well.
Is it possible?

Regards
Christer

Are the retries necessary?

I added automatic retries because I get intermittent failures when communicating with my charge controller via my Raspberry PI Zero. I am not sure if these failures are expected or if it is a specific issue with my setup.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.