Set battery cut-offs

Use this action to set the charge levels at which your Sofar inverter stops discharging the battery, with the grid up and during a grid outage, and the level at which it stops charging. These are the same cut-offs, with the same ranges, as on the battery parameters page of the SofarCloud app. Only available on three-phase hybrid inverters with battery storage, and not for lead-acid batteries.

The inverter stores each change, so use this action for settings you change now and then, such as keeping a larger reserve ahead of a storm, rather than in automations that run often.

Only users with administrator rights can run this action.

Using this action from the user interface

If you prefer building automations and scripts visually, Home Assistant walks you through this action step by step. You pick what to target, tweak a few options, and save. No YAML knowledge required.

To set the battery cut-offs from an automation or a script:

  1. Go to Settings > Automations & scenes.
  2. Open an existing automation or script, or select Create automation > Create new automation.
  3. If you’re setting up a new automation, add a trigger in the When section. Scripts don’t need a trigger. They run when something else calls them.
  4. In the Then do section, select Add action.
  5. From the search box, search for and select Sofar: Set battery cut-offs.
  6. Select the Inverter, and enter the On-grid discharge cut-off state of charge, the Off-grid discharge cut-off state of charge, and the Off-grid discharge recovery state of charge. Optionally, enter the Charge cut-off state of charge.
  7. Select Save.

This action does not support targets. In the UI, you are not prompted to choose an area, device, entity, or label.

Options in the UI

Inverter (Required)

The Sofar inverter to send this to.

On-grid discharge cut-off state of charge (Required)

The charge level at which the battery stops discharging while the grid is up, from 10 to 100%. It can’t be below the off-grid discharge cut-off.

Off-grid discharge cut-off state of charge (Required)

The charge level at which the battery stops discharging during a grid outage, from 10 to 30%.

Off-grid discharge recovery state of charge (Required)

The charge level the battery recharges to before it discharges off-grid again, up to 100%. It must be at least 5% above the off-grid discharge cut-off.

Charge cut-off state of charge (Optional)

The charge level at which the battery stops charging, from 60 to 100%. Left unchanged when you leave it out. Not every inverter supports it.

Using this action in YAML

If you work directly in YAML, or you want to know exactly what Home Assistant does under the hood, this section has the technical reference. It lists the field names you use in YAML, their types, and which ones are required. For how an automation or a script is built in YAML, refer to Automations in YAML and Scripts.

In YAML, refer to this action as sofar.set_battery_cutoffs. A basic example looks like this:

ActionAn action makes Home Assistant do something, for example, turn on a light, send a notification, or activate a scene. Automations and scripts run a list of actions. [Learn more]
action: sofar.set_battery_cutoffs
data:
  config_entry_id: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4
  on_grid_discharge_cutoff_soc: 20
  off_grid_discharge_cutoff_soc: 10
  off_grid_recovery_soc: 20

This lets the battery discharge down to 20% while the grid is up, and down to 10% during a grid outage. After an off-grid cut-off, the battery recharges to 20% before it discharges off-grid again.

Options in YAML

config_entry_id string Required

The Sofar inverter to send this to.

on_grid_discharge_cutoff_soc integer Required

The charge level at which the battery stops discharging while the grid is up, from 10 to 100%. It can’t be below the off-grid discharge cut-off.

off_grid_discharge_cutoff_soc integer Required

The charge level at which the battery stops discharging during a grid outage, from 10 to 30%.

off_grid_recovery_soc integer Required

The charge level the battery recharges to before it discharges off-grid again, up to 100%. It must be at least 5% above the off-grid discharge cut-off.

charge_cutoff_soc integer (Optional)

The charge level at which the battery stops charging, from 60 to 100%. Left unchanged when you leave it out. Not every inverter supports it.

Good to know

  • This action is only available on three-phase hybrid inverters with battery storage. It doesn’t support lead-acid batteries, including AGM, gel, and flooded batteries. On other inverters or batteries, the action fails with an error instead of doing nothing silently.
  • If you set a Charge cut-off state of charge on an inverter that doesn’t support it, the action fails with an error, and nothing is changed.
  • If all the cut-offs you set already have those values, nothing is written to the inverter.
  • To see the cut-offs currently stored on the inverter, enable the battery configuration sensors, such as On-grid discharge cut-off state of charge. They’re disabled by default.

Try it yourself

Ready to test this? Open Settings > Tools > Actions, search for this action, fill in the fields, and select Perform action. You see what happens on your actual entitiesAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more] without writing a line of YAML.

More examples

Real scenarios where this action shows up in automations and scripts. Copy any example and adapt it to your setup. In the visual editor, select the UI options listed in the example or paste the YAML code.

Tip

You don’t need to edit YAML to use these examples. Copy a YAML snippet from this page, open the visual automation editor in Home Assistant, and press Ctrl+V (or Cmd+V on Mac). Home Assistant automatically converts the pasted YAML into the visual editor format, whether it’s a full automation, a single trigger, a condition, or an action.

Automation: keep a larger reserve ahead of a storm

A storm can take the grid down for hours, and a battery that’s already run down by the evening’s loads won’t carry the house through. This automation reacts to an input_boolean helper you create and turn on when a storm is forecast, and raises the on-grid cut-off to 50%, so half of the battery is kept for an outage. A second automation, or the same one with another trigger, can set it back when the helper turns off.

  • Trigger: State changed
    • Entity: Storm warning helper
    • To: On
  • Action: Set battery cut-offs
    • Inverter: Your Sofar inverter
    • On-grid discharge cut-off state of charge: 50
    • Off-grid discharge cut-off state of charge: 10
    • Off-grid discharge recovery state of charge: 20
YAML example for keeping a storm reserve
AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
alias: "Keep a Sofar battery reserve ahead of a storm"
triggers:
  - trigger: state
    entity_id: input_boolean.storm_warning
    to: "on"
actions:
  - action: sofar.set_battery_cutoffs
    data:
      config_entry_id: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4
      on_grid_discharge_cutoff_soc: 50
      off_grid_discharge_cutoff_soc: 10
      off_grid_recovery_soc: 20

Still stuck?

To test the action on its own, run it in the automation editor with Run action, and check the message that it shows. To see what the action did when the automation ran, open the trace of that run. For details, refer to Testing automations. For common problems and their solutions, refer to Troubleshooting automations.

If that doesn’t help, the Home Assistant community is quick to help: join Discord for real-time chat, post on the community forum with the action you’re calling and what you expected to happen, or share on our subreddit /r/homeassistant.

Tip

AI assistants like ChatGPT or Claude can also explain actions or suggest the right one when you describe what you want in plain language.

Related actions

Explore related actions: