batpred
batpred copied to clipboard
Mismatch between Predbat energy control switch states for "solis_new" and Solis inverters using plugin_solis_fb00 in SolaxModbus ..
Describe the bug
The fb00 plugin exposes the following options for the energy_control_swtich:
option_dict={
1: "Self-Use - No Grid Charging",
17: "Backup/Reserve - No Grid Charging",
33: "Self-Use",
37: "Off-Grid Mode",
41: "Battery Awaken",
49: "Backup/Reserve",
64: "Feed-in priority - No Grid Charging",
96: "Feed-in priority",
},
This causes issues with Predbat which in "hold" mode, which gas a different disctionary in config.py
New modes are from 2024.03.2 controlled with solax_modbus_new in apps.yaml
SOLAX_SOLIS_MODES_NEW = { "Self-Use - No Grid Charging": 1, "Timed Charge/Discharge - No Grid Charging": 3, "Backup/Reserve - No Grid Charging": 17, "Self-Use - No Timed Charge/Discharge": 33, "Self-Use": 35, "Off-Grid Mode": 37, "Battery Awaken": 41, "Battery Awaken + Timed Charge/Discharge": 43, "Backup/Reserve - No Timed Charge/Discharge": 49, "Backup/Reserve": 51, "Feed-in priority - No Grid Charging": 64, "Feed-in priority - No Timed Charge/Discharge": 96, "Feed-in priority": 98, }
Expected behaviour A clear and concise description of what you expected to happen.
Predbat version
xxxx
Environment details
- Inverter and battery setup
- Standard HAOS installer or Docker
- Anything else?
Screenshots If applicable, add screenshots to help explain your problem. The most useful ones can be your battery chart, the Predbat HTML plan and your current settings in HA.
Log file Can you capture a log file from the time of the issue, debug mode is not normally required.
Predbat debug yaml file Enable debug mode and let Predbat run for one cycle. Look in the 'debug' directory under the Predbat add-on and take the .yaml file for the time period in question. Rename the predbat_debug_XX_XX_XX.yaml to predbat_debug_XX_XX_XX.yaml.txt and upload it to Github. This will allow your plan to be reproduced and also stores all your settings for review.
This appears to be all back-to-front, conceptually.
Rather than picking a magic number out of thin air like 33 or 35 and hard coding it then setting it in the inverter and checking if the text value then matches the expected value ... should you not be using the dict to map charge/discharge to numbers to predbat desired states ... sending that number and checking if that number was set?
What the code currently does is set "33" and then check what that is textually and if it is not what it expected, throw an error.
A better approach would be to know what you want to do eg set "Self-Use" ... use whichever dict is appropriate for the currently connected inverter type to look up the magic number for that .. eg "35", set 35, check 35 is set, be happy. Whatever text value Solax then happens to think that is (Such as "Self Use, but no grid charging on Sundays") is irrelvant.
ie .. Predbat should have a set of modes it needs to use , ie for the grid to battery: [Charge|Discharge|Hold] ... and for Solar destination priority: [SelfUse|Grid] or whatever states it is that Predbat has ... and then it should use the dict to map those states to Solis (or whatever) control state numbers.
I have probebly the same fault. Predbat is trying to set an option that doesn't exist. seel log below:
2025-06-30 08:46:02.520714: Inverter 0 adjust target soc for charge to 63% (48.2kWh/76.5kWh 76.5kWh) based on going from 65% -> 63% total add is -1.52kWh and this battery needs to add -1.52kWh to get to 48.2kWh 2025-06-30 08:46:02.520773: Inverter 0 Current Target SOC is 63%, already at target 2025-06-30 08:46:02.520897: Setting Solis Energy Control Switch to 33 Self-Use - No Timed Charge/Discharge from 35 Self-Use for charge False 2025-06-30 08:46:02.544468: Warn: Service call select/select_option data {'option': 'Self-Use - No Timed Charge/Discharge', 'entity_id': 'select.solis_energy_storage_control_switch'} failed with response None 2025-06-30 08:46:06.567548: Warn: Service call select/select_option data {'option': 'Self-Use - No Timed Charge/Discharge', 'entity_id': 'select.solis_energy_storage_control_switch'} failed with response None 2025-06-30 08:46:10.606761: Warn: Service call select/select_option data {'option': 'Self-Use - No Timed Charge/Discharge', 'entity_id': 'select.solis_energy_storage_control_switch'} failed with response None 2025-06-30 08:46:11.563260: number_event: input_number.predbat_forecast_plan_hours = 24.0 2025-06-30 08:46:14.642347: Warn: Service call select/select_option data {'option': 'Self-Use - No Timed Charge/Discharge', 'entity_id': 'select.solis_energy_storage_control_switch'} failed with response None 2025-06-30 08:46:18.678155: Warn: Service call select/select_option data {'option': 'Self-Use - No Timed Charge/Discharge', 'entity_id': 'select.solis_energy_storage_control_switch'} failed with response None 2025-06-30 08:46:22.714095: Warn: Service call select/select_option data {'option': 'Self-Use - No Timed Charge/Discharge', 'entity_id': 'select.solis_energy_storage_control_switch'} failed with response None 2025-06-30 08:46:26.716816: Warn: Inverter 0 Trying to write select.solis_energy_storage_control_switch to Self-Use - No Timed Charge/Discharge didn't complete got Self-Use 2025-06-30 08:46:26.768507: Warn: record_status Warn: Inverter 0 write to select.solis_energy_storage_control_switch failed 2025-06-30 08:46:30.823490: Inverter 0 write_and_poll_value: Wrote 0.0 to timed_charge_current, successfully now 0.0
if he has to discharge this also goes wrong because he doesn't give a start time or if it is in the past. This causes the discharge not to start:
2025-06-30 10:20:33.088780: Current SOC 73% is greater than Target SOC 68. Grid Discharge enabled. 2025-06-30 10:20:33.088933: Solis Energy Control Switch setting 35 Self-Use unchanged for discharge True 2025-06-30 10:20:33.089072: Inverter 0 write_and_poll_value: No write needed for timed_discharge_current: 19.7 == 19.6 fuzzy 1 2025-06-30 10:20:33.089144: Current SOC 73% is greater than Target SOC 68. Grid Discharge enabled, amp rate written to inverter.
Yep, sadly I had modified solax_modus to work with Predbat and stupidly, I forgot and did an update and overwrote it ... so my install is stuffed again.
Said it once, but I'll say it again: Predbat shoudl have no knowledge of the magic numbers 33, 35 etc and just use the descriptive terms ... mapping those descriptive terms to magic numbers to send/from to the inverter is what solax_modus has to bother itself with ... all Predbat should care is that it has a list of descriptive terms for the various modes that matches what solax_modbus will accept.
@rszemeti I wonder if the solution used in the Tesla powerwall integration would be the way to go for solax, rather than an inbuilt definition of the inverter it uses service calls made by predbat to start / stop charging, discharging etc to call an automation that then does the inverter specific transformation
See https://github.com/gcoan/batpred/blob/main/docs/inverter-setup.md
I'm absolutely certain that the less Predbat "knows" about the inverter, the better. The specific codes like 33,35,96 etc should not be exposed to Predbat, it has no reason to know what magic is needed to make the inverter go into a particular mode ... it just needs to set an option value in HA in the appropriate place and maybe press a virtual button and then it is up to the external integration (solax_modbus or whatever) to make that happen.
The only thing then required is a uniform set of textual options that represent the basic modes of Predbat and a mapping between those and the exposed textual modes of whatever inverter is connected and then it is up to the inverter integration to convert those into magic numbers or serial commands or whatever
Somewhere ... there should be a representation of what Predbat thinks are its core modes ... then potentially a mapping for how they are set in HA entities and an action that is taken ... the mapping could handle differences between the Predbat textual name for its core mode like "Charge" and the invertor integrations name for that such as ""Self-Use" .. but certrainly Predbat should not be knowing/caring if "Self-Use" unds up as invertor mode 33,35 or anything else.
On Fri, 14 Nov 2025 at 22:31, Geoffrey Coan @.***> wrote:
gcoan left a comment (springfall2008/batpred#2329) https://github.com/springfall2008/batpred/issues/2329#issuecomment-3534920781
@rszemeti https://github.com/rszemeti I wonder if the solution used in the Tesla powerwall integration would be the way to go for solax, rather than an inbuilt definition of the inverter it uses service calls made by predbat to start / stop charging, discharging etc to call an automation that then does the inverter specific transformation
See https://github.com/gcoan/batpred/blob/main/docs/inverter-setup.md
— Reply to this email directly, view it on GitHub https://github.com/springfall2008/batpred/issues/2329#issuecomment-3534920781, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALFTBRGLKPJWLLEJ4C5P2XT34ZJ3LAVCNFSM6AAAAAB4NEYQVSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKMZUHEZDANZYGE . You are receiving this because you were mentioned.Message ID: @.***>
So, what I have done that seems to have got it going again is to modify Solax Modbus to match Predbat ... around line 2122 in /homeassistant/custom_components/solax_modbus/plugin_solis_fb00.py which I use as I have an S6 hybrid, I've modified the Soalx dict to match up with predbats dict. It seems to be running without errors at the moment ..
SolisModbusSelectEntityDescription(
name="Energy Storage Control Switch",
key="energy_storage_control_switch",
register=43110,
# From predbat:
option_dict={
1: "Self-Use - No Grid Charging",
3: "Timed Charge/Discharge - No Grid Charging",
17: "Backup/Reserve - No Grid Charging",
33: "Self-Use - No Timed Charge/Discharge",
35: "Self-Use",
37: "Off-Grid Mode",
41: "Battery Awaken",
43: "Battery Awaken + Timed Charge/Discharge",
49: "Backup/Reserve - No Timed Charge/Discharge",
51: "Backup/Rserve",
64: "Feed-in priority - No Grid Charging",
96: "Feed-in priority - No Timed Charge/Discharge",
98: "Feed-in priority",
},
allowedtypes=HYBRID,
icon="mdi:dip-switch",
),
On Fri, 14 Nov 2025 at 22:31, Geoffrey Coan @.***> wrote:
gcoan left a comment (springfall2008/batpred#2329) https://github.com/springfall2008/batpred/issues/2329#issuecomment-3534920781
@rszemeti https://github.com/rszemeti I wonder if the solution used in the Tesla powerwall integration would be the way to go for solax, rather than an inbuilt definition of the inverter it uses service calls made by predbat to start / stop charging, discharging etc to call an automation that then does the inverter specific transformation
See https://github.com/gcoan/batpred/blob/main/docs/inverter-setup.md
— Reply to this email directly, view it on GitHub https://github.com/springfall2008/batpred/issues/2329#issuecomment-3534920781, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALFTBRGLKPJWLLEJ4C5P2XT34ZJ3LAVCNFSM6AAAAAB4NEYQVSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKMZUHEZDANZYGE . You are receiving this because you were mentioned.Message ID: @.***>
I'm absolutely certain that the less Predbat "knows" about the inverter, the better. The specific codes like 33,35,96 etc should not be exposed to Predbat
We can do this !
Rather than you hacking the solax modbus we can improve predbat so it works properly.
3 options:
-
We change predbat's hard coded definition of what the solax modes are. Simple change, I can do this, BUT we need to be sure that this change will work for all Solax users and not just 'newer' inverter users and we break their integration
-
We move away from the hard coded definition and instead make a custom inverter definition so predbat calls the correct modes for charge start/stop. This is what we have just done for the Solar SX4+ - see https://github.com/springfall2008/batpred/issues/259#issuecomment-3492771134 The code is currently in my fork but will be merged into base soon
-
We decouple making specific calls from apps.yaml and make the calls in a helper automation as done for Tesla Powerwall (link earlier)
It would seem #2 would be easiest, especially as it's the same modbus library.
Unfortunately, the Predbat license specifically forbids any modifications/changes, so while 2 seems logical, it is not something I could do and I needed to get going.
As I said, ideally we need to lose all the numeric mode definitions and call them by name not by number .... eg sections such as this:
if direction == "charge":
if enable:
new_switch = 35
else:
new_switch = 33
elif direction == "discharge":
if enable:
new_switch = 35
else:
new_switch = 33
else:
# ECO
new_switch = 35
should be using the textual mode descriptor, not the magic numbers, which should only be exposed on the Solax_modbus side.
On Sat, 15 Nov 2025 at 10:17, Geoffrey Coan @.***> wrote:
gcoan left a comment (springfall2008/batpred#2329) https://github.com/springfall2008/batpred/issues/2329#issuecomment-3536288225
I'm absolutely certain that the less Predbat "knows" about the inverter, the better. The specific codes like 33,35,96 etc should not be exposed to Predbat
We can do this !
Rather than you hacking the solax modbus we can improve predbat so it works properly.
3 options:
We change predbat's hard coded definition of what the solax modes are. Simple change, I can do this, BUT we need to be sure that this change will work for all Solax users and not just 'newer' inverter users and we break their integration 2.
We move away from the hard coded definition and instead make a custom inverter definition so predbat calls the correct modes for charge start/stop. This is what we have just done for the Solar SX4+ - see #259 (comment) https://github.com/springfall2008/batpred/issues/259#issuecomment-3492771134 The code is currently in my fork but will be merged into base soon 3.
We decouple making specific calls from apps.yaml and make the calls in a helper automation as done for Tesla Powerwall (link earlier)
It would seem #2 https://github.com/springfall2008/batpred/issues/2 would be easiest, especially as it's the same modbus library.
— Reply to this email directly, view it on GitHub https://github.com/springfall2008/batpred/issues/2329#issuecomment-3536288225, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALFTBRGUEXK5A46QZKBKBYL3434URAVCNFSM6AAAAAB4NEYQVSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKMZWGI4DQMRSGU . You are receiving this because you were mentioned.Message ID: @.***>
Unfortunately, the Predbat license specifically forbids any modifications/changes, so while 2 seems logical, it is not something I could do and I needed to get going
Possibly but not relevant, and wrong
I'm trying to help you and the community by pointing you to how to enhance predbat to work not only for the current Solis configuration but also for the Solis inverter type you have.
But if you need to get going and are not willing to put the effort in, then since I don't have a Solis inverter, there can't be any improvements made.
Firstly Trefor always accepts PR's to the predbat code, whether that be bug fixes or enhancements, he is very open to others supporting the open source product. Like Trefor I am doing this on my own time, but can't do everything on my own.
I can make the changes to Predbat code and documentation and PR it in, I've done it many times, and that's exactly what I have done with the support of other Solax and Powerwall owners (see links provided previously), and I could help you with the Solis inverter.
Adding new custom inverter types to override the predbat built-in inverter types is already provided for in predbat. See https://springfall2008.github.io/batpred/inverter-setup/#i-want-to-add-an-unsupported-inverter-to-predbat - that is precisely what we have done for Solax and Powerwall, and then PR'd these into the product to benefit other owners.
Balls's in your court!
Sorry, but you are wrong ... predbat is not open source, I wish it was. The licence specifically prohibits modification:
[image: image.png] Likewise, I am just trying to assist and would be very happy to contribute, as I do to many open source projects and indeed I publish a lot of what I do as open source,
Predbat could really use some refactoring and code cleanup, some of the classes are getting very large now and doing far more than any single class should, some of the methods are over 500 lines ... my mum told me any method longer than a page needed refactoring.
Getting back to Solis ... the problems start in Solax_modbus ... it would be better if Solax_modbus presented a uniform interface as far as possible for all the inverters, then client software could be to some extent, inverter agnostic ... unfortunately even in the various Solis modules, the naming scheme for the modeswitch changes between modules, it really would be better if they were all the same.
Fixing it would of course break some existing implementations, but getting everyone on the same page has long term benefits that may be worth the short term pain.
What would be really nice in Predbat is some test buttons for the various modes (export, grid import, hold charge, house from battery) so you could test the integration of your inverter however it is hooked up and the inverter.py interface ... this would avoid having to make modifications to HA and then wait for the various states of the plan to execute and see if any errors occur .. which in some cases can mean waiting for 24 hours ...
On Sat, 15 Nov 2025 at 15:46, Geoffrey Coan @.***> wrote:
gcoan left a comment (springfall2008/batpred#2329) https://github.com/springfall2008/batpred/issues/2329#issuecomment-3536608429
Unfortunately, the Predbat license specifically forbids any modifications/changes, so while 2 seems logical, it is not something I could do and I needed to get going
Possibly but not relevant, and wrong
I'm trying to help you and the community by pointing you to how to enhance predbat to work not only for the current Solis configuration but also for the Solis inverter type you have.
But if you need to get going and are not willing to put the effort in, then since I don't have a Solis inverter, there can't be any improvements made.
Firstly Trefor always accepts PR's to the predbat code, whether that be bug fixes or enhancements, he is very open to others supporting the open source product. Like Trefor I am doing this on my own time, but can't do everything on my own.
I can make the changes to Predbat code and documentation and PR it in, I've done it many times, and that's exactly what I have done with the support of other Solax and Powerwall owners (see links provided previously), and I could help you with the Solis inverter.
Adding new custom inverter types to override the predbat built-in inverter types is already provided for in predbat. See https://springfall2008.github.io/batpred/inverter-setup/#i-want-to-add-an-unsupported-inverter-to-predbat
- that is precisely what we have done for Solax and Powerwall, and then PR'd these into the product to benefit other owners.
Balls's in your court!
— Reply to this email directly, view it on GitHub https://github.com/springfall2008/batpred/issues/2329#issuecomment-3536608429, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALFTBRHEHOEV4WB7XQUYK7D345DDPAVCNFSM6AAAAAB4NEYQVSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKMZWGYYDQNBSHE . You are receiving this because you were mentioned.Message ID: @.***>
OK, you are right, predbat is not open source, Trefor still retains the rights to the software https://github.com/springfall2008/batpred/blob/main/License.md This is probably because there is a predbat.com commercial version.
However, point 8 talks about contributions to the software via Github. To contribute you have to modify and extend the existing software, which contradicts point 2.
So it's in conflict.
All I can say is that I have made a number of contributions to Predbat because I find it useful and I am happy to contribute to further it. Most of the documentation I have written/rewritten, and I've done code changes for other things as have others, just look at the release history to see other contributors.
On facebook Trefor has confirmed that the open source (his words) version of Predbat will continue.
If you feel the code could be refactored, and adding test buttons is a good idea, please contribute.
I have suggested how we can use the provided mechanisms to get the Solis inverter working with Predbat without having to change the modbus implementation. See #259 for similar discussion and changes made for Solax
Predbat now has a new GS_fb00 inverter type for use with the solis_fb00 profile in Solax Modbus. There are a number of new apps.yaml configuration options available to enable charging and discharging to specific levels with the new Solax modbus firmware.
See Predbat release 8.27.27 for details and updated inverter setup guide https://github.com/springfall2008/batpred/releases/tag/v8.27.27
Awesome, thanks for the update!
On Sat, 22 Nov 2025 at 20:37, Geoffrey Coan @.***> wrote:
Closed #2329 https://github.com/springfall2008/batpred/issues/2329 as completed.
— Reply to this email directly, view it on GitHub https://github.com/springfall2008/batpred/issues/2329#event-21116990993, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALFTBRH5FRA6TBHYEZEU5R336DCSDAVCNFSM6AAAAAB4NEYQVSVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMRRGEYTMOJZGA4TSMY . You are receiving this because you were mentioned.Message ID: @.***>
Thanks both :)
I probably should clarify the license agreement, it's fine to create your own local versions and contributions are welcomed. I just don't want someone else distributing a modified version for their own project, instead it's better if they contribute to a single code base.
Would it not be a good idea to change the license terms to reflect that? As it stands, it specifically prohibits any modifications.
On Sun, 23 Nov 2025 at 09:44, Trefor Southwell @.***> wrote:
springfall2008 left a comment (springfall2008/batpred#2329) https://github.com/springfall2008/batpred/issues/2329#issuecomment-3567712499
Thanks both :)
I probably should clarify the license agreement, it's fine to create your own local versions and contributions are welcomed. I just don't want someone else distributing a modified version for their own project, instead it's better if they contribute to a single code base.
— Reply to this email directly, view it on GitHub https://github.com/springfall2008/batpred/issues/2329#issuecomment-3567712499, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALFTBRDHRCR73O3ZOMMOHKD36F6XDAVCNFSM6AAAAAB4NEYQVSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKNRXG4YTENBZHE . You are receiving this because you were mentioned.Message ID: @.***>
Would it not be a good idea to change the license terms to reflect that?
As it stands, it specifically prohibits any modifications.
Already done as part of the latest release
That looks a lot better, thank you.
My other concern was that the author could, on a whim, simply terminate use and I see that has been addressed also.
I shall attempt to repay the changes by contributing something useful :)
On Mon, 24 Nov 2025 at 15:29, Geoffrey Coan @.***> wrote:
gcoan left a comment (springfall2008/batpred#2329) https://github.com/springfall2008/batpred/issues/2329#issuecomment-3571388816
Would it not be a good idea to change the license terms to reflect that?
As it stands, it specifically prohibits any modifications.
Already done as part of the latest release
— Reply to this email directly, view it on GitHub https://github.com/springfall2008/batpred/issues/2329#issuecomment-3571388816, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALFTBRHDOMC5YX4DU3YMQ4D36MP3ZAVCNFSM6AAAAAB4NEYQVSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTKNZRGM4DQOBRGY . You are receiving this because you were mentioned.Message ID: @.***>