Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feature request: show where battery is charging from #422

Open
molekuul opened this issue Jan 6, 2025 · 3 comments
Open

Feature request: show where battery is charging from #422

molekuul opened this issue Jan 6, 2025 · 3 comments

Comments

@molekuul
Copy link

molekuul commented Jan 6, 2025

In the optimization results, you see when the battery is charging, however you don’t see where the charging energy is provided by. Please add a output showing if the battery charging get it’s energy from the PV or from the GRID. This makes it easier to automate battery charging when you have a hybrid inverter, such as the growatt inverters.

@radim2tej
Copy link
Contributor

For battery management I use the following sensor:

sensor:
  - platform: template
    sensors:
      emhass_battery_control:
        unique_id: emhass_battery_control
        value_template: >-
          {% if states('sensor.p_batt_forecast') | float < -300 and states('sensor.p_grid_forecast') | float > 300.0 %}  
            {{ 'charge' }}
          {% elif states('sensor.p_batt_forecast') | float > 300.0 and states('sensor.p_grid_forecast') | float < -300.0 %}
            {{ 'discharge' }}
          {% elif states('sensor.p_batt_forecast') | float == 0 %}
            {{ 'idle' }}
          {% else %} 
            {{ 'normal' }}                          
          {% endif %}

The automation then controls charging up to the SOC maximum, discharging up to the SOC maximum, not using the battery and normal operation. I use Goodwe GW10k-ET hybrid inverter.

@nejcsu
Copy link

nejcsu commented Jan 8, 2025

How do you instruct the inverter to go into charge/discharge/idle? I use a Deye inverter, and it looks like they only support six different time periods, where you can set charge/discharge parameters and limits.

@radim2tej
Copy link
Contributor

I'm using a Goodw GW10K-ET and an experimental integration that can charge and discharge in economy inverter mode. I solve the idle state by setting the depth of discharge to 95%. Since I don't know if the changes are written to the internal eeprom of the inverter, a check is made before each change to see if the change is necessary.

alias: EMHASS battery control
description: use battery by EMHASS
triggers:
  - trigger: state
    entity_id:
      - sensor.emhass_battery_control
  - trigger: state
    entity_id:
      - sensor.battery_state_of_charge
  - trigger: state
    entity_id:
      - sensor.soc_batt_forecast
  - trigger: state
    entity_id:
      - sensor.final_sell_kwh
conditions: []
actions:
  - alias: charge or idle battery_control for depth of discharge
    if:
      - condition: or
        conditions:
          - condition: state
            entity_id: sensor.emhass_battery_control
            state: charge
          - condition: state
            entity_id: sensor.emhass_battery_control
            state: idle
    then:
      - alias: disabling battery usage in charge and idle battery_control
        if:
          - alias: battery depth of discharge is below 95%
            condition: numeric_state
            entity_id: number.goodwe_maximum_vybiti_v_siti
            above: 5
        then:
          - alias: disable battery usage by setting the depth of discharge to 95%
            action: number.set_value
            metadata: {}
            data:
              value: 5
            target:
              entity_id: number.goodwe_maximum_vybiti_v_siti
    else:
      - alias: enable battery usage in normal and discharge battery_control
        if:
          - alias: battery depth of discharge is above 20%
            condition: numeric_state
            entity_id: number.goodwe_maximum_vybiti_v_siti
            below: 80
        then:
          - alias: enable battery use by setting the discharge depth to 20%
            action: number.set_value
            metadata: {}
            data:
              value: 80
            target:
              entity_id: number.goodwe_maximum_vybiti_v_siti
  - alias: overflow control at negative prices
    if:
      - condition: numeric_state
        entity_id: number.final_sell_kwh
        below: 0.2
    then:
      - alias: enable grid supply control
        if:
          - alias: supply control is off
            condition: state
            entity_id: switch.goodwe_rizeni_dodavky_do_site
            state: "off"
        then:
          - alias: mains supply control switched on
            entity_id: switch.goodwe_rizeni_dodavky_do_site
            action: homeassistant.turn_on
      - alias: disable mains overflows
        if:
          - alias:supply limit is not 0
            condition: numeric_state
            entity_id: number.goodwe_limit_dodavky_do_site
            above: 0
        then:
          - alias: set site delivery limit
            action: number.set_value
            metadata: {}
            data:
              value: 0
            target:
              entity_id: number.goodwe_limit_dodavky_do_site
    else:
      - alias: control discharge battery_control
        if:
          - condition: state
            entity_id: sensor.emhass_battery_control
            state: discharge
        then:
          - alias: enable grid supply control
            if:
              - alias: supply control is off
                condition: state
                entity_id: switch.goodwe_rizeni_dodavky_do_site
                state: "off"
            then:
              - alias: supply control to the network is switched on
                entity_id: switch.goodwe_rizeni_dodavky_do_site
                action: homeassistant.turn_on
          - alias: limit power to grid to reserved/allowed
            if:
              - alias: supply limit is not 6400W
                condition: template
                value_template: >-
                  {{ states('number.goodwe_limit_dodavky_do_site') | int(0) !=
                  6400 }}
            then:
              - alias: set site supply limit
                action: number.set_value
                metadata: {}
                data:
                  value: 6400
                target:
                  entity_id: number.goodwe_limit_dodavky_do_site
        else:
          - alias: there are no negative prices or discharges to the grid, turn off control (for GoodWe reduce consumption by half to a third); cancel this section if the reserved/allowed power to the grid is greater than the kWp output of the panels
            if:
              - alias: supply management is switched on
                condition: state
                entity_id: switch.goodwe_rizeni_dodavky_do_site
                state: "on"
            then:
              - alias: switching off the network supply control
                entity_id: switch.goodwe_rizeni_dodavky_do_site
                action: homeassistant.turn_off
  - alias: charge battery_control to recharge the battery
    if:
      - condition: state
        entity_id: sensor.emhass_battery_control
        state: charge
      - condition: numeric_state
        entity_id: sensor.battery_state_of_charge
        below: sensor.soc_batt_forecast
    then:
      - alias: enable battery charging
        if:
          - alias: inverter is in echo_charge mode
            condition: state
            entity_id: select.goodwe_provozni_rezim_stridace
            state: eco_charge
        then: []
        else:
          - alias: enable battery charging by eco_charge mode
            action: select.select_option
            metadata: {}
            data:
              option: eco_charge
            target:
              entity_id: select.goodwe_provozni_rezim_stridace
    else:
      - alias: discharge battery_control to discharge the battery
        if:
          - condition: state
            entity_id: sensor.emhass_battery_control
            state: discharge
          - condition: numeric_state
            entity_id: sensor.battery_state_of_charge
            above: sensor.soc_batt_forecast
        then:
          - alias: enable battery discharge by eco_discharge mode
            if:
              - alias: inverter is in eco_discharge mode
                condition: state
                entity_id: select.goodwe_provozni_rezim_stridace
                state: eco_discharge
            then: []
            else:
              - alias: inverter in eco_discharge mode
                action: select.select_option
                metadata: {}
                data:
                  option: eco_discharge
                target:
                  entity_id: select.goodwe_provozni_rezim_stridace
        else:
          - alias: disable battery charging/discharging by general mode
            if:
              - alias: inverter is in general mode
                condition: state
                entity_id: select.goodwe_provozni_rezim_stridace
                state: general
            then: []
            else:
              - alias: inverter in general mode
                action: select.select_option
                metadata: {}
                data:
                  option: general
                target:
                  entity_id: select.goodwe_provozni_rezim_stridace
mode: single

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants