Akku Schutz Min SoC nach morgendlicher Außentemperatur - Kieft-C/Zendure-BKW-PV GitHub Wiki

HA Automation für zwei Hyper, kann natürlich abgewandelt werden für nur ein Gerät.

Vorraussetzungen:

  • Homeassistant ;-)
  • Zendure Integration
  • Sensor der Außentemperatur liefert

Mein setup: Hyper A - Outdoor, daher aggressivere Anhebung Hyper B - Indoor

alias: Z0 - Akku Schutz Min SoC nach morgendlicher Außentemperatur (A/B getrennt)
description: >
  Setzt die minimalen SoC-Grenzwerte der Hyper-Akkus abhängig von der
  Außentemperatur einmal täglich um 06:00 Uhr.
  Informiert zusätzlich, wenn der Außentemperatursensor 5 Minuten lang
  nicht verfügbar ist.
mode: single

triggers:
  - at: "06:00:00"
    trigger: time

  - trigger: state
    entity_id: sensor.aussentemperatur_www
    to:
      - unavailable
      - unknown
    for: "00:05:00"

conditions: []

variables:
  temp: "{{ states('sensor.aussentemperatur_www') | float(0) }}"
  sensor_ok: "{{ not states('sensor.aussentemperatur_www') in ['unavailable', 'unknown'] }}"

  soc_min_a_new: |
    {% if temp > 20 %}
      5
    {% elif temp > 15 %}
      10
    {% elif temp > 10 %}
      20
    {% elif temp > 5 %}
      30
    {% elif temp > 0 %}
      40
    {% else %}
      50
    {% endif %}

  soc_min_b_new: |
    {% if temp > 20 %}
      5
    {% elif temp > 15 %}
      5
    {% elif temp > 10 %}
      10
    {% elif temp > 5 %}
      15
    {% elif temp > 0 %}
      20
    {% else %}
      25
    {% endif %}

  soc_min_a_old: "{{ states('number.hyper_2000_min_soc') | float(0) }}"
  soc_min_b_old: "{{ states('number.hyper_2000_b_min_soc') | float(0) }}"

actions:
  - choose:

      # 🔴 Außentemperatur-Sensor seit 5 Minuten nicht verfügbar
      - conditions:
          - condition: template
            value_template: "{{ not sensor_ok }}"
        sequence:
          - action: notify.persistent_notification
            data:
              title: "⚠ Außentemperatur nicht verfügbar"
              message: >
                Der Sensor 'sensor.aussentemperatur_www' ist seit mindestens
                5 Minuten nicht verfügbar ({{ states('sensor.aussentemperatur_www') }}).
                Die automatische Min-SoC-Anpassung wurde nicht ausgeführt.

      # 🟢 Sensor OK → Min-SoC ggf. anpassen
      - conditions:
          - condition: template
            value_template: "{{ sensor_ok }}"
          - condition: template
            value_template: >
              {{ soc_min_a_new != soc_min_a_old or soc_min_b_new != soc_min_b_old }}
        sequence:

          - if:
              - condition: template
                value_template: "{{ soc_min_a_new != soc_min_a_old }}"
            then:
              - action: number.set_value
                target:
                  entity_id: number.hyper_2000_min_soc
                data:
                  value: "{{ soc_min_a_new }}"

          - if:
              - condition: template
                value_template: "{{ soc_min_b_new != soc_min_b_old }}"
            then:
              - action: number.set_value
                target:
                  entity_id: number.hyper_2000_b_min_soc
                data:
                  value: "{{ soc_min_b_new }}"

          - action: notify.persistent_notification
            data:
              title: "🔋 Min SoC Anpassung"
              message: >
                Außentemperatur: {{ temp | round(1) }} °C
                Hyper A: {{ soc_min_a_old }} % → {{ soc_min_a_new }} %
                Hyper B: {{ soc_min_b_old }} % → {{ soc_min_b_new }} %