Page 1 of 1

Change the Work Mode based on battery SoC

Posted: Mon Nov 11, 2024 12:25 pm
by AndyB
Hi
With the winter months now here and the sun making less of an appearance, I am trying to write an automation so that if my battery SoC is above say 95%, the system will switch to Feed-In. If the charge drops below the threshold, the system switches back to Self-Use.
This way if is a bad day for solar ill use all thats available and keep the battery topped up for night. If its a good day, i dont need to wait until its squeezed the last drop of power into the battery before i start exporting.

I am playing with the settings, as i dont find the automation method very intuitive.
Can anyone advise what i am looking for to change the Work Mode please, then ill try and figure out the If, Then, Else part of the statement

Thanks

Re: Change the Work Mode based on battery SoC

Posted: Mon Nov 11, 2024 2:36 pm
by AndyB
I may have actually figured this.
Does this look right? It should check the Battery SoC every 5 minutes between sunrise and sunset. If the battery is above 95%, set the Work Mode to Feed-In. If it drops below 95%, set it back to Self Use

Code: Select all

alias: Set Work Mode based on SoC
description: Set Work Mode of Inverter, based on the battery being above 95%
triggers:
  - trigger: time_pattern
    minutes: /5
conditions:
  - condition: sun
    before: sunset
    after: sunrise
actions:
  - if:
      - condition: numeric_state
        entity_id: sensor.battery_soc
        above: 95
    then:
      - device_id: **my specific inverter id**
        domain: select
        entity_id: **my specific entitiy id**
        type: select_option
        option: Feed-in First
    else:
      - device_id: **my specific inverter id**
        domain: select
        entity_id: **my specific entitiy id**
        type: select_option
        option: Self Use
mode: single

Re: Change the Work Mode based on battery SoC

Posted: Tue Nov 12, 2024 8:19 am
by marcus
Hi Andy,

Not saying this is more correct, but I have something similar working during summer when I set mode to Force Discharge at peak rate. It's also making use of a

Code: Select all

input_number.target_soc_force_export
created as Settings > Device & Services > Helper tab, which allows playing with the value from the UI
helper.png
and added to a dash
dash.png
My automation below (looking at again could be neater with a condition on time like you have done with the _sun_) but note the action works setting mode like this

Code: Select all

alias: >-
  Energy: Battery Switch Work mode from Force Discharge to Feed-in First - when target Force Discharge SoC level achieved
description: >-
  Sets the work mode back to Feed-in First (from Force Discharge) once the
  target SoC acheived. - it 'polls' every 5 minutes during the 16th, 17th & 18th
  hours to check condition
trigger:
  - platform: time_pattern
    hours: 16
    minutes: /5
  - platform: time_pattern
    hours: 17
    minutes: /5
  - platform: time_pattern
    hours: 18
    minutes: /5
condition:
  - and:
      - condition: template
        value_template: "{{ states('select.work_mode') == 'Force Discharge' }}"
      - condition: template
        value_template: >-
          {{ states('sensor.battery_soc')|float(0) <=
          states('input_number.target_soc_force_export')|float(0) }}
action:
  - variables:
      workmode: Feed-in First
  - service: select.select_option
    target:
      entity_id: select.work_mode
    data:
      option: "{{ workmode }}"
mode: single
Hope that's useful to you, you might also find viewtopic.php?t=946 helpful as that's doing conditions on Battery SoC too

Re: Change the Work Mode based on battery SoC

Posted: Tue Nov 12, 2024 10:16 am
by AndyB
Thanks Marcus
You're bascially doing the same thing, just using Force Discharge and having a variable SoC percentage.
Interesting that your variable method is different to mine, as that was the bit i was originally struggling with