GithubHelp home page GithubHelp logo

Comments (10)

tcoenraad avatar tcoenraad commented on July 17, 2024 1

I do have an SAJ inverter so I can help you test any implementation when needed.

from home-assistant-saj-modbus.

OmegaAlfa7 avatar OmegaAlfa7 commented on July 17, 2024 1

I will look in to this. Unfortunately I do not have an SAJ inverter anymore, so it will take some time to get this done. Maybe someone else can help adding this?

I second this request, because with dynamic prices, a controleable power slider / export limiter would be a super nice feature to have!

from home-assistant-saj-modbus.

HindrikDeelstra avatar HindrikDeelstra commented on July 17, 2024 1

After spending several hours to try to get anything working, it looks like I finally made some progress! I am not a programmer, and I am largely unfamiliar with Python and Modbus in general, but I think I now know how to write a value into the "Power Limit" register of the SAJ R5 (Zonneplan One) inverter.

The register at address 0x801F (or 32799 in decimal notation) accepts an integer value, and the documentation comments it is a "percentage". The docs omit the "Scale factor", but it seems this is "-1", meaning that the value in the register is to be divided by 10 to get the actual percentage.

Eg.: a register value of "1000" means "100%", and a register value of "500" means "50%", etc.

This percentage is of the maximum rated power output of the inverter. Mine is a 4 kW version, so a percentage of 25% corresponds to a 1 kW output limit for my inverter.

One could issue the following to set the register value to (desired power percentage * 10):

  • call Modbus command "write_registers" (plural, the singular command "write_register" results in an "IllegalFunction" error),
  • pass the required value of (percentage * 10) as an integer, as the single element of the "value" array.

I've tested this using "pymodbus.console" in my HA docker container. From this cli, one can simply omit anything but the first value from the "values" parameter, and this works (setting power limit to 50% of maximum in the below example):

client.write_registers address 0x801F values 500 slave 1

Calling the "modbus.write_register" (singular) service_call from within HomeAssistant in an automation for instance, does require the "value" to be an array (or python list object). This causes the code to issue a "write_registers" call, whereas it would issue a "write_register" call if there is only a single value. It may also contain just the one value, but it must be formatted as an array/list.

This is my currently working automation "action":

- service: modbus.write_register
data:
hub: saj_solar_inverter
address: 32799
slave: 1
value:
- '{{ states(''input_number.solar_power_output_wanted'')|int * 10 }}'

The "hub" value is the self-defined name in the "modbus:" section of HA's configuration.yaml (or the corresponding config-file loaded there).

The "input_number.solar_power_output_wanted" is a helper I created, that changes its value based on triggers for the energy price of the current hour...

Any changes to this input_number helper then trigger the abovementioned action/service call, limiting the export power to the correct percentage...

I hope this helps!

from home-assistant-saj-modbus.

wimb0 avatar wimb0 commented on July 17, 2024

I will look in to this.
Unfortunately I do not have an SAJ inverter anymore, so it will take some time to get this done.
Maybe someone else can help adding this?

from home-assistant-saj-modbus.

HindrikDeelstra avatar HindrikDeelstra commented on July 17, 2024

@wimb0 to recap for a possible implementation into the repo: the Modbus function to write to the 0x801F register needs to be the "write_registers"(plural) call, with the value(s) being an array/list containing 1 element, that has a value of (percentage * 10)|int ;)

from home-assistant-saj-modbus.

mvn23 avatar mvn23 commented on July 17, 2024

I added the number entity and filed a PR. Please let me know if anyone has found a way to retrieve the current value from the inverter and I'll update the code.

from home-assistant-saj-modbus.

HindrikDeelstra avatar HindrikDeelstra commented on July 17, 2024

I added the number entity and filed a PR. Please let me know if anyone has found a way to retrieve the current value from the inverter and I'll update the code.

I have not been able to find a way to read the current setting from the register. The docs mention it's a "Write Only" type register, so I'm assuming the manufacturer did not intend it to be retrievable, only writable.

I have tested your code (briefly!), and it seems to be doing exactly as intended! The slider allows for an export limit, and the numbers very nicely match the expected output limits (i.e. setting the slider to 10% adjusts the actual power output of my 4 kW inverter to roughly 400 W).

So, at first glance and quick test, your commit(s) seem to be doing precisely what was requested ;)

from home-assistant-saj-modbus.

wimb0 avatar wimb0 commented on July 17, 2024

@mvn23 Thanks for the work on implementing this.
I will merge your pull request and release it as beta version.
If anyone wants to test version v2.0.0-beta, and let me know if it all works fine, I will make a final release.

from home-assistant-saj-modbus.

HindrikDeelstra avatar HindrikDeelstra commented on July 17, 2024

@wimb0 I've checked out the 2.0.0-beta version, and restarted HomeAssistant.

Everything seems to be working just fine! All sensors and their states remain intact and are updated every scan_interval. The power limit slider is present under a "Controls" section of the device, which seems appropriate. It also still works of course ;)

I see no immediate and obvious problems/issues with this release, and no warnings or errors in the logs when (re)loading this integration.

TL;DR: All seems well!

from home-assistant-saj-modbus.

tcoenraad avatar tcoenraad commented on July 17, 2024

Works on our installation too 🥳

from home-assistant-saj-modbus.

Related Issues (20)

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.