-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
Allow to set desired grid power along with minimum and maximum battery power. #745
Conversation
@@ -2875,11 +2933,11 @@ def value_function_toumode(initval, descr, datadict): | |||
allowedtypes = HYBRID, | |||
), | |||
SofarModbusSensorEntityDescription( | |||
name = "Passive Mode Battery Power", | |||
key = "passive_mode_battery_power", |
There was a problem hiding this comment.
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.
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? |
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. |
sounds good, big thanks for your inspiriance and go to far |
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 |
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. |
The entities will still be there instead of "ro_passive_mode_lower" they will just be "passive_mode_lower" |
I see. Shall I remove the "ro_" in my PR? |
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. |
Thank you. Any other changes needed for this PR? |
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](https://private-user-images.githubusercontent.com/894150/305237502-bcf83e8f-fdf6-4631-b4d0-a36fca3f950e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MzQ2MTksIm5iZiI6MTczOTYzNDMxOSwicGF0aCI6Ii84OTQxNTAvMzA1MjM3NTAyLWJjZjgzZThmLWZkZjYtNDYzMS1iNGQwLWEzNmZjYTNmOTUwZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxNVQxNTQ1MTlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yMDdhOGUyODYxYzExNzlkMjdkODIwNThkNTlmZjNkY2U0MjNlMTBkZjFjYjg5NjM2ZjFlNWNlOTMyMzliOGYwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.BqpQIUAzegrbcGErBzhQw9Vd5GGwHyvGIVexFCWftJU)
When setting these values the registers are set accordingly:
![image](https://private-user-images.githubusercontent.com/894150/305237602-7842fbc1-0d11-4f0a-8b91-d9544522cfcb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MzQ2MTksIm5iZiI6MTczOTYzNDMxOSwicGF0aCI6Ii84OTQxNTAvMzA1MjM3NjAyLTc4NDJmYmMxLTBkMTEtNGYwYS04YjkxLWQ5NTQ0NTIyY2ZjYi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxNVQxNTQ1MTlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mNDBlZGI3ZDYzNDFiZTdmOWY1NjU0NWMyODkxOTc3NGRjNGVmNmE4OWUyODBkYTY4NzhjOGFmZjhjYjc0Y2MyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.70S_Up0COuxvy0jAj_8CKzTEIB8drHYAODxYLXNTd78)
Now this allows finer control like this:
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
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](https://private-user-images.githubusercontent.com/894150/305219675-257ca076-4093-495c-b3bd-ea21ababba9c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MzQ2MTksIm5iZiI6MTczOTYzNDMxOSwicGF0aCI6Ii84OTQxNTAvMzA1MjE5Njc1LTI1N2NhMDc2LTQwOTMtNDk1Yy1iM2JkLWVhMjFhYmFiYmE5Yy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxNVQxNTQ1MTlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04ZDNmNjc2ZWRiYjYyZTQ1YzhiMjhjNzI5MzQ1YWIzODBjODNmMjg3NDkxM2U1MzgxMzhiNjY1NmJiN2QwN2M2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.Z2IqclQIXIXtG2HPGxtaug9pQShgH72czWD35RpOoLQ)
UI is showing the new controls already:
![image](https://private-user-images.githubusercontent.com/894150/305219889-4384d878-0171-4d3a-99cb-2c2eb50902dd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MzQ2MTksIm5iZiI6MTczOTYzNDMxOSwicGF0aCI6Ii84OTQxNTAvMzA1MjE5ODg5LTQzODRkODc4LTAxNzEtNGQzYS05OWNiLTJjMmViNTA5MDJkZC5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjE1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxNVQxNTQ1MTlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hZWQ2MDYxNzcyYTExMGVhNThkMmJhNTg4ZTQ4M2MzODFhZmY5NTY1Y2EzZGEyYzFmMTE1ZGJmYjk0YTc5NGYwJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.drx2VG_WFEisJXZhWijpaDaK4MtlCXkVt8BNR2sEHzA)