Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to set desired grid power along with minimum and maximum battery power. #745

Merged
merged 3 commits into from
Feb 16, 2024
Merged

Allow to set desired grid power along with minimum and maximum battery power. #745

merged 3 commits into from
Feb 16, 2024

Conversation

cschlipf
Copy link
Contributor

@cschlipf cschlipf commented Feb 15, 2024

PREVIOUS BEHAVIOR

When setting battery power, desired grid was always set to 0 and battery min and max charge to the value of passive_mode_battery_power. This does not allow the full flexibility of the passive mode

CHANGE

With this addition users can set desired grid power, minimum charge/discharge and maximum charge/discharge:
image

When setting these values the registers are set accordingly:
image

Now this allows finer control like this:

  • Passive Mode Grid Power: 0
  • Passive Mode Max Battery Power: 2500
  • Passive Mode Min Battery Power: -5000

Try to keep grid power at zero like in self use, but limit charging of the battery to 2.5kW, while still allowing discharging to 5 kW

  • Passive Mode Grid Power: 2000
  • Passive Mode Max Battery Power: 5000
  • Passive Mode Min Battery Power: 0

Force charging the battery with 2 kW while preventing discharging. If sun delivers more allow to charge with up to 5kW.

OUTDATED

I am trying to modify plugin_sofar.py to set upper and lower limits for battery charge/discharge in passive mode. So far it is not working yet. Values do not get committed. Not sure what I am doing wrong here as a total novice.

Registers I am trying to write are the green registers here:
image

UI is showing the new controls already:
image

@@ -2875,11 +2933,11 @@ def value_function_toumode(initval, descr, datadict):
allowedtypes = HYBRID,
),
SofarModbusSensorEntityDescription(
name = "Passive Mode Battery Power",
key = "passive_mode_battery_power",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that was a mistake in the existing code? The register is actually not for the passive_mode_battery_power that is used above already for 0x1187, but is the lower limit of the battery power.

@cschlipf
Copy link
Contributor Author

cschlipf commented Feb 15, 2024

One possible reason: Registers needs to be written together in one batch with 1187. One button to commit all values together would be better anyway. I assume I did not understand the value_function_passivemode correctly. Maybe this is doing this already if I pass passive_mode_battery_power as first, passive_mode_battery_power_min as second and passive_mode_battery_power_max as third parameter like this?

def value_function_passivemode_min(initval, descr, datadict):
    return [ (REGISTER_S32, datadict.get('passive_mode_battery_power', 0))
            (REGISTER_S32, datadict.get('passive_mode_battery_power_min', 0)), 
            (REGISTER_S32, datadict.get('passive_mode_battery_power_max', 0)),
           ]

Right now I am seeing that ro_passive_mode_lower and ro_passive_mode_upper are set to the value I enter to passive_mode_battery_power, but ro_passive_mode_gdes stays on 0?

@cschlipf
Copy link
Contributor Author

Tried what I suspected and now it is working!

So with this change I can now set the expected grid consumption and battery discharge and battery charge separately.

@cschlipf cschlipf marked this pull request as ready for review February 15, 2024 22:13
@cschlipf cschlipf changed the title Trying to set values for upper and lower battery power limits Allow to set desired grid power along with minimum and maximum battery power. Feb 15, 2024
@sahomm
Copy link
Contributor

sahomm commented Feb 16, 2024

sounds good, big thanks for your inspiriance and go to far

@wills106
Copy link
Owner

Will probably need to update https://homeassistant-solax-modbus.readthedocs.io/en/latest/sofar-operation-modes/ to explain how to use this mode.

I forgot there is still "ro_" entities in plugin_sofar.py

I'll need to couple them back up as per Solis mentioned
https://github.com/wills106/homeassistant-solax-modbus/releases/tag/2023.05.2
https://homeassistant-solax-modbus.readthedocs.io/en/latest/solis-operation-modes/#timed-charge-discharge

@cschlipf
Copy link
Contributor Author

These ro_ entities are great to check whether the values have been written or check the actual current state in an automation.

Yes, Documentation needs to be updated. I plan to do that, but before I am doing this I would like to add two more entities for controling the passive mode timeout (also very important for reliable passive mode) and I would also like to suggest some renamings. Will post a new discussion on this soon.

I believe then we rather need a more complete documentation on all the entities of Sofar as there are so many specialities to consider here.

@wills106
Copy link
Owner

The entities will still be there instead of "ro_passive_mode_lower" they will just be "passive_mode_lower"
It allows the Inverter to feedback to the Integration if you make a change on the Inverter or Cloud app.

@cschlipf
Copy link
Contributor Author

I see. Shall I remove the "ro_" in my PR?

@wills106
Copy link
Owner

Leave them in for now as I'll need to add in the supporting parts and update the value_function's.

So I'll update it all in one go.

@cschlipf
Copy link
Contributor Author

Thank you. Any other changes needed for this PR?

@wills106 wills106 merged commit 51a6ad9 into wills106:main Feb 16, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants