Discharge Settings on Home Assistant

10 comments started 2024-01-29 last 2024-01-31
Home Automation
W
#1 WillC

Now that spring is getting closer, we'll have excess electricity that I'd like to dump to the grid during the day for both environmental and financial reasons.

I'm trying to work out how to create automations in Home Assistant that say, for example, if I have >50% battery at 7pm, then discharge to the grid.

I've set my discharge times to all day and turned off discharge. I've also created an automation...
At 7pm:
Change eco to eco paused
Turn on Enable Discharge Schedule
Set Battery Power Reserve to 50%

This works fine, but then I want to stop discharging to grid when the battery hits 50%, but still discharge to the home.
Do I just need to create another automation so when the battery hits 50% I revert the above settings, or is there a better way?

D
#2 DD

WillC Do I just need to create another automation so when the battery hits 50% I revert the above settings, or is there a better way?

Do you actually need an automation at all? It sounds like you ought to be able to achieve this using just the static configuration on the inverter. Though the exact behaviour of timed DC discharge seems to depend on hardware/firmware model.

I'd try with just configuring a timed discharge (which leaves eco on) from 7pm, with a min battery SoC of 50%. I would try the experiment now, but solar is currently exceeding consumption, so I wouldn't be able to tell whether the battery would discharge to cover house load, or stop.

Though I guess that once you've gone the HA route, you probably have to do everything that way, else you have two captains trying to pilot the ship.

W
#3 WillC

I want 50% at 7, 40% at 8, 30% at 9, 20% at 10 and 10% at 11, which I can't set that up on the inverter.

D
#4 DD

Okay. Just FYI I've now tried the experiment, but got the "wrong" result - timed discharge with min battery SoC of 70% (above current value). It didn't dump the battery, which is good, but it also ran without eco mode, so all discharge was stopped, rather than going back to cover the house load as if the time had run out.

I guess it's like timed charge in reverse - if it reaches target before the time limit, the battery is effectively paused until the end of the time window.

W
#5 WillC

Yup, that's the issue I'm having. I think I need two rules for each slot. One to turn discharge on, and then one to turn it off again if the battery % hits the target. It's going to be a bit of a faff to set up.

D
#6 DD

WillC A different approach you could try... for overnight charging, I use a simple script which calculates the required rate of charge to get battery up to target SoC over the full cheap period. Maybe you could do the same in reverse: at 7pm, have a look at the Soc. If it's higher than 50%, calculate the discharge rate which will get you down to 10% at 11pm, and then set it discharging at that rate for the rest of the evening. If the rate is lower than 50%, then calculate at what time you want to start discharging in order to hit 40% at 8pm, 30% at 9pm etc. (eg if your battery is 9.5kWh, then 950W would take you down roughly 10% per hour, so just need to decide when to start).

Unfortunately, when you're forcing a discharge, it ignores house load. So if you put the kettle on, for example, it will draw from the grid to make up the difference.

N
#7 naltsta

WillC in my pre predbat days I had a load of these automation and one called “back to eco” that triggered at various points

G
#8 geoffreycoan

@WillC

This is a script I wrote in my very early days of Home Assistant, I'd do it differently now with trigger id's to select the different branches in the script (e.g. different stepped SoC levels).

It does a force discharge down to a SoC percentage held in a helper entity

I now use predbat to manage my battery which will automatically export when I've got spare capacity over and above the predicted evening load

alias: G182 Inv1 Start & stop flux peak discharge
description: ""
trigger:
  - platform: time_pattern
    hours: "17"
    minutes: /5
    enabled: true
  - platform: time_pattern
    hours: "18"
    minutes: /5
  - platform: time
    at:
      - "19:00"
      - "19:15"
      - "19:30"
action:
  - if:
      - condition: or
        conditions:
          - condition: time
            after: "18:59"
          - condition: numeric_state
            entity_id: sensor.givtcp_xxx_soc
            below: input_number.flux_peak_export_minimum_soc
    then:
      - service: select.select_option
        target:
          entity_id: select.givtcp_xxx_mode
        data:
          option: Eco
      - service: select.select_option
        target:
          entity_id: select.givtcp_xxx_discharge_end_time_slot_1
        data:
          option: "00:00:00"
    else:
      - if:
          - condition: and
            conditions:
              - condition: numeric_state
                entity_id: sensor.givtcp_xxx_soc
                above: input_number.flux_peak_export_minimum_soc
              - condition: not
                conditions:
                  - condition: state
                    entity_id: select.givtcp_xxx_mode
                    state: Timed Export
        then:
          - service: select.select_option
            target:
              entity_id: select.givtcp_xxx_discharge_end_time_slot_1
            data:
              option: "23:59:00"
          - delay:
              hours: 0
              minutes: 0
              seconds: 10
              milliseconds: 0
          - service: select.select_option
            target:
              entity_id: select.givtcp_xxx_mode
            data:
              option: Timed Export
mode: single
D
#9 DD

DD this has given me an idea... I was lamenting that inverter only offers me a single timed pause, but multiple charge and discharge slots. I can implement pause-discharge by using one of the timed discharge slots, but with a min SoC of 100%.
(This is for inhibiting battery discharge if IOG gives me bonus cheap-rate slots. I don't need to charge battery, but do want to inhibit discharge.)

W
#10 WillC

Maybe I should just try Predbat!