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

Add solar assistant to predbat #1723

Merged

Conversation

xhemp
Copy link
Contributor

@xhemp xhemp commented Dec 12, 2024

Added Solar Assistant to PredBat.
I believe this will help whoever wants to use PredBat with Solar Assistant and would allow people (like me) to upgrade to new versions without modifying the config.py.
This resolves #786

@springfall2008
Copy link
Owner

Nice one :) Any chance of you adding it to the documentation too?

@xhemp
Copy link
Contributor Author

xhemp commented Dec 12, 2024 via email

@springfall2008 springfall2008 merged commit a701b4c into springfall2008:main Dec 13, 2024
1 check passed
@sparkyhughes
Copy link

Any chance this can be enhanced to enable more features via Solar-Assistant exposed MQTT entities? The Mode works fine now, but SOC Target and Discharge rate has no effect from what I can see as setting the discharge rate to 0 doesn’t stop the battery discharging. Maybe if more of the batpred variables which can be tied to HA entities were known and documented in the apps.yaml file?

@xhemp
Copy link
Contributor Author

xhemp commented Dec 18, 2024

@sparkyhughes Not sure if you can set that on Solar Assistant, I went through the MQTT topics and I can't see anywhere to set a SOC target. For charge/discharge rate, I can see topics but they are in percentage for Solar Assistant and looks like they are in watts in batpred. Have you tried to play with those topics and see what happened?

@sparkyhughes
Copy link

I've managed to get Batpred setting the Battery First Stop Charge value by using the charge_limit setting:

charge_limit:
   - number.growatt_sph_battery_first_stop_charge

I've also managed to get charge freeze working by modifying the start/stop/freeze service settings

# Service for start/stop
charge_start_service:
  - service: select.select_option
    entity_id: select.growatt_sph_work_mode_priority
    option: "Battery first"
  - service: select.select_option
    entity_id: select.growatt_sph_battery_first_grid_charge
    option: "Enabled"
charge_stop_service:
  service: select.select_option
  entity_id: select.growatt_sph_work_mode_priority
  option: "Load first"
discharge_start_service:
  service: select.select_option
  entity_id: select.growatt_sph_work_mode_priority
  option: "Grid first"
charge_freeze_service:
  - service: select.select_option
    entity_id: select.growatt_sph_battery_first_grid_charge
    option: "Disabled"
  - service: select.select_option
    entity_id: select.growatt_sph_work_mode_priority
    option: "Battery first"

I needed to enable charge freeze and charge limit in the config.py file, which will be overwritten I presume when Batpred is next upgraded?

I set "has_target_soc" to True
I set "support_charge_freeze" to True

@xhemp
Copy link
Contributor Author

xhemp commented Dec 19, 2024

Nice one, @sparkyhughes, I have added on mine and will see what happens.
You are right, you would need to change config.py again with that after an update but that's until we test it works properly, either one of us can open a PR to add that and after it gets merged, we won't need to change anything else.
There's also something which I believe we will need @springfall2008 's help, I get the following error on the Status:

Error: Exception raised 'NoneType' object has no attribute 'split'

And on the logs:

`
2024-12-19 10:15:21.186310: Error: Exception raised 'NoneType' object has no attribute 'split'
2024-12-19 10:15:21.187935: Error: Traceback (most recent call last):
File "/config/predbat.py", line 965, in run_time_loop
self.update_pred(scheduled=True)
File "/config/predbat.py", line 556, in update_pred
status, status_extra = self.execute_plan()
File "/config/execute.py", line 454, in execute_plan
self.adjust_battery_target_multi(inverter, 0, isCharging, isExporting)
File "/config/execute.py", line 498, in adjust_battery_target_multi
inverter.adjust_battery_target(new_soc_percent, is_charging, is_exporting)
File "/config/inverter.py", line 1243, in adjust_battery_target
self.write_and_poll_value("charge_limit", self.base.get_arg("charge_limit", indirect=False, index=self.id), soc)
File "/config/inverter.py", line 1307, in write_and_poll_value
domain, entity_name = entity_id.split(".")
AttributeError: 'NoneType' object has no attribute 'split'

2024-12-19 10:15:21.237717: Info: record_status Error: Exception raised 'NoneType' object has no attribute 'split'
2024-12-19 10:15:21.237916: Error: 'NoneType' object has no attribute 'split'
`

Do you get that as well @sparkyhughes ?

Edit: Yes, I did add your modifications to mine but it is not setting number.growatt_sph_battery_first_stop_charge (mine is an SPA so I changed to spa) to the percentage chosen so we will probably have to wait for @springfall2008 to chime in on this.

@sparkyhughes
Copy link

No I don't get that error. Is that in the Predbat log (on the HA Add-ons page -> Log) ?
I just get the usual "Warn: Inverter 0: Using Inverter type SA - not all features are available" and "Info: record_status Demand"

There's another useful log in File Editor in the same directory as apps.yaml called predbat.log which has quite verbose stuff logged.

@sparkyhughes
Copy link

sparkyhughes commented Dec 19, 2024

I think because Solar-Assistant supports so many different inverters, it's almost like a separate version for each inverter type is needed. Luckily you and I have Growatt albeit slightly different inverter model

I have also emailed solar-assistant support to try and get them to make more features that Batpred can do available

@xhemp
Copy link
Contributor Author

xhemp commented Dec 19, 2024

No I don't get that error. Is that in the Predbat log (on the HA Add-ons page -> Log) ? I just get the usual "Warn: Inverter 0: Using Inverter type SA - not all features are available" and "Info: record_status Demand"

There's another useful log in File Editor in the same directory as apps.yaml called predbat.log which has quite verbose stuff logged.

Yes, there or in the predbat page - logs but then you have to set it to All to see all errors.
So just with the same configuration (in your case, you probably changed the apps.yaml to sph instead of spa), you see no errors at all? It's odd.
Maybe it's time to open a new issue so we can talk there instead of in this PR.

@xhemp
Copy link
Contributor Author

xhemp commented Dec 19, 2024

Opened #1761 , we can continue there.

@xhemp
Copy link
Contributor Author

xhemp commented Dec 28, 2024

@springfall2008 any chance you can have a look at #1761 ?

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.

Add support for Solar Assistant
3 participants