⚠️ IMPORTANT: Before installing, please ensure you complete all steps in the Required Configuration section. The system requires specific logging setup to function properly.
Maximize the potential of your Huawei solar battery system with this powerful Home Assistant package. By intelligently optimizing battery usage, solar production, and grid interaction, this solution helps you:
Perfect for homeowners looking to make the most of their solar investment while contributing to a greener future.
To use this package, you need the following integrations:
⚠️ CRITICAL: These steps must be completed before installing the package.
Create a logging directory under your Home Assistant config folder:
mkdir /config/hsbo_logging
configuration.yaml
:
homeassistant:
allowlist_external_dirs:
- "/config/hsbo_logging"
Navigate to Home Assistant Settings:
Configure the notification service:
/config/hsbo_logging/hsbo_system.log
Set the correct entity name:
notify.file
or notify.file2
if you have existing file integrations)notify.file_hsbo_system_log
⚠️ Important: The entity ID must be exactly
notify.file_hsbo_system_log
for the system to work properly.
input_boolean.hsbo_logging_enabled
in your Home Assistant instance⚠️ Note: The new logging system won't function until this boolean is enabled.
First, ensure your Home Assistant instance is configured to use packages by adding the following to your configuration.yaml
:
homeassistant:
packages: !include_dir_named packages
If you don't have a packages
directory in your Home Assistant configuration directory, create it:
mkdir /config/packages
Place the following YAML files in your Home Assistant packages directory (/config/packages/
):
huawei_solar_battery_optimization.yaml
(main package with scripts and automations)huawei_solar_battery_optimization_input.yaml
(user-configured input parameters)huawei_solar_battery_optimization_power.yaml
(power and statistics sensors)huawei_solar_battery_optimization_logging.yaml
(logging configuration)huawei_solar_battery_optimization_pricing.yaml
(pricing-related configurations)After placing all files and updating the configuration, restart Home Assistant to load the new packages.
⚠️ Important:
- All five package files are required for the system to function properly
- The packages configuration in
configuration.yaml
is mandatory- Restart Home Assistant after making these changes
For more information on using packages in Home Assistant, see the official documentation.
You need to adjust the following input sensors in the package file to match your setup:
sensor.solcast_pv_forecast_forecast_today
(from Solcast integration)sensor.solcast_pv_forecast_forecast_tomorrow
(from Solcast integration)sensor.energi_data_service_total_price
(from Energi Data Service integration)sensor.energi_data_service_spot_price
(from Energi Data Service integration)sensor.batteries_state_of_capacity
(from Huawei Solar Integration)sensor.inverter_active_power_control
(from Huawei Solar Integration) You need to map your specific user-provided sensors to the input sensors. You can either do this in Developer tools > States or you can use the Lovelace card described below.
The package includes the following automations to manage and optimize your Huawei solar battery system:
hsbo_daily_battery_optimization
:
hsbo_set_battery_charge_time
:
hsbo_calculate_next_day_charging_at_9_pm
:
hsbo_comprehensive_daily_mode_management
:
These automations work together to provide a comprehensive, adaptive system that optimizes your solar battery usage, maximizes self-consumption, and manages grid interaction based on current conditions and forecasts.
The package includes the following scripts for managing and optimizing your Huawei solar battery system:
hsbo_calculate_energy_thresholds
: Calculates the average, high, and low energy price thresholds for the day.
hsbo_analyze_hourly_data
: Analyzes the hourly solar production forecast and electricity prices, making decisions about battery charging and grid selling.
hsbo_process_hourly_data
: Processes data for a specific hour, determining whether to sell to the grid, charge the battery, or use the energy.
hsbo_update_hourly_recommendation
: Updates the recommendation for a specific hour based on the decision made in the hourly data processing.
hsbo_generate_summary
: Generates a summary of the battery optimization analysis, including potential grid selling, battery charging, and recommendations.
hsbo_set_working_mode_to_default_tou_periods
: Sets the system to use default Time-of-Use (TOU) periods, configuring charging and discharging times.
hsbo_set_working_mode_to_fully_fed_to_grid
: Sets the system to feed all generated power to the grid. Only in here as a function, not in any automations
hsbo_set_working_mode_to_maximise_self_consumption
: Sets the system to maximize self-consumption of generated power.
hsbo_set_working_mode_to_tou_and_disable_battery_charging_and_discharging
: Sets a special TOU mode where battery charging and discharging are disabled.
hsbo_disable_grid_export
: Disables exporting power to the grid.
hsbo_enable_grid_export
: Enables exporting power to the grid.
hsbo_calculate_next_day_charging
: Calculates the charging strategy for the next day, including required grid charging and recommended working mode.
These scripts are used in various automations within the package and can also be called manually or incorporated into your own custom automations as needed.
You can use the following lovelace card to show all entities related to HSBO using the custom auto entities card:
- type: custom:auto-entities
card:
type: entities
title: HSBO
filter:
include:
- entity_id: '*hsbo*'
exclude: []
...or you can use this lovelace card directly in an enteties card.
type: entities
entities:
- entity: input_text.hsbo_device_id_inverter
- entity: input_text.hsbo_device_id_inverter_2
- entity: input_text.hsbo_device_id_batteries
- entity: input_text.hsbo_batteries_grid_charge_cutoff_soc
- entity: input_text.hsbo_batteries_working_mode
- entity: input_text.hsbo_batteries_excess_pv_energy_use_in_tou
- entity: input_text.hsbo_energi_data_service_total_price
- entity: input_text.hsbo_energi_data_service_spot_price
- entity: input_text.hsbo_solcast_pv_forecast_forecast_today
- entity: input_text.hsbo_solcast_pv_forecast_forecast_tomorrow
- entity: input_text.hsbo_batteries_state_of_capacity
- entity: input_text.hsbo_inverter_active_power_control
- entity: input_text.hsbo_house_consumption_power
- entity: input_text.hsbo_solar_production_power
- entity: input_text.hsbo_ev_charger_status
title: HSBO Battery Optimization
This package supports several working modes to optimize your Huawei solar battery system:
Description: This mode prioritizes using the energy generated by your solar panels to power your home and charge your battery, minimizing the amount of energy drawn from the grid.
Use Case: Ideal for households looking to reduce their reliance on grid electricity and maximize the use of their solar energy production.
When to Use:
Description: This mode optimizes battery charging and discharging based on time-of-use electricity rates. It charges the battery when electricity rates are low and discharges when rates are high.
Use Case: Perfect for users with time-of-use electricity tariffs who want to minimize their electricity costs.
When to Use:
Default TOU Periods (configured in this package)
These default periods are set to optimize battery usage based on typical daily electricity demand patterns. The system charges the battery during early morning hours when demand is typically low, and discharges during morning and evening peak hours. You can adjust these periods to match your specific utility's rate schedule or your household's energy consumption patterns.
Description: In this mode, all excess solar energy is fed back to the grid instead of being stored in the battery and in some circumstances will also drain the battery.
Use Case: Useful in scenarios where feeding energy to the grid is more beneficial than storing it. Especially if electricity price for selling is high.
When to Use:
Note: This working mode is not in use by any automations at the moment, but script is added if needed.
Description: This feature allows you to enable or disable the export of excess energy to the grid based on current electricity spot prices.
Use Case: Helps optimize the financial benefits of your solar system by exporting energy when it's most profitable.
How it Works:
When to Use:
By utilizing these working modes and the grid export management feature, you can tailor your Huawei solar battery system's operation to your specific needs, local energy market conditions, and personal energy goals.
This package now includes features to optimize battery usage when an electric vehicle (EV) is charging. Here's how it works:
The system monitors the state of EV charging using a binary sensor (binary_sensor.hsbo_ev_charging
). When EV charging starts or stops, it triggers specific actions to optimize energy usage.
When EV charging starts:
When EV charging stops:
To use this feature, ensure you have a binary sensor set up in Home Assistant that indicates when your EV is charging. Update the input_text.hsbo_ev_charger_status
in the package configuration to point to your EV charging sensor.
This EV charging optimization works seamlessly with the other features of the Huawei Solar Battery Optimization package, providing a comprehensive energy management solution for homes with both solar systems and electric vehicles.
Please note, if you already has existing automations configuring the Huawai working mode, these should be disabled or removed as the Daily mode management automation would conflict or reset any other configurations.
This section highlights key updates and new features added to the Huawei Solar Battery Optimization package.
Future planned features include:
This package is created by Heino Skov. While no official support is provided, you're free to use and edit it to your needs. Contributions, suggestions, and improvements are welcome via GitHub issues and pull requests.
A big thank you to all the contributors who have helped improve this project:
Your contributions, whether through discussons, code, documentation, or suggestions, have been invaluable in making this project better for everyone. Thank you for your time and effort!
This project is open-source and available under the MIT License.
This package is provided as-is, without any warranty or guarantee of its functionality or suitability for any particular purpose. Use at your own risk.