Background and purpose
The original purpose of integrating the solar PV system — a Growatt SPH hybrid inverter with battery — into Home Assistant was to use measurement data to control other installations in the house based on the current solar surplus.
When Home Assistant knows production, consumption and grid exchange, larger appliances and installations can be controlled so they run mainly when there is a solar surplus. A battery control layer was later built on top of this data integration.
Testing Home Assistant’s Growatt integration
Home Assistant has an official Growatt integration that provides access to data via Growatt’s cloud API. This integration requires a working API token. It was not possible to obtain token access linked to the system, and the integration therefore could not be put into operation. The impression was that API access in practice is only available to installers or specific account types. The official Growatt integration was therefore put on hold.
There are other unofficial and partly local integration options, for example based on Modbus or third-party software, but these often require complex manual configuration, special hardware, or ongoing maintenance. This track was therefore not pursued.
As a workaround, import and export were measured for a period using an external 3-phase Shelly energy meter. This solution provided an overview of grid export and import, but it did not enable control of the inverter and battery.
SunMate Pulse and data logging
Along the way, I became aware of the SunMate Pulse data logger as a possible solution with access to both measurement data and control in Home Assistant.
SunMate.io is a Danish platform for monitoring and controlling solar PV systems and related hardware. The data logger is designed to connect to SunMate’s platform, which also provides an advanced integration with Home Assistant.
In this Home Assistant setup, the SunMate Pulse data logger is used. It connects directly to the inverter and sends data via Wi-Fi to SunMate’s platform. At the same time, the data logger acts as the link to Home Assistant through the local integration. Home Assistant can therefore read measurement data and control key inverter parameters via the Pulse device.

SunMate’s guides for installing the data logger for different inverters, connecting it to Wi-Fi, creating a user, and setting up integrations (including Home Assistant) can be found on their support pages (Danish language).
SunMate and Home Assistant
SunMate’s own automations and control via Home Assistant must not be used simultaneously, as parallel control can create conflicts that, according to SunMate, may damage the inverter.
In this setup, control is currently centralized in Home Assistant. Over time it has gradually developed into a personal project, where part of the motivation has been the challenge of understanding the system in depth and building a custom solution rather than relying on a ready-made platform.
Battery control is fully implemented in Home Assistant and uses SunMate Pulse solely as a data logger and control interface for the inverter.
Overall use of the battery
During the summer months the battery is primarily used to store excess solar production. In winter the purpose is different: here the battery is mainly used to reduce electricity purchases from the grid during the most expensive hours of the day.
The control strategy is not based on continuous optimization against hourly electricity prices, but on a simple and transparent model using fixed time windows and a calculated night-time charging target. The battery is mainly used during two periods when electricity prices are typically high: in the morning and in the evening. At night the battery can be charged from the grid if the current battery level is below the calculated target.
The system is deliberately kept simple. Instead of advanced price optimization or machine learning, a practical model is used where the battery strategy for the next day is calculated based on expected solar production (Solcast) and measured consumption blocks from the house. The goal is not theoretical perfection, but stable and predictable operation.
The financial benefit is modest but real. Savings are achieved by shifting part of the electricity consumption away from the most expensive hours and instead using the battery where it provides the greatest benefit.
Overall heating and energy management model in Home Assistant
Heating control and battery control are two separate systems in the current setup.
The house heating system is still managed in Home Assistant through different operating modes, but the battery control no longer directly follows these modes. Instead, the battery operates according to its own logic, independent of whether the house is set to Home, Away, or Vacant mode.
The battery model is based on three simple principles:
- the battery can be used during a morning window when electricity prices are typically high
- the battery can be used again during an evening window when electricity prices are typically high
- the battery can be charged at night if the calculated demand for the following day requires it
Battery control is therefore no longer tied to a specific heating mode but to a separate energy logic within Home Assistant.
The setup remains relatively simple. It does not use dynamic electricity price calculations or advanced optimization from hour to hour. Instead, it relies on fixed time windows, simple forecasts, and real-time measurement data from the inverter and the house’s energy consumption. This makes the control logic easier to understand, test, and adjust.
Battery operation during periods of high electricity prices
During winter operation the battery is primarily used in two fixed time windows:
- morning peak from 07:30 to 09:30
- evening peak from 17:00 to 21:00
These periods are chosen because they normally coincide with the highest electricity prices of the day.
During the morning period the battery is not discharged freely. Instead, Home Assistant sets a calculated stop level so the battery is only used down to a level that still leaves reserves for the evening period. The evening period therefore has higher priority than the morning period.
During the evening period the battery is discharged more directly, since avoiding grid purchases at that time typically provides the greatest value.
Outside these time windows the battery is generally held back so that energy is reserved for the periods when it has the greatest impact.
At night, between 01:00 and 04:00, the battery can be charged from the grid. This only happens if the current battery SOC is below the target calculated by Home Assistant for the coming day.
Dynamic calculation of the night charging target
The night charging target is calculated after midnight in Home Assistant.
The calculation is based on measured household consumption in defined daily blocks and the expected solar production for the following day. Instead of working with total daily consumption, the household demand is divided into relevant periods so the system can better account for morning and evening needs.
The calculated night target must cover two things:
- the expected demand during the morning peak period
- the expected demand during the evening peak period, after accounting for the solar energy expected to be available during the day
In this way the battery is not simply charged to a fixed level at night, but to a level that depends on both the next day’s solar forecast and the house’s recent consumption pattern.
At the same time, a separate stop level is calculated for the morning period. This means that the morning discharge does not simply follow a fixed minimum SOC but a level derived from the expected energy requirement later in the day.
The model remains simple but is significantly more targeted than a fixed night charge or a simple minimum battery limit.
Base operation
When Home Assistant is not actively using the battery during the defined peak periods, the system runs in a more neutral operating mode.
In this state the battery is not aggressively discharged but held in reserve so its capacity can be used during the morning or evening periods. If there is excess solar production, the battery continues to charge from solar power as usual.
During summer the system will in practice behave much like a conventional solar installation with battery storage: excess solar energy is stored in the battery, household consumption is supplied by solar power first, and any remaining surplus is exported to the grid.
Technical structure
The control model is based on the sensors and control entities provided by the SunMate Pulse integration in Home Assistant, which exposes both measurement data and key control parameters.
Measurement data
Control is based on continuous measurements of the battery SOC (State of Charge, i.e. the current battery charge level in percent), solar production, grid import and export, and total household consumption.
The most important sensors include, among others:
- Battery state of charge (pulse_battery_soc)
- Current grid consumption/export (pulse_grid_total_power, pulse_grid_out_total_power)
- Total household consumption (pulse_load_w_totalpower)
- Solar PV production (pulse_pv_totalpower, pulse_daily_production)
- Battery charge and discharge power (pulse_battery_input_w, pulse_battery_output_w)
- Battery temperature and voltage (pulse_battery_temperature, pulse_battery_voltage)
- Daily energy figures (pulse_daily_energy_bought, pulse_daily_energy_sold, pulse_daily_battery_charge, pulse_daily_battery_discharge)
These data are used both for monitoring and as input to the automations.
Central enable switch and conflict prevention
All controllable functions are gated behind a central enable switch in Home Assistant. When this switch is off, the system makes no automatic changes to the inverter or battery settings. When it is on, SunMate’s automations must be turned off.
Sensors and measurement data are always active and can be used freely. Only the control functions are disabled. This preserves monitoring and history even when the Home Assistant automation is turned off.
All scripts and automations check whether this switch is on before making changes.
Controllable parameters
Through the integration, a number of key settings can be changed directly from Home Assistant via the ESPHome setup provided by SunMate.
The most important control entities are:
- Discharge limit / stop SOC (pulse_battery_discharge_stop_soc)
- Maximum SOC (pulse_battery_max_soc)
- Minimum SOC (pulse_battery_min_soc)
- Maximum charge power (pulse_battery_max_charge_power)
- Maximum discharge power (pulse_battery_max_discharge_power)
- Grid charging on/off (pulse_charge)
- Inverter priority (pulse_inverter_priority)
Scripts and automations
Control is split into scripts with well-defined functions, which are used by the automations at fixed times or when modes change. The scripts mainly use the entities above to change the operating mode.
About coding
This case describes architecture and control principles, but not specific Home Assistant automations. The code will depend on the individual installation. Automations can be generated with the help of AI, if the AI is given the necessary technical prerequisites described above.


