Sonnenbatterie with APIv2 / Webhook

The “path” leads to complex JSON data when all you want is one element. So you have to use jinja template to extract the data of interets.

Hi!

now I’m trying to set the Em_OperatingMode to manual. I can do it with this curl command:

curl -X PUT -d EM_OperatingMode=1 --header 'Auth-Token: TOKEN' http://sonnen:80/api/v2/configurations

And I get the appropriate response:

{"EM_OperatingMode":"1"}

I would like to have it as a switch though:

switch:
  - name: Sonnen battery manual mode
    platform: rest
    resource: http://sonnen:80/api/v2/configurations
    method: put
    headers:
      Auth-Token: !secret sonnen_api_token
    body_on: "EM_OperatingMode=1"
    body_off: "EM_OperatingMode=2"
    is_on_template: '{{ value_json["EM_OperatingMode"] == "1" }}'

But it doesn’t work. In the logs I only get:

ERROR (MainThread) [homeassistant.components.rest.switch] Can't turn on http://sonnen:80/api/v2/configurations. Is resource/endpoint offline?

Any clues?

I think the problem lies in how you’re specifying the body_on and body_off parameters.

In your curl command, you’re using -d EM_OperatingMode=1, which sends a JSON payload to the API. However, in your Home Assistant configuration, you’ve specified body_on: "EM_OperatingMode=1" and body_off: "EM_OperatingMode=2", without any indication that these should be treated as JSON payloads.

When you send a request with these values, it’s likely being interpreted as a query string (e.g. http://sonnen:80/api/v2/configurations?EM_OperatingMode=1) instead of a JSON payload. This is why the API is not receiving the expected data and returning an error.

To fix this, you should use the following configuration:

switch:
  - name: Sonnen battery manual mode
    platform: rest
    resource: http://sonnen:80/api/v2/configurations
    method: put
    headers:
      Auth-Token: !secret sonnen_api_token
    body_on: '{"EM_OperatingMode": "1"}'
    body_off: '{"EM_OperatingMode": "2"}'
    is_on_template: '{{ value_json["EM_OperatingMode"] == "1" }}'

By surrounding the values with double quotes and curly braces, you’re telling Home Assistant to treat them as JSON payloads.

Hi!

thanks for the answer, but unfortunately it didn’t work. I get the same log output and nothing happens in the battery. I also got this working in HTTPie (GUI) and I had to specify that the payload is Form data:

PUT /api/v2/configurations HTTP/1.1
Auth-Token: TOKEN
Content-Length: 18
Content-Type: application/x-www-form-urlencoded
Host: sonnen
User-Agent: HTTPie

EM_OperatingMode=2

So I guess we need to tell HA somehow to send the payload as form data, which, turns out you can do with a header:

switch:
  - name: Sonnen battery manual mode
    platform: rest
    resource: http://sonnen:80/api/v2/configurations
    method: put
    headers:
      Auth-Token: !secret sonnen_api_token
      Content-Type: application/x-www-form-urlencoded
    body_on: "EM_OperatingMode=1"
    body_off: "EM_OperatingMode=2"
    is_on_template: '{{ value_json["EM_OperatingMode"] == "1" }}'

This worked for me.

Thanks for the hint!!

Hi again,

I have been using this config to monitor and control the status of my Sonnen battery. Thought I’d just share this here for anyone interested.

I took most of it from other sources that now I can’t find again, so huge thanks to everybody who somehow contributed.

rest:
  - resource: http://IP_of_Battery:80/api/v2/status
    headers:
      Auth-Token: !secret sonnen_api_token
    scan_interval: 15
    sensor:
      - name: Sonnen Apparent_output
        unique_id: sonnen_status_Apparent_output
        value_template: '{{ value_json.Apparent_output | int(None) }}'
        unit_of_measurement: VA
        device_class: apparent_power
        state_class: measurement
      - name: Sonnen BackupBuffer
        unique_id: sonnen_status_BackupBuffer
        value_template: '{{ value_json.BackupBuffer | int(None) }}'
        unit_of_measurement: '%'
      - name: Sonnen Consumption_Avg
        unique_id: sonnen_status_Consumption_Avg
        value_template: '{{ value_json.Consumption_Avg | int(None) }}'
        unit_of_measurement: W
        device_class: power
        state_class: measurement
      - name: Sonnen Consumption_W
        unique_id: sonnen_status_Consumption_W
        value_template: '{{ value_json.Consumption_W | int(None) }}'
        unit_of_measurement: W
        device_class: power
        state_class: measurement
      - name: Sonnen Fac
        unique_id: sonnen_status_Fac
        value_template: '{{ value_json.Fac | int(None) }}'
        unit_of_measurement: Hz
        device_class: frequency
        state_class: measurement
      - name: Sonnen GridFeedIn_W
        unique_id: sonnen_status_GridFeedIn_W
        value_template: '{{ value_json.GridFeedIn_W | int(None) }}'
        unit_of_measurement: W
        device_class: power
        state_class: measurement
      - name: Sonnen OperatingMode
        unique_id: sonnen_status_OperatingMode
        value_template: >
          {% if value_json.OperatingMode == "1" %}
            Manual charging or discharging via API
          {% elif value_json.OperatingMode == "2" %}
            Automatic Self Consumption
          {% else %}
            {{ None }}
          {% endif %}
        device_class: enum
      - name: Sonnen Pac_total_W
        unique_id: sonnen_status_Pac_total_W
        value_template: '{{ value_json.Pac_total_W | int(None) }}'
        unit_of_measurement: W
        device_class: power
        state_class: measurement
      - name: Sonnen Production_W
        unique_id: sonnen_status_Production_W
        value_template: '{{ value_json.Production_W | int(None) }}'
        unit_of_measurement: W
        device_class: power
        state_class: measurement
      - name: Sonnen RSOC
        unique_id: sonnen_status_RSOC
        value_template: '{{ value_json.RSOC | int(None) }}'
        unit_of_measurement: '%'
        device_class: battery
        state_class: measurement
      - name: Sonnen RemainingCapacity_Wh
        unique_id: sonnen_status_RemainingCapacity_Wh
        value_template: '{{ value_json.RemainingCapacity_Wh | int(None) }}'
        unit_of_measurement: Wh
        device_class: energy_storage
      - name: Sonnen Sac1
        unique_id: sonnen_status_Sac1
        value_template: '{{ value_json.Sac1 | int(None) }}'
        unit_of_measurement: VA
        device_class: apparent_power
        state_class: measurement
      - name: Sonnen SystemStatus
        unique_id: sonnen_status_SystemStatus
        value_template: '{{ value_json.SystemStatus }}'
        device_class: enum
      - name: Sonnen Timestamp
        unique_id: sonnen_status_Timestamp
        value_template: '{{ strptime(value_json.Timestamp, "%Y-%m-%d %H:%M:%S") | as_local }}'
        device_class: timestamp
      - name: Sonnen USOC
        unique_id: sonnen_status_USOC
        value_template: '{{ value_json.USOC | int(None) }}'
        unit_of_measurement: '%'
        device_class: battery
        state_class: measurement
      - name: Sonnen Uac
        unique_id: sonnen_status_Uac
        value_template: '{{ value_json.Uac | int(None) }}'
        unit_of_measurement: V
        device_class: voltage
        state_class: measurement
      - name: Sonnen Ubat
        unique_id: sonnen_status_Ubat
        value_template: '{{ value_json.Ubat | int(None) }}'
        unit_of_measurement: V
        device_class: voltage
        state_class: measurement
    binary_sensor:
      - name: Sonnen BatteryCharging
        unique_id: sonnen_status_BatteryCharging
        value_template: '{{ value_json.BatteryCharging }}'
        device_class: battery_charging
      - name: Sonnen BatteryDischarging
        unique_id: sonnen_status_BatteryDischarging
        value_template: '{{ value_json.BatteryDischarging }}'
        device_class: power
      - name: Sonnen FlowConsumptionBattery
        unique_id: sonnen_status_FlowConsumptionBattery
        value_template: '{{ value_json.FlowConsumptionBattery }}'
        device_class: power
      - name: Sonnen FlowConsumptionGrid
        unique_id: sonnen_status_FlowConsumptionGrid
        value_template: '{{ value_json.FlowConsumptionGrid }}'
        device_class: power
      - name: Sonnen FlowConsumptionProduction
        unique_id: sonnen_status_FlowConsumptionProduction
        value_template: '{{ value_json.FlowConsumptionProduction }}'
        device_class: power
      - name: Sonnen FlowGridBattery
        unique_id: sonnen_status_FlowGridBattery
        value_template: '{{ value_json.FlowGridBattery }}'
        device_class: power
      - name: Sonnen FlowProductionBattery
        unique_id: sonnen_status_FlowProductionBattery
        value_template: '{{ value_json.FlowProductionBattery }}'
        device_class: battery_charging
      - name: Sonnen FlowProductionGrid
        unique_id: sonnen_status_FlowProductionGrid
        value_template: '{{ value_json.FlowProductionGrid }}'
        device_class: power
      - name: Sonnen IsSystemInstalled
        unique_id: sonnen_status_IsSystemInstalled
        value_template: '{{ value_json.IsSystemInstalled }}'
      - name: Sonnen dischargeNotAllowed
        unique_id: sonnen_status_dischargeNotAllowed
        value_template: '{{ value_json.dischargeNotAllowed }}'
      - name: Sonnen generator_autostart
        unique_id: sonnen_status_generator_autostart
        value_template: '{{ value_json.generator_autostart }}'

  - resource: http://IP_of_Battery/api/v2/powermeter
    headers:
      Auth-Token: !secret sonnen_api_token
    scan_interval: 15
    sensor:
      - name: Sonnen solar production Wh
        unique_id: sonnen_powermeter_solar_production
        # json_attributes_path: "$[0]"
        value_template: '{{ value_json[0].kwh_imported }}'
        unit_of_measurement: Wh
        device_class: energy
      - name: Sonnen house consumption Wh
        unique_id: sonnen_powermeter_house_consumption
        # json_attributes_path: "$[1]"
        value_template: '{{ value_json[1].kwh_imported }}'
        unit_of_measurement: Wh
        device_class: energy

  - resource: http://IP_of_Battery:80/api/v2/battery
    headers:
      Auth-Token: !secret sonnen_api_token
    scan_interval: 15
    sensor:
      - name: Sonnen chargecurrentlimit
        unique_id: sonnen_battery_chargecurrentlimit
        value_template: '{{ value_json.chargecurrentlimit }}'
        unit_of_measurement: A
        device_class: current
        state_class: measurement
      - name: Sonnen cyclecount
        unique_id: sonnen_battery_cyclecount
        value_template: '{{ value_json.cyclecount | int(None) }}'
        state_class: measurement
      - name: Sonnen dischargecurrentlimit
        unique_id: sonnen_battery_dischargecurrentlimit
        value_template: '{{ value_json.dischargecurrentlimit }}'
        unit_of_measurement: A
        device_class: current
        state_class: measurement
      - name: Sonnen fullchargecapacity
        unique_id: sonnen_battery_fullchargecapacity
        value_template: '{{ value_json.fullchargecapacity }}'
        unit_of_measurement: Ah
        state_class: measurement
      - name: Sonnen fullchargecapacitywh
        unique_id: sonnen_battery_fullchargecapacitywh
        value_template: '{{ value_json.fullchargecapacitywh }}'
        unit_of_measurement: Wh
        device_class: energy
      - name: Sonnen maximumcelltemperature
        unique_id: sonnen_battery_maximumcelltemperature
        value_template: '{{ value_json.maximumcelltemperature }}'
        unit_of_measurement: '°C'
        device_class: temperature
        state_class: measurement
      - name: Sonnen maximumcellvoltage
        unique_id: sonnen_battery_maximumcellvoltage
        value_template: '{{ value_json.maximumcellvoltage }}'
        unit_of_measurement: V
        device_class: voltage
        state_class: measurement
      - name: Sonnen maximumcellvoltagenum
        unique_id: sonnen_battery_maximumcellvoltagenum
        value_template: '{{ value_json.maximumcellvoltagenum }}'
        device_class: enum
      - name: Sonnen maximummodulecurrent
        unique_id: sonnen_battery_maximummodulecurrent
        value_template: '{{ value_json.maximummodulecurrent }}'
        unit_of_measurement: A
        device_class: current
        state_class: measurement
      - name: Sonnen maximummoduledcvoltage
        unique_id: sonnen_battery_maximummoduledcvoltage
        value_template: '{{ value_json.maximummoduledcvoltage }}'
        unit_of_measurement: V
        device_class: voltage
        state_class: measurement
      - name: Sonnen maximummoduletemperature
        unique_id: sonnen_battery_maximummoduletemperature
        value_template: '{{ value_json.maximummoduletemperature }}'
        unit_of_measurement: '°C'
        device_class: temperature
        state_class: measurement
      - name: Sonnen minimumcelltemperature
        unique_id: sonnen_battery_minimumcelltemperature
        value_template: '{{ value_json.minimumcelltemperature }}'
        unit_of_measurement: '°C'
        device_class: temperature
        state_class: measurement
      - name: Sonnen minimumcellvoltage
        unique_id: sonnen_battery_minimumcellvoltage
        value_template: '{{ value_json.minimumcellvoltage }}'
        unit_of_measurement: V
        device_class: voltage
        state_class: measurement
      - name: Sonnen minimumcellvoltagenum
        unique_id: sonnen_battery_minimumcellvoltagenum
        value_template: '{{ value_json.minimumcellvoltagenum }}'
        device_class: enum
      - name: Sonnen minimummodulecurrent
        unique_id: sonnen_battery_minimummodulecurrent
        value_template: '{{ value_json.minimummodulecurrent }}'
        unit_of_measurement: A
        device_class: current
        state_class: measurement
      - name: Sonnen minimummoduledcvoltage
        unique_id: sonnen_battery_minimummoduledcvoltage
        value_template: '{{ value_json.minimummoduledcvoltage }}'
        unit_of_measurement: V
        device_class: voltage
        state_class: measurement
      - name: Sonnen minimummoduletemperature
        unique_id: sonnen_battery_minimummoduletemperature
        value_template: '{{ value_json.minimummoduletemperature }}'
        unit_of_measurement: '°C'
        device_class: temperature
        state_class: measurement
      - name: Sonnen nominalmoduledcvoltage
        unique_id: sonnen_battery_nominalmoduledcvoltage
        value_template: '{{ value_json.nominalmoduledcvoltage }}'
        unit_of_measurement: V
        device_class: voltage
        state_class: measurement
      - name: Sonnen relativestateofcharge
        unique_id: sonnen_battery_relativestateofcharge
        value_template: '{{ value_json.relativestateofcharge }}'
        unit_of_measurement: '%'
        device_class: battery
        state_class: measurement
      - name: Sonnen remainingcapacity
        unique_id: sonnen_battery_remainingcapacity
        value_template: '{{ value_json.remainingcapacity }}'
        unit_of_measurement: Ah
        state_class: measurement
      - name: Sonnen systemaveragecurrent
        unique_id: sonnen_battery_systemaveragecurrent
        value_template: '{{ value_json.systemaveragecurrent }}'
        unit_of_measurement: A
        device_class: current
        state_class: measurement
      - name: Sonnen systemcurrent
        unique_id: sonnen_battery_systemcurrent
        value_template: '{{ value_json.systemcurrent }}'
        unit_of_measurement: A
        device_class: current
        state_class: measurement
      - name: Sonnen systemdcvoltage
        unique_id: sonnen_battery_systemdcvoltage
        value_template: '{{ value_json.systemdcvoltage }}'
        unit_of_measurement: V
        device_class: voltage
        state_class: measurement
      - name: Sonnen systemstatus
        unique_id: sonnen_battery_systemstatus
        value_template: '{{ value_json.systemstatus | int(None) }}'
      - name: Sonnen usableremainingcapacity
        unique_id: sonnen_battery_usableremainingcapacity
        value_template: '{{ value_json.usableremainingcapacity }}'
        unit_of_measurement: Ah
        state_class: measurement
    binary_sensor:
      - name: Sonnen balancechargerequest
        unique_id: sonnen_battery_balancechargerequest
        value_template: '{{ value_json.balancechargerequest }}'
      - name: Sonnen systemalarm
        unique_id: sonnen_battery_systemalarm
        value_template: '{{ value_json.systemalarm }}'
        device_class: problem
      - name: Sonnen systemtime
        unique_id: sonnen_battery_systemtime
        value_template: '{{ value_json.systemtime }}'
      - name: Sonnen systemwarning
        unique_id: sonnen_battery_systemwarning
        value_template: '{{ value_json.systemwarning }}'
        device_class: problem

template:
  - sensor:
    - name: Sonnen discharge power
      unique_id: sonnen_discharge_power
      unit_of_measurement: W
      device_class: power
      state_class: measurement
      state: '{{ [0, states.sensor.sonnen_pac_total_w.state | int] | max }}'
    - name: Sonnen charge power
      unique_id: sonnen_charge_power
      unit_of_measurement: W
      device_class: power
      state_class: measurement
      state: '{{ [0, states.sensor.sonnen_pac_total_w.state | int] | min | abs}}'

    # For https://github.com/reptilex/tesla-style-solar-power-card#complete-example-with-all-details
    - name: "Flow Solar to House"
      unique_id: flow_solar_to_house
      device_class: power
      state_class: measurement
      unit_of_measurement: "W"
      # Assumption: all produced power is used first for the house.
      state: '{{ [states.sensor.sonnen_consumption_w.state | int, states.sensor.sonnen_production_w.state | int] | min }}'
    - name: "Flow Solar to Battery"
      unique_id: flow_solar_to_battery
      device_class: power
      state_class: measurement
      unit_of_measurement: "W"
      # Assumption: all produced power is used first for the house, so what remains can be used for charging (but might not be used for it).
      state: '{{ [0, [states.sensor.sonnen_charge_power.state | int, states.sensor.sonnen_production_w.state | int - states.sensor.sonnen_consumption_w.state | int] | min ] | max }}'
    - name: "Flow Solar to Grid"
      unique_id: flow_solar_to_grid
      device_class: power
      state_class: measurement
      unit_of_measurement: "W"
      # Assumption: all produced power is used first for the house, then the battery. What remains is feed to the grid.
      state: '{{ [0, states.sensor.sonnen_production_w.state | int - states.sensor.sonnen_consumption_w.state | int - states.sensor.sonnen_charge_power.state | int] | max }}'
    - name: "Flow Grid to Battery"
      unique_id: flow_grid_to_battery
      device_class: power
      state_class: measurement
      unit_of_measurement: "W"
      # Assumption: The missing enery for charging the battery must come from the grid.
      state: '{{ [0, states.sensor.sonnen_charge_power.state | int - states.sensor.flow_solar_to_battery.state | int] | max }}'
    - name: "Flow Grid to House"
      unique_id: flow_grid_to_house
      device_class: power
      state_class: measurement
      unit_of_measurement: "W"
      # Assumption: The missing enery for the house must come first from the battery.
      state: '{{ [0, states.sensor.sonnen_consumption_w.state | int - states.sensor.sonnen_production_w.state | int - states.sensor.sonnen_discharge_power.state | int] | max }}'
    - name: "Flow Battery to House"
      unique_id: flow_battery_to_house
      device_class: power
      state_class: measurement
      unit_of_measurement: "W"
      # Assumption: The remaining missing enery for the house must come from the grid.
      state: '{{ [0, states.sensor.sonnen_consumption_w.state | int - states.sensor.sonnen_production_w.state | int - states.sensor.flow_grid_to_house.state | int] | max }}'
    - name: "Flow Battery to Grid"
      unique_id: flow_battery_to_grid
      device_class: power
      state_class: measurement
      unit_of_measurement: "W"
      # Assumption: any unused battery power must go to the grid.
      state: '{{ [0, states.sensor.sonnen_discharge_power.state | int - states.sensor.flow_battery_to_house.state | int] | max }}'

sensor:
  - name: Sonnen discharge energy
    unique_id: sonnen_discharge_energy
    platform: integration
    source: sensor.sonnen_discharge_power
    unit_prefix: k
    method: left
  - name: Sonnen charge energy
    unique_id: sonnen_charge_energy
    platform: integration
    source: sensor.sonnen_charge_power
    unit_prefix: k
    method: left

binary_sensor:
  - name: Sonnen power flow directions
    unique_id: sonnen_power_flow_direction_booleans
    platform: group
    entities:
      - binary_sensor.sonnen_flowconsumptionbattery
      - binary_sensor.sonnen_flowconsumptiongrid
      - binary_sensor.sonnen_flowconsumptionproduction
      - binary_sensor.sonnen_flowgridbattery
      - binary_sensor.sonnen_flowproductionbattery
      - binary_sensor.sonnen_flowproductiongrid

switch:
  - name: Sonnen battery manual mode
    platform: rest
    resource: http://IP_of_Battery:80/api/v2/configurations
    method: put
    headers:
      Auth-Token: !secret sonnen_api_token
      Content-Type: application/x-www-form-urlencoded
    body_on: "EM_OperatingMode=1"
    body_off: "EM_OperatingMode=2"
    is_on_template: '{{ value_json["EM_OperatingMode"] == "1" }}'

input_number:
  sonnen_charge_setpoint:
    name: Sonnen battery charge setpoint
    min: -4000
    initial: 0
    max: 4000
    step: 250
    unit_of_measurement: W
    mode: slider
    icon: mdi:power-plug-battery-outline

rest_command:
  sonnen_battery_set_manual_power:
    url: >
      {% if states.input_number.sonnen_charge_setpoint.state | int >= 0 -%}
        http://IP_of_Battery/api/v2/setpoint/charge/{{states.input_number.sonnen_charge_setpoint.state | int | abs}}
      {%- else -%}
        http://IP_of_Battery/api/v2/setpoint/discharge/{{states.input_number.sonnen_charge_setpoint.state | int | abs}}
      {%- endif %}
    method: post
    headers:
      Auth-Token: !secret sonnen_api_token

automation:
  - alias: "Update charge config on input change"
    id: manual_sonnen_control_input_change
    mode: single
    triggers:
      - entity_id:
          - input_number.sonnen_charge_setpoint
        trigger: state
      - trigger: state
        entity_id:
          - switch.sonnen_battery_manual_mode
        to: "on"
        from: "off"
    conditions:
      - condition: state
        entity_id: switch.sonnen_battery_manual_mode
        state: "on"
    actions:
      - action: rest_command.sonnen_battery_set_manual_power
        metadata: {}
        data: {}

Hi!
I’m having some issues with the sonnen webhook API. I am successfully sending data with a webhook from the sonnen batterie 10 to node red. The problem is that I get “GridFeedIn_W”:0" from the webhook when it is clearly exporting to the grid. The same time I get GridFeedIn_W: 8130 from the JSON API.

The webhook is correctly sending data for SOC and for example “Consumption_W”:804.

Anyone else have this problem? Am I doing anything wrong?

Complete response from the webhook: https://bin.sibe.nu/GSnrn0PrCLf
Complete response fron json api: https://bin.sibe.nu/n5AMErqqJpa

Sonnen Software: 1.18.4, Release-Channel: stable

Hi all,

I’ve been working with my Son­nen system using the v2 local API to try to force battery discharge.

What I’m trying to do:

• Switch to Manual mode (EM_OperatingMode=1)

• Use POST /api/v2/setpoint/discharge/3300 to force approx 3.3 kW discharge

What I observe instead:

• When solar + battery total ≈3.3 kW, battery only supplies the “rest” (so solar + battery = ~3.3 kW)

• If solar > 0, the battery contribution is reduced. The system seems to treat the setpoint as total inverter output (Pac_total_W) rather than absolute battery discharge.

• I’ve verified that Manual mode is active, no ToU schedule is overriding, and still this behaviour appears.

What I’d like to know:

• Has anyone gotten true “battery only” discharge (battery → house/grid) via this endpoint on a similar firmware/hardware?

• Did you have to use a different endpoint, modbus register write, or installer-enabled firmware flag to get battery current control?

• Are there any hidden flags like dischargeNotAllowed / chargeNotAllowed that I should check?

• Any suggestions on how to force the battery to discharge regardless of solar contribution?

I can share detailed status logs, token behaviour, and what I’ve tried. Appreciate any pointers from those who have cracked this. Thanks in advance!

Yes I manage the charge and discharge rate of my battery in manual mode all the time. I use Node-Red to manage this and the EMS I use is EMHASS which is an add-on to HA that uses machine learning (MPC) to calculate bat charging and discharging and things like EV charging and pool pump operation.

But the battery API part is all Node-red and should be easily transcribed into HA rest_command YAML.

My docs are here

My shell commands:

set_operating_mode_sonnen_battery: curl -X PUT -d EM_OperatingMode={{ operating_mode }} --header 'Auth-Token{{':'}} {{ token }}' {{ api_endpoint }}
dis_charge_sonnen_battery: curl -d -H -X POST --header 'Auth-Token{{':'}} {{ token }}' {{ api_endpoint }}/{{dis_charge_command}}/{{ dis_charge_value }}

Automation examples:

- id: 'sonnen_8_manual_charge'
  alias: "Sonnen 8 manual charge"
  triggers: []
  conditions: []
  actions:
    - action: shell_command.dis_charge_sonnen_battery
      data:
        token: !secret sonnen_8_api_token
        api_endpoint: !secret sonnen_8_setpoint_api_endpoint
        dis_charge_command: charge
        dis_charge_value: 0
  mode: single
- id: 'sonnen_8_manual_operating_mode'
  alias: "Sonnen 8 manual operating mode"
  triggers: []
  conditions: []
  actions:
    - action: shell_command.set_operating_mode_sonnen_battery
      data:
        operating_mode: 1
        token: !secret sonnen_8_api_token
        api_endpoint: !secret sonnen_8_configurations_api_endpoint
  mode: single
- id: 'sonnen_8_automatic_operating_mode'
  alias: "Sonnen 8 automatic operating mode"
  triggers: []
  conditions: []
  actions:
    - action: shell_command.set_operating_mode_sonnen_battery
      data:
        operating_mode: 2
        token: !secret sonnen_8_api_token
        api_endpoint: !secret sonnen_8_configurations_api_endpoint
  mode: single

I've been dabbling with controlling my Sonnen battery (eco 8.2), using the many examples and approaches documented in this excellent thread (BIG THANKS to all the contributors).
One thing that I noticed is that when I send a setpoint discharge command to the battery with a value of 1500W or more, it reboots the inverter, taking the battery off-grid and unable to charge or discharge for about 3 minutes, until everything has reinitialised and recovered.
Has anyone noticed similar issues in your automations, and have you found a way around it?
I contacted Sonnen Support about this but haven't received an acknowledgement or support for this issue yet.
If I let the Sonnen battery do its own thing (i.e. self-consumption or time-of-use mode), it has no problems discharging at higher rates, up to 2300W (which is the maximum output the inverter can provide for my system). That makes me wonder if there is a threshold setting somewhere in the API that I might have missed.
My battery is running Firmware Version 1.31.10.4176380, Release Channel stable, Software Version 1.31.10.

I had issues with my eco 8.2 for several months. I also have a "Frankenstein" setup, in combination with a Sonnen 10 and Sonnen has been unresponsive, even following the letters of my lawyer.
What I can say is that with software v. 1.31.10, firmware v. 1.31.10.4176380, the problem with charge/discharge API commands seem to have been solved (not sure how much it was related to the software itself or the interaction with Sonnen 10 - which is was the result of my investigation). BTW I managed to disable automatic updates with my installer.