batpred
batpred copied to clipboard
Solax Inverters
Splitting this out to separate request. Please add support for Solax inverters. I use https://github.com/wills106/homeassistant-solax-modbus for HA integration (also supports other brands of inverters) As I have an X1 gen 4 inverter https://github.com/wills106/homeassistant-solax-modbus/wiki/Modbus-Power-Control-(remotecontrol-power) is the preferred method as it avoids excessive writes to eeprom
I’m working on support for Solis inverters which use the same integration. I’m hopeful that it’s nearly there but to support the Solax as well will require some additional information.
Once I have the Solis version working I’ll get in touch about Solax On 4 Nov 2023 at 21:53 +0000, Bart39 @.***>, wrote:
Splitting this out to separate request. Please add support for Solax inverters. I use https://github.com/wills106/homeassistant-solax-modbus for HA integration (also supports other brands of inverters) As I have an X1 gen 4 inverter https://github.com/wills106/homeassistant-solax-modbus/wiki/Modbus-Power-Control-(remotecontrol-power) is the preferred method as it avoids excessive writes to eeprom — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Perfect, many thanks
OK - I think I'm getting there. What I first need to add Solax is for you to try to edit the config.yaml file with the entities you would use for a Solax inverter and then to comment any that are different.
Then can you answer the following:
- What format are the charge/discharge start/end entities? (i.e to they take a string as HH:MM(Givenerrgy) or are there separate entities for Hours and Minutes (Solis)
- Once you have set the start/end time entities, do they automatically get written to the inverter or do you have to press a button?
- Do you set Power or Current during a timed Charge/Discharge?
- Can you set a Target SOC for a timed charge or discharge period?
- Does the inverter report SOC in kWh or Percent?
- Is there a specific boolean entity to toggle to enable Timed Charge and/or Discharge?
- Can you set a Reserve or Backup SOC?
- Does the inverter have a specific Mode that needs setting for Timed Charge, Discharge or Backup?
There's probably more but that would be a decent start!
Thanks, will do (I have it already working in read only mode) FYI for my inverter (X1-Hybrid Gen 4) it doesn’t really have a timed charge/discharge mode rather it allows you to change the mode between Self use, forced charge, forced discharge etc but they are instant, however the preferred method is by using “Modbus Power Control” which again is instant but gives you finer control on power limits / duration and doesn’t write to eeprom (saving limited writes) Will write this all up later today when I am back at home
OK - so I think I have BatPred working with the Solis. To get the Solax working, in addition to the above we need
Constants
- Battery capacity in kWh
- Max Battery Power
- Max Inverter Power (if different from Battery)
Entity IDs for the following sensors:
Cumulative Daily Energy
- Load today in kWh (resetting daily)
- Import today in kWh (resetting daily)
- Export today in kWh (resetting daily)
- PV Generation today in kWh (resetting daily)
Current Power / Battery Readings
- Battery power
- PV power
- Load power
- Battery SOC (%)
Others
- Inverter clock (if available) - if so let me know the format it reports in
Entity IDs for the Modbus Power Control Entities
I think I can get all of these from here but no harm to confirm them.
Sorry it took a while as work has been crazy
Constants
- Battery capacity in kWh
- 9.3
- Max Battery Power
- 6100w
- Max Inverter Power (if different from Battery)
- 6100w
Cumulative Daily Energy
- Load today in kWh (resetting daily)
- sensor.solax_today_house_load (utility helper as there is no daily total load from the inverter)
- Import today in kWh (resetting daily)
- sensor.solax_today_s_import_energy
- Export today in kWh (resetting daily)
- sensor.solax_today_s_export_energy
- PV Generation today in kWh (resetting daily)
- sensor.solax_today_s_solar_energy
Current Power / Battery Readings
- Battery power
- sensor.solax_battery_power_charge
- PV power
- sensor.solax_pv_power_total
- Load power
- sensor.solax_house_load
- Battery SOC (%)
- sensor.solax_battery_capacity
Others
- Inverter clock (if available) - if so let me know the format it reports in
- sensor.solax_rtc (disabled by default due to the constant updates)
- YYYY-MM-DD HH24:MI:SS
Entity IDs for the Modbus Power Control Entities
Set Mode select.solax_remotecontrol_power_control
-
"Disabled", -
"Enabled Power Control", -
"Enabled Grid Control", -
"Enabled Battery Control", -
"Enabled Self Use", -
"Enabled Feedin Priority" -
"Enabled No Discharge"- When remotecontrol_power_control = Enabled Power Control is chosen, the target value refers to the battery interface where positive values will cause batteries to charge, negative values will make the batteries discharge. When the target is set to zero, in the presence of PV, the PV will go to the battery, the house load will come from the grid. If in addition to selecting this mode, remote_control_import_limit is set to Zero, the house load will come from PV and battery only. Enabled Power Control is the basic mode offered by solax, it allows us to specify activepower directly, but the notion activepower may be difficult to understand, so grid control and battery control may be easier to understand.
- When remotecontrol_power_control = Enabled Grid Control is chosen, the target value refers to the grid interface where positive values mean import, negative values mean export. When using this mode, make sure that remotecontrol_import_limit is set to a high enough value so that the import target can be reached.
- When remotecontrol_power_control = Enabled Battery Control is chosen, the target value refers to the battery interface where positive values mean charge, negative values mean discharge. If target is set to zero, excess PV power will be sent to the grid.
- NEW: When remotecontrol_power_control = Enabled Self Use is chosen, the target value is ignored and the system will emulate the standard self-use mode for the specified (autorepeat) duration. This mode may not be as accurate/responsive as the builtin self_use mode.
- NEW: When remotecontrol_power_control = Enabled Feedin Priority is chosen, the target value is ignored and the system will emulate the standard feedin-priority mode for the specified (autorepeat) duration. This mode may not be as accurate/responsive as the builtin feedin_priority mode.
- NEW: When remotecontrol_power_control = Enabled No Discharge is chosen, the target value is ignored and the system will make sure that the battery does not discharge. Houseload will be provided by PV, and when PV is insufficient, from Grid.
I prefer using battery control to charge, No discharge for charge freeze, and grid control for export
Set Active Power (Watts - positive charge, negative discharge)
- number.solax_remotecontrol_active_power
Set Autorepeat duration (seconds)
- number.solax_remotecontrol_autorepeat_duration
Main button press to start the selected mode with the active power for the specified duration
- button.solax_remotecontrol_trigger
That’s fine I’ve been busy with other stuff anyway.
Will try to have a look at this over the next week On 12 Nov 2023 at 14:22 +0000, Bart39 @.***>, wrote:
Sorry it took a while as work has been crazy Constants
• Battery capacity in kWh • 9.3 • Max Battery Power • 6100w • Max Inverter Power (if different from Battery) • 6100w
Cumulative Daily Energy
• Load today in kWh (resetting daily) • sensor.solax_today_house_load (utility helper as there is no daily total load from the inverter) • Import today in kWh (resetting daily) • sensor.solax_today_s_import_energy • Export today in kWh (resetting daily) • sensor.solax_today_s_export_energy • PV Generation today in kWh (resetting daily) • sensor.solax_today_s_solar_energy
Current Power / Battery Readings
• Battery power • sensor.solax_battery_power_charge • PV power • sensor.solax_pv_power_total • Load power • sensor.solax_house_load • Battery SOC (%) • sensor.solax_battery_capacity
Others
• Inverter clock (if available) - if so let me know the format it reports in • sensor.solax_rtc (disabled by default due to the constant updates) • YYYY-MM-DD HH24:MI:SS
Entity IDs for the Modbus Power Control Entities Set Mode select.solax_remotecontrol_power_control
• > "Disabled", • > "Enabled Power Control", • > "Enabled Grid Control", • > "Enabled Battery Control", • > "Enabled Self Use", • > "Enabled Feedin Priority" • > "Enabled No Discharge" • When remotecontrol_power_control = Enabled Power Control is chosen, the target value refers to the battery interface where positive values will cause batteries to charge, negative values will make the batteries discharge. When the target is set to zero, in the presence of PV, the PV will go to the battery, the house load will come from the grid. If in addition to selecting this mode, remote_control_import_limit is set to Zero, the house load will come from PV and battery only. Enabled Power Control is the basic mode offered by solax, it allows us to specify activepower directly, but the notion activepower may be difficult to understand, so grid control and battery control may be easier to understand. • When remotecontrol_power_control = Enabled Grid Control is chosen, the target value refers to the grid interface where positive values mean import, negative values mean export. When using this mode, make sure that remotecontrol_import_limit is set to a high enough value so that the import target can be reached. • When remotecontrol_power_control = Enabled Battery Control is chosen, the target value refers to the battery interface where positive values mean charge, negative values mean discharge. If target is set to zero, excess PV power will be sent to the grid. • NEW: When remotecontrol_power_control = Enabled Self Use is chosen, the target value is ignored and the system will emulate the standard self-use mode for the specified (autorepeat) duration. This mode may not be as accurate/responsive as the builtin self_use mode. • NEW: When remotecontrol_power_control = Enabled Feedin Priority is chosen, the target value is ignored and the system will emulate the standard feedin-priority mode for the specified (autorepeat) duration. This mode may not be as accurate/responsive as the builtin feedin_priority mode. • NEW: When remotecontrol_power_control = Enabled No Discharge is chosen, the target value is ignored and the system will make sure that the battery does not discharge. Houseload will be provided by PV, and when PV is insufficient, from Grid.
I prefer using battery control to charge, No discharge for charge freeze, and grid control for export Set Active Power (Watts - positive charge, negative discharge)
• number.solax_remotecontrol_active_power
Set Autorepeat duration (seconds)
• number.solax_remotecontrol_autorepeat_duration
Main button press to start the selected mode with the active power for the specified duration
• button.solax_remotecontrol_trigger
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
Hey, I have a Solax system and use the same integration to control it. Anything a layperson can do to support at this stage?
@nikotime the work so far has been pushed to main including the template configuration and the code. Maybe you can give it a try and feedback?
@nikotime the work so far has been pushed to main including the template configuration and the code. Maybe you can give it a try and feedback?
Oh wow! Just found the guide, https://github.com/springfall2008/batpred/blob/480ffc4aee0da4da49ff57af548820e215858343/docs/install.md#L3
Will give it a go this weekend :)
Sorry @Bart39 , could you please share how you set up the utility sensor for total daily load? I've been struggling and getting some wildly wrong numbers!
sensor.solax_today_house_load (utility helper as there is no daily total load from the inverter)
Sorry @Bart39 , could you please share how you set up the utility sensor for total daily load? I've been struggling and getting some wildly wrong numbers!
sensor.solax_today_house_load (utility helper as there is no daily total load from the inverter)
There's a sample template sensor in the predbat docs for calculating house load https://springfall2008.github.io/batpred/config-yml-settings/#data-from-givtcp as I have two GivEnergy inverters and as they share the load between them, I found I couldn't use the inbuilt entities.
You should be able to follow this approach for your inverter
Sorry @Bart39 , could you please share how you set up the utility sensor for total daily load? I've been struggling and getting some wildly wrong numbers!
sensor.solax_today_house_load (utility helper as there is no daily total load from the inverter)
Sorry have been busy and not spotted this i create all my sensors directly in yaml so this is what i have: First create a sensor to track the house load and then secondly add a utility helper to accumulate and reset daily:
sensor:
- platform: integration
source: sensor.solax_house_load
name: house_load_total
unit_prefix: k
round: 2
method: left
utility_meter:
solax_today_house_load:
source: sensor.house_load_total
cycle: daily
@fboundy any progress on solax modbus control ? If this is proving tricky or doesn't really fit with the other supported inverters @springfall2008 would it be worth considering exposing some sensors for the charging/discharging mode, power / Soc limits, start/end times etc ? That way it would universally support any inverter that can be controlled through HA via our own automations
Sorry but my attention has been elsewhere. Have a look at https://github.com/fboundy/pv_opt which attempts to do much the same as PredBat but with a more open API for other inverters On 19 Jan 2024 at 19:29 +0000, Bart39 @.***>, wrote:
@fboundy any progress on solax modbus control ? If this is proving tricky or doesn't really fit with the other supported inverters @springfall2008 would it be worth considering exposing some sensors for the charging/discharging mode, power / Soc limits, start/end times etc ? That way it would universally support any inverter that can be controlled through HA via our own automations — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Just got PV OPT set up with my Solax inverter and is now in read only mode :) I used the SOLIS_SOLAX_MODBUS inverter type and only had to make the following changes:
id_consumption_today: sensor.energy_house_load_today
id_grid_import_today: sensor.{device_name}_today_s_import_energy
id_grid_export_today: sensor.{device_name}_today_s_export_energy
id_battery_soc: sensor.{device_name}_battery_capacity
Big thing I guess relates to Bart's point earlier that PV OPT also seems to just work with this concept of timed_charge and discharge which doesn't exist in Solax. Need to configure the graphs etc and get more history for house load and then will look into GUI Automations to trigger changes to forced charge and forced discharge.
You rock @fboundy
@fboundy any progress on solax modbus control ? If this is proving tricky or doesn't really fit with the other supported inverters @springfall2008 would it be worth considering exposing some sensors for the charging/discharging mode, power / Soc limits, start/end times etc ? That way it would universally support any inverter that can be controlled through HA via our own automations
I did release the solax code for Predbat also so I think it’s usable but I can’t test it myself.
@fboundy any progress on solax modbus control ? If this is proving tricky or doesn't really fit with the other supported inverters @springfall2008 would it be worth considering exposing some sensors for the charging/discharging mode, power / Soc limits, start/end times etc ? That way it would universally support any inverter that can be controlled through HA via our own automations
I did release the solax code for Predbat also so I think it’s usable but I can’t test it myself.
In read only it looks to work really well, just can't use it to control the charge / discharge as solax doesn't support a timed charge /discharge
Timed charge should work as predbat has an immediate mode where it forces charging on and off at the correct times
@springfall2008 I'm so sorry would you mind linking to the released Solax code in the github which supports the immediate mode? I've been trying to find how to change the Solis integration to use 'Modbus Power Control Mode' as per https://github.com/springfall2008/batpred/blob/c1d5d7087b927a4060ac36cfbf730bfc18ecfc1c/docs/other-inverters.md but can't see that option in the ginlong_solis.yaml or anything solax specific through searching through the repo.
Sorry I’ve been a bit distracted, the code lists it as “SX4” which when enabled will use power control To start and stop charging. What we are missing is a template configuration which maybe you can help with?
I can definitely try and help with that!
Firstly I needed to create house load which was kindly provided by other clever people - I just have this in configuration.yaml:
sensor:
- platform: integration
source: sensor.solaxmodbus_house_load
name: "Energy House Load Total"
unique_id: "energy_house_load_total"
method: trapezoidal
unit_prefix: k
unit_time: h
round: 2
apps.yaml settings I used (ps my intergration is called solaxmodbus rather than solax as default):
# Max inverter power from battery
battery_rate_max:
- 5000
# Battery capacity in kWh
soc_max:
- 11.6
# Solax specific parameters (these are based on https://github.com/wills106/homeassistant-solax-modbus)
load_today:
- sensor.energy_house_load_today
import_today:
- sensor.solaxmodbus_today_s_import_energy
export_today:
- sensor.solaxmodbus_today_s_export_energy
pv_today:
- sensor.solaxmodbus_today_s_solar_energy
battery_voltage:
- sensor.solaxmodbus_battery_voltage_charge
# I manually enabled solax time in the integration but it killed the whole integration after about 30 seconds. Not recommended! I just pulled in a separate sensor for date time to avoid expected errors
# inverter_time:
# - sensor.date_time
# This is disabled by default in the Solax integration so it must be manually enabled.
battery_power:
- sensor.solaxmodbus_battery_power_charge
pv_power:
- sensor.solaxmodbus_pv_power_total
load_power:
- sensor.solaxmodbus_house_load
soc_percent:
- sensor.solaxmodbus_battery_capacity
reserve:
- number.solaxmodbus_backup_discharge_min_soc
battery_min_soc:
- sensor.solaxmodbus_feedin_discharge_min_soc
inverter_limit: 5000
Then the problem I experienced was with the control. I tried:
energy_control_switch:
- select.solaxmodbus_remotecontrol_power_control
But no luck, down to not enabling SX4 but I now can't find anything relating to SX4 in Github either 😅
Have you tried setting:
inverter_type: "SX4"
This should change the controls to be more suitable.
Can you clarify how Predbat should start/stop charges and forced export?
What would be good is if you can share an automation that charges the battery and one that exports it
I will try changing inverter type hopefully tomorrow and see if it works (if my baby sleeps enough to buy me time!)
For now here are my automations to force charge.
`alias: Predbat Charger Automation True
description: ""
trigger:
- platform: state
entity_id:
- sensor.predbat_current_charging_session
for:
hours: 0
minutes: 0
seconds: 0
condition:
- condition: state
entity_id: sensor.predbat_current_charging_session
state: "True"
for:
hours: 0
minutes: 0
seconds: 0
action:
- device_id: 2780f933c7dfa3b564a86f618a26dfdb
domain: select
entity_id: 5c3fe78f0b70a79ac641d8ed49176c94
type: select_option
option: Manual Mode
- device_id: 2780f933c7dfa3b564a86f618a26dfdb
domain: select
entity_id: 357cfa49177419da9d42526a8ac8bdd6
type: select_option
option: Force Charge
mode: single
And discharge is exactly the Same as above but select option Force Discharge
This is my code to reset it to normal after
alias: Predbat Charger Automation False
description: ""
trigger:
- platform: state
entity_id:
- sensor.predbat_current_charging_session
for:
hours: 0
minutes: 0
seconds: 0
condition:
- condition: state
entity_id: sensor.predbat_current_charging_session
state: "False"
for:
hours: 0
minutes: 0
seconds: 0
action:
- device_id: 2780f933c7dfa3b564a86f618a26dfdb
domain: select
entity_id: 5c3fe78f0b70a79ac641d8ed49176c94
type: select_option
option: Self Use Mode
mode: single
I have just tried setting it as SX4 and get:
2024-02-12 17:22:28.977032 INFO pred_bat: ERROR: Exception raised argument of type 'NoneType' is not iterable
Here it is the full log: https://pastebin.com/QfzNFpPs
Can confirm read only mode still works and I get the full Predbat plan. Let me know if there are more detailed logs I can pull!
For the error you probably need to capture the stack trace from 'settings, system, logs, appdeamon' so I can see what causes it.
Taking a step back can you share your apps.yaml so far so I know what you have configured?
Sure, thanks!
Apps.yaml: https://pastebin.com/Ser82dSC
And here is the stack trace:
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/lib/python3.11/site-packages/appdaemon/adapi.py", line 588, in _check_entity
if "." not in entity:
^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable
2024-02-13 08:45:04.002111 WARNING pred_bat: ------------------------------------------------------------
2024-02-13 08:50:04.024183 WARNING pred_bat: ------------------------------------------------------------
2024-02-13 08:50:04.025037 WARNING pred_bat: Unexpected error in worker for App pred_bat:
2024-02-13 08:50:04.025959 WARNING pred_bat: Worker Ags: {'id': 'cad7e4124fd948adb57863342941485e', 'name': 'pred_bat', 'objectid': '38a38edca8844d53a1634f83d5a1d78e', 'type': 'scheduler', 'function': <bound method PredBat.run_time_loop of <predbat.PredBat object at 0x7ff62f593050>>, 'pin_app': True, 'pin_thread': 0, 'kwargs': {'interval': 300, 'random_start': 0, 'random_end': 0, '__thread_id': 'thread-0'}}
2024-02-13 08:50:04.026247 WARNING pred_bat: ------------------------------------------------------------
2024-02-13 08:50:04.027896 WARNING pred_bat: Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/appdaemon/threading.py", line 1022, in worker
funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"]))
File "/usr/lib/python3.11/site-packages/appdaemon/adbase.py", line 35, in f_app_lock
return f(*args, **kw)
^^^^^^^^^^^^^^
File "/config/apps/predbat.py", line 12119, in run_time_loop
raise e
File "/config/apps/predbat.py", line 12115, in run_time_loop
self.update_pred(scheduled=True)
File "/usr/lib/python3.11/site-packages/appdaemon/adbase.py", line 35, in f_app_lock
return f(*args, **kw)
^^^^^^^^^^^^^^
File "/config/apps/predbat.py", line 11142, in update_pred
status, status_extra = self.execute_plan()
^^^^^^^^^^^^^^^^^^^
File "/config/apps/predbat.py", line 9834, in execute_plan
self.reset_inverter()
File "/config/apps/predbat.py", line 9811, in reset_inverter
inverter.adjust_charge_rate(inverter.battery_rate_max_charge * MINUTE_WATT)
File "/config/apps/predbat.py", line 1940, in adjust_charge_rate
entity = self.base.get_entity(self.base.get_arg("charge_rate", indirect=False, index=self.id))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/appdaemon/adapi.py", line 3188, in get_entity
self._check_entity(namespace, entity)
File "/usr/lib/python3.11/site-packages/appdaemon/utils.py", line 231, in inner_sync_wrapper
f = run_coroutine_threadsafe(self, coro(self, *args, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/appdaemon/utils.py", line 313, in run_coroutine_threadsafe
result = future.result(self.AD.internal_function_timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 456, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/lib/python3.11/site-packages/appdaemon/adapi.py", line 588, in _check_entity
if "." not in entity:
Hi Absolutely loving the work that everyone has put in here, it's really appreciated. I have a Solax X1 AC inverter with a Waveshare Modbus attached, and have access to all of the entities for the inverter. I have installed Predbat and have successfully managed to get it fully monitoring and predicting etc, which is awesome. The problem is that I can't get it to charge / discharge the battery as per the plan, even though I've enabled charge / discharge in predbat. I'm assuming that the issue is predbat knowing the exact commends to send to my inverter, so was wondering if anyone could help in solving this with me? Happy to provide whatever information I can to help get this sorted, as I know others are in the same situation as me.
Many thanks in advance
I'm not sure were @nikotime got with this, I kind of lost track.
@punkymuzzle what is currently in your apps.yaml for Solax? If you have an automation example to start/stop charge we can use the service feature in apps.yaml to trigger it.