Habe das Thema jetzt wieder aufgegriffen, der Winter steht bevor und es wird wieder interessant. Ich habe versuchsweise ein YAML-Script dazu von ChatGPT erstellen lassen, bis hin zur Steuerung über Tibber-Preisdifferenz und SoC-Wert. Tw. sind Register verwendet von ChatGPT die ich in der Datei von SMA nicht finde, diese werden allerdings auch im Photovoltaikforum in entspr. Beiträgen genutzt.
Ich stelle das hier mal ein, was ChatGPT "produziert" hat. Bin mir allerdings höchst unsicher, ob das nutzbar und funktionsfähig ist (ich traue dem ganzen nicht so). Kommentare und Anregungen sind hoch erwünscht. Der Code enthält 2 Varianten:
Ich stelle das hier mal ein, was ChatGPT "produziert" hat. Bin mir allerdings höchst unsicher, ob das nutzbar und funktionsfähig ist (ich traue dem ganzen nicht so). Kommentare und Anregungen sind hoch erwünscht. Der Code enthält 2 Varianten:
YAML:
# ===============================
# SMA SBS2.5 Modbus Integration Zeitgesteurtes Laden aus dem Netz
# ===============================
modbus:
- name: sma_sbs25
type: tcp
host: 192.168.178.XX # IP-Adresse deines SBS2.5 anpassen
port: 502
sensors:
# --- Batterie ---
- name: "SBS2.5 Batterie SoC"
unit_of_measurement: "%"
address: 30845
input_type: holding
data_type: int32
scale: 0.1
precision: 1
- name: "SBS2.5 Batterie Leistung"
unit_of_measurement: "W"
address: 30865
input_type: holding
data_type: int32
scale: 1
precision: 0
# positiv = Entladung, negativ = Ladung
- name: "SBS2.5 Batterieladung Gesamt"
unit_of_measurement: "kWh"
address: 30593
input_type: holding
data_type: int64
scale: 0.001
precision: 3
- name: "SBS2.5 Batterieentladung Gesamt"
unit_of_measurement: "kWh"
address: 30597
input_type: holding
data_type: int64
scale: 0.001
precision: 3
# --- Netz ---
- name: "SBS2.5 Netzleistung"
unit_of_measurement: "W"
address: 30775
input_type: holding
data_type: int32
scale: 1
precision: 0
# positiv = Einspeisung, negativ = Bezug
- name: "SBS2.5 Netzbezug Gesamt"
unit_of_measurement: "kWh"
address: 30531
input_type: holding
data_type: int64
scale: 0.001
precision: 3
- name: "SBS2.5 Netzeinspeisung Gesamt"
unit_of_measurement: "kWh"
address: 30535
input_type: holding
data_type: int64
scale: 0.001
precision: 3
# --- Erzeugung PV/Wechselrichter ---
- name: "SBS2.5 AC-Leistung"
unit_of_measurement: "W"
address: 30775
input_type: holding
data_type: int32
scale: 1
precision: 0
- name: "SBS2.5 Gesamterzeugung"
unit_of_measurement: "kWh"
address: 30513
input_type: holding
data_type: int64
scale: 0.001
precision: 3
# --- Netz -> Batterie Laden ---
- name: "SBS2.5 Netz-Batterie Ladeleistung"
unit_of_measurement: "W"
address: 31393
input_type: holding
data_type: int32
scale: 1
precision: 0
- name: "SBS2.5 Netz-Batterie Ladeenergie Gesamt"
unit_of_measurement: "kWh"
address: 31397
input_type: holding
data_type: int64
scale: 0.001
precision: 3
# ===============================
# Buttons zum Erzwingen von Netzladung
# ===============================
button:
- platform: template
buttons:
erzwinge_netzladung:
name: "Batterie Netzladung Starten"
press:
service: modbus.write_register
data:
hub: sma_sbs25
unit: 3 # Modbus Unit-ID (meist 3, evtl. 126 prüfen!)
address: 40151 # Ladeleistungs-Sollwert
value: 2000 # Ladeleistung in W (hier: 2 kW aus Netz laden)
stoppe_netzladung:
name: "Batterie Netzladung Stoppen"
press:
service: modbus.write_register
data:
hub: sma_sbs25
unit: 3
address: 40151
value: 0 # 0 = keine erzwungene Netzladung
# ===============================
# Automationen: Nachtladung
# ===============================
automation:
- alias: "Nachtladung Starten"
trigger:
- platform: time
at: "02:00:00"
action:
- service: modbus.write_register
data:
hub: sma_sbs25
unit: 3
address: 40151
value: 2000 # Netzladung mit 2 kW starten
mode: single
- alias: "Nachtladung Stoppen"
trigger:
- platform: time
at: "04:00:00"
action:
- service: modbus.write_register
data:
hub: sma_sbs25
unit: 3
address: 40151
value: 0 # Netzladung stoppen
mode: single
# ===============================
# SMA SBS2.5 Modbus Integration abhängig von Tibberpreis und SoC
# ===============================
modbus:
- name: sma_sbs25
type: tcp
host: 192.168.178.XX # IP-Adresse deines SBS2.5 anpassen
port: 502
sensors:
# --- Batterie ---
- name: "SBS2.5 Batterie SoC"
unit_of_measurement: "%"
address: 30845
input_type: holding
data_type: int32
scale: 0.1
precision: 1
- name: "SBS2.5 Batterie Leistung"
unit_of_measurement: "W"
address: 30865
input_type: holding
data_type: int32
scale: 1
precision: 0
- name: "SBS2.5 Batterieladung Gesamt"
unit_of_measurement: "kWh"
address: 30593
input_type: holding
data_type: int64
scale: 0.001
precision: 3
- name: "SBS2.5 Batterieentladung Gesamt"
unit_of_measurement: "kWh"
address: 30597
input_type: holding
data_type: int64
scale: 0.001
precision: 3
# --- Netz ---
- name: "SBS2.5 Netzleistung"
unit_of_measurement: "W"
address: 30775
input_type: holding
data_type: int32
scale: 1
precision: 0
- name: "SBS2.5 Netzbezug Gesamt"
unit_of_measurement: "kWh"
address: 30531
input_type: holding
data_type: int64
scale: 0.001
precision: 3
- name: "SBS2.5 Netzeinspeisung Gesamt"
unit_of_measurement: "kWh"
address: 30535
input_type: holding
data_type: int64
scale: 0.001
precision: 3
# --- Erzeugung ---
- name: "SBS2.5 AC-Leistung"
unit_of_measurement: "W"
address: 30775
input_type: holding
data_type: int32
scale: 1
precision: 0
- name: "SBS2.5 Gesamterzeugung"
unit_of_measurement: "kWh"
address: 30513
input_type: holding
data_type: int64
scale: 0.001
precision: 3
# --- Netz -> Batterie Laden ---
- name: "SBS2.5 Netz-Batterie Ladeleistung"
unit_of_measurement: "W"
address: 31393
input_type: holding
data_type: int32
scale: 1
precision: 0
- name: "SBS2.5 Netz-Batterie Ladeenergie Gesamt"
unit_of_measurement: "kWh"
address: 31397
input_type: holding
data_type: int64
scale: 0.001
precision: 3
# ===============================
# Buttons zum manuellen Erzwingen von Netzladung
# ===============================
button:
- platform: template
buttons:
erzwinge_netzladung:
name: "Batterie Netzladung Starten"
press:
service: modbus.write_register
data:
hub: sma_sbs25
unit: 3
address: 40151
value: 2000 # 2 kW Netzladung
stoppe_netzladung:
name: "Batterie Netzladung Stoppen"
press:
service: modbus.write_register
data:
hub: sma_sbs25
unit: 3
address: 40151
value: 0 # Netzladung aus
# ===============================
# Automationen: Tibber-Preis + SoC-Steuerung
# ===============================
automation:
- alias: "Netzladung starten bei günstigem Tibber-Preis und SoC < 80%"
trigger:
- platform: state
entity_id: sensor.tibber_current_price
condition:
- condition: template
value_template: >
{{ (states('sensor.tibber_average_price') | float(0)) -
(states('sensor.tibber_current_price') | float(0)) >= 0.06 }}
- condition: numeric_state
entity_id: sensor.sbs25_batterie_soc
below: 80
action:
- service: modbus.write_register
data:
hub: sma_sbs25
unit: 3
address: 40151
value: 2000
mode: single
- alias: "Netzladung stoppen bei normalem Preis oder SoC >= 80%"
trigger:
- platform: state
entity_id: sensor.tibber_current_price
- platform: state
entity_id: sensor.sbs25_batterie_soc
condition:
- condition: or
conditions:
- condition: template
value_template: >
{{ (states('sensor.tibber_average_price') | float(0)) -
(states('sensor.tibber_current_price') | float(0)) < 0.06 }}
- condition: numeric_state
entity_id: sensor.sbs25_batterie_soc
above: 79.9
action:
- service: modbus.write_register
data:
hub: sma_sbs25
unit: 3
address: 40151
value: 0
mode: single