OpenHAB SMA Wechselrichter mittels Modbus einbinden
Hier findet ihr eine Beispiel Konfiguration für openHAB um via ModBus die Daten der SMA Wechselrichter eurer PV Anlage auszulesen. Ich kann so alle gewünschten Werte auslesen. Mittels einer Regeldatei ist noch der Gesamtstromverbrauch berechnet. Ebenfalls berechnet dieser die Einnahmen durch Einspeisung und auch die Ausgaben für den Zukauf vom Stromanbieter.
Ich habe die folgenden SMA Wechselrichter im Einsatz:
- SMA Sunny Tripower 8 (Solarpanels)
- SMA SunnyBoy Storage 3.7-10 (BYD Batteriespeicher)
Die Anleitung sollte aber auch sehr gut für andere Wechselrichter von SMA adaptierbar sein. Die aktuellen Modbus IDs bekommt ihr bei SMA zum herunterladen.
Alle unten stehenden Dateien findet ihr in diesem GitHub Repository
Aktivieren von Modbus auf den Wechselrichtern
Dies müsst ihr entweder durch eure PV Fachleute konfigurieren lassen, oder falls ihr die benötigten Installateur
Rechte habt direkt über die Webkonfiguration der Wechselrichter.
Auf den Wechselrichter findet ihr die Einstellung unter Geräteparameter --> Externe Kommuniktion
. Wenn ihr den Wert bearbeiten wollt, müsst ihr zuerst den Button Parameter bearbeiten
anklicken:
Nach dem ihr das Ganze gespeichert habt, sollte der Wechselrichter via IP / DNS Name und Modbus TCP 502 erreichbar sein.
openHAB Vorbereitung
Um Modbus überhaupt in openHAB verwenden zu können, muss man als erstes das Modbus Binding installieren. Dies könnt ihr unter den Einstellungen --> Bindings
machen. Hier einfach nach Modbus suchen und installieren:
Wir benötigen dann noch die Transformations Javascript und Map. Diese könnt ihr in den Einstellungen --> Transfomations
suchen und installieren:
Nach dem nun alle Abhängigkeiten in openHAB installiert sind, können wir die Konfigurationsdateien anlegen.
Achtung bei openHAB 4 bitte auch prüfen ob die JavaScript Erweiterung installiert ist, wenn nicht einfach nachinstallierten:
Wechselrichter Things
Zunächst müssen wir für alle Items, Things anlegen. Diese werden zum Teil durch Transform Scripte erweitert, da sonst verfälschte Werte in openHAB ankommen.
Ihr müsst die IP Adressen in die euerer Wechselrichter ändern. Zu empfehlen ist auch, das die IPs der Wechselrichter fixiert sind nicht ändern können.
conf/things/sma.things
// SMA Inverter 1 (SMA Tripower 8)
Bridge modbus:tcp:inverter1 "SMA Inverter 1 Bridge" [ host="192.168.50.41", port=502, id=3, connectMaxTries=3] {
// SMA Inverter Device Type
Bridge poller DevType "SMA Inverter 1 Poller Device Type" [ start=30053, length=4, refresh=60000, type="input" ] {
Thing data type "SMA Inverter 1 Device Type" [ readStart="30053", readValueType="uint32" ]
}
// SMA Inverter Status
Bridge poller SMA_Status "SMA Inverter 1 Poller Status" [ start=30201, length=36, refresh=20000, type="input" ] {
Thing data status "SMA Inverter 1 Status" [ readStart="30201", readValueType="int32" ]
Thing data Grid_Contactor "SMA Inverter 1 Grid Contactor" [ readStart="30217", readValueType="int32" ]
Thing data Max_Power "SMA Inverter 1 Max Power" [ readStart="30231", readValueType="int32" ]
Thing data Set_Max_Power "SMA Inverter 1 Set Max Power" [ readStart="30233", readValueType="int32" ]
}
Bridge poller PowerDrawn "SMA Inverter 1 Poller Power Drawn" [ start=30865, length=4, refresh=5000, type="input" ] {
Thing data PowerDrawn "SMA Inverter 1 Power Drawn" [ readStart="30865", readValueType="int32", readTransform="JS(smalimit.js)" ]
Thing data PowerGridFeedIn "SMA Inverter 1 Power Grid Feed In" [ readStart="30867", readValueType="int32", readTransform="JS(smalimit.js)" ]
}
// SMA Inverter Yield
Bridge poller Yield "SMA Inverter 1 Poller Yield" [ start=30517, length=36, refresh=60000, type="input" ] {
Thing data Day_Yield "SMA Inverter 1 Day Yield" [ readStart="30537", readValueType="int32", readTransform="JS(smalimit_undef.js)" ]
Thing data Total_Yield "SMA Inverter 1 Total Yield" [ readStart="30531", readValueType="int32", readTransform="JS(smalimit_undef.js)" ]
}
// SMA Inverter Power Section A & Total
Bridge poller power_a "SMA Inverter 1 Poller Power A and Total" [ start=30769, length=20, refresh=5000, type="input" ] {
Thing data currentA_input "SMA Inverter 1 Current Input A" [ readStart="30769", readValueType="int32", readTransform="JS(smalimit1000.js)" ]
Thing data voltageA_input "SMA Inverter 1 Voltage A" [ readStart="30771", readValueType="int32", readTransform="JS(smalimit100.js)" ]
Thing data powerA_input "SMA Inverter 1 Power A" [ readStart="30773", readValueType="int32", readTransform="JS(smalimit.js)" ]
Thing data active_power "SMA Inverter 1 Active Power" [ readStart="30775", readValueType="int32", readTransform="JS(smalimit.js)" ]
Thing data power_L1 "SMA Inverter 1 Power L1" [ readStart="30777", readValueType="int32", readTransform="JS(smalimit.js)" ]
Thing data power_L2 "SMA Inverter 1 Power L2" [ readStart="30779", readValueType="int32", readTransform="JS(smalimit.js)" ]
Thing data power_L3 "SMA Inverter 1 Power L3" [ readStart="30781", readValueType="int32", readTransform="JS(smalimit.js)" ]
Thing data volt_G1 "SMA Inverter 1 Volt G1" [ readStart="30783", readValueType="int32", readTransform="JS(smalimit100.js)" ]
Thing data volt_G2 "SMA Inverter 1 Volt G2" [ readStart="30785", readValueType="int32", readTransform="JS(smalimit100.js)" ]
Thing data volt_G3 "SMA Inverter 1 Volt G3" [ readStart="30787", readValueType="int32", readTransform="JS(smalimit100.js)" ]
}
// SMA Inverter Power Section B
Bridge poller power_b "SMA Inverter 1 Poller Power B" [ start=30957, length=8, refresh=5000, type="input" ] {
Thing data currentB_input "SMA Inverter 1 Current Input B" [ readStart="30957", readValueType="int32", readTransform="JS(smalimit1000.js)" ]
Thing data voltageB_input "SMA Inverter 1 Voltage B" [ readStart="30959", readValueType="int32", readTransform="JS(smalimit100.js)" ]
Thing data powerB_input "SMA Inverter 1 Power B" [ readStart="30961", readValueType="int32", readTransform="JS(smalimit.js)" ]
}
// SMA Inverter Temperature
Bridge poller InternalTemperature "SMA Inverter 1 Poller Internal Temperature" [ start=34113, length=2, refresh=15000, type="input" ] {
Thing data InternalTemperature "SMA Inverter 1 Internal Temperature" [ readStart="34113", readValueType="int32", readTransform="JS(smalimit10_undef.js)" ]
}
// SMA Inverter Operation
Bridge poller SMA_Status_Operate "SMA Inverter 1 Poller Status Operate" [ start=40029, length=4, refresh=15000, type="input" ] {
Thing data operatestatus "SMA Inverter 1 Status Operate" [ readStart="40029", readValueType="uint32" ]
}
}
// SMA Inverter 2 (SunnyBoy Storage 3.7)
Bridge modbus:tcp:inverter2 "SMA Inverter 2 Bridge" [ host="192.168.50.42", port=502, id=3, connectMaxTries=3] {
// SMA SunnyBoy Storage 3.7
Bridge poller device_typ "SMA Inverter 2 Poller Device Type" [ start=30053, length=4, refresh=60000, type="input" ] {
Thing data device_typ "SMA Inverter 2 Device Type" [ readStart="30053", readValueType="int32"]
}
// SMA SunnyBoy Storage 3.7 Condition
Bridge poller status "SMA Inverter 2 Poller Status" [ start=30201, length=4, refresh=15000, type="input" ] {
Thing data status "SMA Inverter 2 Status" [ readStart="30201", readValueType="int32"]
}
// SMA SunnyBoy Storage 3.7 GridRelay on/off
Bridge poller GridRelay "SMA Inverter 2 Poller Grid Relay" [ start=30217, length=4, refresh=5000, type="input" ] {
Thing data GridRelay "SMA Inverter 2 Grid Relay" [ readStart="30217", readValueType="int32"]
}
// SMA SunnyBoy Storage 3.7 Total Yield.
Bridge poller TotalYield "SMA Inverter 2 Poller Total Yield" [ start=30531, length=4, refresh=60000, type="input" ] {
Thing data TotalYield "SMA Inverter 2 Total Yield" [ readStart="30531", readValueType="int32", readTransform="JS(smalimit_undef.js)" ]
}
// SMA SunnyBoy Storage 3.7 Daily Yield
Bridge poller DayYield "SMA Inverter 2 Poller Daily Yield" [ start=30537, length=4, refresh=60000, type="input" ] {
Thing data DayYield "SMA Inverter 2 Day Yield" [ readStart="30537", readValueType="int32" ]
}
// SMA SunnyBoy Storage 3.7 Power
Bridge poller Power "SMA Inverter 2 Poller Power" [ start=30775, length=4, refresh=5000, type="input" ] {
Thing data Power "SMA Inverter 2 Power" [ readStart="30775", readValueType="int32" ]
Thing data PowerL1 "SMA Inverter 2 Power L1" [ readStart="30777", readValueType="int32", readTransform="JS(smalimit.js)" ]
}
// SMA SunnyBoy Storage 3.7 Grid Voltage L1
Bridge poller GVoltageL1 "SMA Inverter 2 Poller Voltage L1" [ start=30783, length=4, refresh=5000, type="input" ] {
Thing data GVoltageL1 "SMA Inverter 2 Voltage L1" [ readStart="30783", readValueType="int32", readTransform="JS(smalimit100.js)" ]
}
// SMA SunnyBoy Storage 3.7 Current battery state
Bridge poller CurrentBatStatCharge "SMA Inverter 2 Poller Current Battery Charge" [ start=30845, length=6, refresh=15000, type="input" ] {
Thing data CurrentBatStatCharge "SMA Inverter 2 Current Battery Charge State" [ readStart="30845", readValueType="int32" ]
Thing data CurrentBatcapacity "SMA Inverter 2 Current Battery Capacity" [ readStart="30847", readValueType="int32" ]
Thing data CurrentBatTemp "SMA Inverter 2 Current Battery Temperature" [ readStart="30849", readValueType="int32", readTransform="JS(smalimit10_undef.js)" ]
}
// SMA SunnyBoy Storage 3.7 PowerDrawn
Bridge poller PowerDrawn "SMA Inverter 2 Poller Power Drawn" [ start=30865, length=4, refresh=5000, type="input" ] {
Thing data PowerDrawn "SMA Inverter 2 Power Drawn" [ readStart="30865", readValueType="int32" ]
Thing data PowerGridFeedIn "SMA Inverter 2 Power Grid Feed In" [ readStart="30867", readValueType="int32" ]
}
// SMA SunnyBoy Storage 3.7 Battery oper. status
Bridge poller BatteryStatus "SMA Inverter 2 Poller Battery Status" [ start=30955, length=4, refresh=30000, type="input" ] {
Thing data BatteryStatus "SMA Inverter 2 Battery Status" [ readStart="30955", readValueType="int32" ]
}
// SMA SunnyBoy Storage 3.7 Status battery application area:
Bridge poller BatteryAppArea "SMA Inverter 2 Poller Battery App Area" [ start=31057, length=4, refresh=30000, type="input" ] {
Thing data BatteryAppArea "SMA Inverter 2 Battery App Area" [ readStart="31057", readValueType="int32" ]
}
// SMA SunnyBoy Storage 3.7
Bridge poller PowerDrawnGridL1 "SMA Inverter 2 Poller Power Grid L1" [ start=31259, length=16, refresh=5000, type="input" ] {
Thing data PowerGridFeedL1 "SMA Inverter 2 Power Grid Feed L1" [ readStart="31259", readValueType="int32" ]
Thing data PowerGridFeedL2 "SMA Inverter 2 Power Grid Feed L2" [ readStart="31261", readValueType="int32" ]
Thing data PowerGridFeedL3 "SMA Inverter 2 Power Grid Feed L3" [ readStart="31263", readValueType="int32" ]
Thing data PowerDrawnGridL1 "SMA Inverter 2 Power Drawn Grid L1" [ readStart="31265", readValueType="int32" ]
Thing data PowerDrawnGridL2 "SMA Inverter 2 Power Drawn Grid L2" [ readStart="31267", readValueType="int32" ]
Thing data PowerDrawnGridL3 "SMA Inverter 2 Power Drawn Grid L3" [ readStart="31269", readValueType="int32" ]
}
// SMA SunnyBoy Storage 3.7
Bridge poller PowerDrawnGridL1 "SMA Inverter 2 Poller Power Grid L1" [ start=31259, length=16, refresh=5000, type="input" ] {
Thing data PowerGridFeedL1 "SMA Inverter 2 Power Grid Feed L1" [ readStart="31259", readValueType="int32" ]
Thing data PowerGridFeedL2 "SMA Inverter 2 Power Grid Feed L2" [ readStart="31261", readValueType="int32" ]
Thing data PowerGridFeedL3 "SMA Inverter 2 Power Grid Feed L3" [ readStart="31263", readValueType="int32" ]
Thing data PowerDrawnGridL1 "SMA Inverter 2 Power Drawn Grid L1" [ readStart="31265", readValueType="int32" ]
Thing data PowerDrawnGridL2 "SMA Inverter 2 Power Drawn Grid L2" [ readStart="31267", readValueType="int32" ]
Thing data PowerDrawnGridL3 "SMA Inverter 2 Power Drawn Grid L3" [ readStart="31269", readValueType="int32" ]
}
// SMA SunnyBoy Storage 3.7 Present battery charge
Bridge poller PresBatCharge "SMA Inverter 2 Poller Present Battery Charge" [ start=31393, length=4, refresh=5000, type="input" ] {
Thing data PresBatCharge "SMA Inverter 2 Present Battery Charge" [ readStart="31393", readValueType="int32" ]
Thing data PresBattDischarge "SMA Inverter 2 Present Battery Discharge" [ readStart="31395", readValueType="int32" ]
}
// SMA SunnyBoy Storage 3.7 Inverter Temperature
Bridge poller InternalTemperature "SMA Inverter 2 Poller Internal Temperature" [ start=34113, length=2, refresh=15000, type="input" ] {
Thing data InternalTemperature "SMA Inverter 2 Internal Temperature" [ readStart="34113", readValueType="int32", readTransform="JS(smalimit10_undef.js)" ]
}
// SMA SunnyBoy Storage 3.7 Battery nominal capacity
Bridge poller BattNormCap "SMA Inverter 2 Poller Battery Nominal Capacity" [ start=40187, length=2, refresh=300000, type="input" ] {
Thing data BattNorminalcapac "SMA Inverter 2 Battery Nominal Capacity" [ readStart="40187", readValueType="int32" ]
}
}
Transformation Scripts
Da die Wechselrichter zum Teil falsche Werte über Modbus liefern, müssen wir die Werte zum Teil umrechnen und bei Werten kleiner 0 entweder 0 setzen, oder gar einen undefinierten Zustand mit UNDEF
.
conf/transform/smalimit1000.js
(function(i) {
if(i < 0) return "0";
return parseFloat(i) / 1000
})(input)
conf/transform/smalimit100.js
(function(i) {
if(i < 0) return "0";
return parseFloat(i) / 100
})(input)
conf/transform/smalimit10_undef.js
(function(i) {
if(i < 0) return "UNDEF";
return parseFloat(i) / 10
})(input)
conf/transform/smalimit.js
(function(i) {
if(i < 0) return "0";
return parseFloat(i)
})(input)
conf/transform/smalimit_undef.js
(function(i) {
if(i < 0) return "UNDEF";
return parseFloat(i)
})(input)
Mapping Datei
Die Mapping Datei sorgt dafür das Zahlencodes in Lesbare Werte gewandelt werden. Zum Beispiel Statuscodes. Die Aktellen Werte für eure Wechselrichter findet ihr auch in der Modbus Dokumentation von eurem Wechselrichter.
conf/transform/sma.map
// Device Type
9098=STP 5000TL-20
9099=STP 6000TL-20
9100=STP 7000TL-20
9102=STP 9000TL-20
9103=STP 8000TL-20
9281=STP 10000TL-20
9282=STP 11000TL-20
9283=STP 12000TL-20
9326=Sunny Boy Storage 2.5
9347=STP 8.0
9356=SBS 3.7-10
// Condition
35=Fault
303=OFf
307=Ok
308=On
455=Warning
// Recommended action:
336=Contact manufacturer
337=Contact installer
338=invalid
887=none
// Grid relay/contactor:
51=Closed
311=Open
16777213=Information not available
// Operating status:
295=MPP
381=Off
569=On
443=Constant voltage
1392=Fault
1393=Waiting for PV voltage
1467=Start
1469=Shut down
1480=Waiting for utilities company
2119=Derating
ON=On
// Battery oper. status:
2291=Battery standby
2292=Charge battery
2293=Discharge battery
// Status battery application area:
2614=Own consumption area
2615=State of charge conservation area
2616=Backup power area
2617=Deep discharge protection area
2618=Deep discharge area
Wechselrichter Items
Um die Werte in openHAB einbinden zukönnen, legen wir nun noch für alles Items an. Die letzten Items ganz unten werden durch die Rules Datei berechnet und gefüttert.
conf/items/sma.items
// Inverter 1 TriPower 8.0
String inverter1DevType "Inverter Type [MAP(sma.map):%s]" <inverter> (Inverter1) ["Status", "Power"] {channel="modbus:data:inverter1:DevType:type:string"}
String inverter1Status "Device Status [MAP(sma.map):%s]" <status> (Inverter1) ["Status", "Power"] {channel="modbus:data:inverter1:SMA_Status:status:string"}
String inverter1GridContactor "Grid contactor [MAP(sma.map):%s]" <status> (Inverter1) ["Status", "Power"] {channel="modbus:data:inverter1:SMA_Status:Grid_Contactor:string"}
Number:Power inverter1MaxPower "Max Power [%.0f W]" <Energy> (Inverter1) ["Measurement", "Power"] {channel="modbus:data:inverter1:SMA_Status:Max_Power:number"}
Number:Power inverter1SetMaxPower "Max Power Set [%.0f W]" <Energy> (Inverter1) ["Measurement", "Power"] {channel="modbus:data:inverter1:SMA_Status:Set_Max_Power:number"}
Number:Power inverter1PowerDrawn "Power drawn from Grid [%.0f W]" <Energy> (Inverter1) ["Measurement", "Power"] {channel="modbus:data:inverter1:PowerDrawn:PowerDrawn:number"}
Number:Power inverter1PowerGridFeedIn "Power feedin Grid [%.0f W]" <Energy> (Inverter1) ["Measurement", "Power"] {channel="modbus:data:inverter1:PowerDrawn:PowerGridFeedIn:number"}
Number:Energy inverter1DailyYield "Inverter Daily Yield [%.0f kWh]" <line> (Inverter1) ["Measurement", "Energy"] {channel="modbus:data:inverter1:Yield:Day_Yield:number"}
Number:Energy inverter1TotalYield "Inverter Total Yield [%.0f kWh]" <line> (Inverter1) ["Measurement", "Energy"] {channel="modbus:data:inverter1:Yield:Total_Yield:number"}
Number:ElectricCurrent inverter1DC1Cur_input "Current input A [%.2f A]" <solarplant> (Inverter1) ["Measurement", "Energy"] {channel="modbus:data:inverter1:power_a:currentA_input:number"}
Number:ElectricPotential inverter1DC1Volt_input "Voltage input A [%.2f V]" <solarplant> (Inverter1) ["Measurement", "Energy"] {channel="modbus:data:inverter1:power_a:voltageA_input:number"}
Number:Power inverter1PowerA "Panel A [%.0f W]" <solarplant> (Inverter1) ["Measurement", "Power"] {channel="modbus:data:inverter1:power_a:powerA_input:number"}
Number:Power inverter1ActivePower "Total Production [%.0f W]" <solarplant> (Inverter1) ["Measurement", "Power"] {channel="modbus:data:inverter1:power_a:active_power:number"}
Number:Power inverter1PowerL1 "Active Power L1 [%.0f W]" <solarplant> (Inverter1) ["Measurement", "Power"] {channel="modbus:data:inverter1:power_a:power_L1:number"}
Number:Power inverter1PowerL2 "Active Power L2 [%.0f W]" <solarplant> (Inverter1) ["Measurement", "Power"] {channel="modbus:data:inverter1:power_a:power_L2:number"}
Number:Power inverter1PowerL3 "Active Power L3 [%.0f W]" <solarplant> (Inverter1) ["Measurement", "Power"] {channel="modbus:data:inverter1:power_a:power_L3:number"}
Number:ElectricPotential inverter1_voltG1 "Grid voltage phase L1 [%.2f V]" <solarplant> (Inverter1) ["Measurement", "Energy"] {channel="modbus:data:inverter1:power_a:volt_G1:number"}
Number:ElectricPotential inverter1_voltG2 "Grid voltage phase L2 [%.2f V]" <solarplant> (Inverter1) ["Measurement", "Energy"] {channel="modbus:data:inverter1:power_a:volt_G2:number"}
Number:ElectricPotential inverter1_voltG3 "Grid voltage phase L3 [%.2f V]" <solarplant> (Inverter1) ["Measurement", "Energy"] {channel="modbus:data:inverter1:power_a:volt_G3:number"}
Number:ElectricCurrent inverter1DC2Cur_input "Current input B [%.3f A]" <solarplant> (Inverter1) ["Measurement", "Energy"] {channel="modbus:data:inverter1:power_b:currentB_input:number"}
Number:ElectricPotential inverter1DC2Volt_input "Voltage input B [%.2f V]" <solarplant> (Inverter1) ["Measurement", "Energy"] {channel="modbus:data:inverter1:power_b:voltageB_input:number"}
Number:Power inverter1PowerB "Panel B [%.0f W]" <solarplant> (Inverter1) ["Measurement", "Power"] {channel="modbus:data:inverter1:power_b:powerB_input:number"}
String inverter1OpMode "Operation Mode [MAP(sma.map):%s]" <status> (Inverter1) ["Status", "Power"] {channel="modbus:data:inverter1:SMA_Status_Operate:operatestatus:string"}
Number:Temperature inverter1InternalTemperature "Internal Temperature [%.1f °C]" <temperature> (Inverter1) ["Measurement", "Temperature"] {channel="modbus:data:inverter1:InternalTemperature:InternalTemperature:number"}
// Inverter 2 SunnyBoy Storage 3.7-10
String inverter2DevType "Inverter type [MAP(sma.map):%s]" <inverter> (Inverter2) ["Status", "Power"] {channel="modbus:data:inverter2:device_typ:device_typ:string"}
String inverter2Status "Device Status [MAP(sma.map):%s]" <status> (Inverter2) ["Status", "Power"] {channel="modbus:data:inverter2:status:status:string"}
String inverter2GridRelay "Grid Relay [MAP(sma.map):%s]" <status> (Inverter2) ["Status", "Power"] {channel="modbus:data:inverter2:GridRelay:GridRelay:string"}
Number:Energy inverter2TotalYield "Total Yield [%.0f kWh]" <line> (Inverter2) ["Measurement", "Energy"] {channel="modbus:data:inverter2:TotalYield:TotalYield:number"}
Number:Energy inverter2DayYield "Daily Yield [%.0f kWh]" <line> (Inverter2) ["Measurement", "Energy"] {channel="modbus:data:inverter2:DayYield:DayYield:number"}
Number:Power inverter2Power "Power [%.0f W]" <Energy> (Inverter2) ["Measurement", "Power"] {channel="modbus:data:inverter2:Power:Power:number"}
Number:Power inverter2PowerL1 "Power L1 [%.0f W]" <Energy> (Inverter2) ["Measurement", "Power"] {channel="modbus:data:inverter2:Power:PowerL1:number"}
Number:ElectricPotential inverter2GVoltageL1 "Grid Voltage L1 [%.2f V]" <Energy> (Inverter2) ["Measurement", "Energy"] {channel="modbus:data:inverter2:GVoltageL1:GVoltageL1:number"}
Number:Dimensionless inverter2BatStateCharge "Current Battery State Charge [%.0f %%]" <batterylevel> (Inverter2) ["Measurement", "Level"] {channel="modbus:data:inverter2:CurrentBatStatCharge:CurrentBatStatCharge:number"}
Number:Dimensionless inverter2BatCapacity "Current Battery Capacity [%.0f %%]" <status> (Inverter2) ["Status", "Level"] {channel="modbus:data:inverter2:CurrentBatStatCharge:CurrentBatcapacity:number"}
Number:Temperature inverter2BatTemp "Current Battery Temperature [%.1f °C]" <temperature> (Inverter2) ["Measurement", "Temperature"] {channel="modbus:data:inverter2:CurrentBatStatCharge:CurrentBatTemp:number"}
Number:Power inverter2PowerDrawn "Power drawn from Grid [%.0f W]" <Energy> (Inverter2) ["Measurement", "Power"] {channel="modbus:data:inverter2:PowerDrawn:PowerDrawn:number"}
Number:Power inverter2PowerGridFeedIn "Power feedin Grid [%.0f W]" <Energy> (Inverter2) ["Measurement", "Power"] {channel="modbus:data:inverter2:PowerDrawn:PowerGridFeedIn:number"}
String inverter2BatteryStatus "Battery status [MAP(sma.map):%s]" <status> (Inverter2) ["Status", "Power"] {channel="modbus:data:inverter2:BatteryStatus:BatteryStatus:string"}
String inverter2BatAppArea "Battery Application Area [MAP(sma.map):%s]" <status> (Inverter2) ["Status", "Power"] {channel="modbus:data:inverter2:BatteryAppArea:BatteryAppArea:string"}
Number:Power inverter2PowGridFeedL1 "Power feedin Grid L1 [%.0f W]" <Energy> (Inverter2) ["Measurement", "Power"] {channel="modbus:data:inverter2:PowerDrawnGridL1:PowerGridFeedL1:number"}
Number:Power inverter2PowGridFeedL2 "Power feedin Grid L2 [%.0f W]" <Energy> (Inverter2) ["Measurement", "Power"] {channel="modbus:data:inverter2:PowerDrawnGridL1:PowerGridFeedL2:number"}
Number:Power inverter2PowGridFeedL3 "Power feedin Grid L3 [%.0f W]" <Energy> (Inverter2) ["Measurement", "Power"] {channel="modbus:data:inverter2:PowerDrawnGridL1:PowerGridFeedL3:number"}
Number:Power inverter2PowDraGridL1 "Power drawn from Grid L1 [%.0f W]" <Energy> (Inverter2) ["Measurement", "Power"] {channel="modbus:data:inverter2:PowerDrawnGridL1:PowerDrawnGridL1:number"}
Number:Power inverter2PowDraGridL2 "Power drawn from Grid L2 [%.0f W]" <Energy> (Inverter2) ["Measurement", "Power"] {channel="modbus:data:inverter2:PowerDrawnGridL1:PowerDrawnGridL2:number"}
Number:Power inverter2PowDraGridL3 "Power drawn from Grid L3 [%.0f W]" <Energy> (Inverter2) ["Measurement", "Power"] {channel="modbus:data:inverter2:PowerDrawnGridL1:PowerDrawnGridL3:number"}
Number:Power inverter2PreBatCharge "Present Battery Charge [%.0f W]" <batterylevel> (Inverter2) ["Measurement", "Power"] {channel="modbus:data:inverter2:PresBatCharge:PresBatCharge:number"}
Number:Power inverter2PreBatDischarge "Present Battery Discharge [%.0f W]" <batterylevel> (Inverter2) ["Measurement", "Power"] {channel="modbus:data:inverter2:PresBatCharge:PresBattDischarge:number"}
Number:Temperature inverter2InternalTemperature "Internal Temperature [%.1f °C]" <temperature> (Inverter2) ["Measurement", "Temperature"] {channel="modbus:data:inverter2:InternalTemperature:InternalTemperature:number"}
Number:Energy inverter2BatNormCapac "Battery Norminal Capacity [%.0f Wh]" <text> (Inverter2) ["Measurement", "Energy"] {channel="modbus:data:inverter2:BattNormCap:BattNorminalcapac:number"}
// Total Power Consumption
Number:Power TotalPowerConsumption "Total Consumption [%.0f W]" <house> (Inverter1) ["Measurement", "Power"]
Number:Power PowerConsumptionBatIncl "Consumption with Battery Charge [%.0f W]" <house> (Inverter1) ["Measurement", "Power"]
Regeln / Rules
Mit Hilfe der Regeldatei, berechnen wir den Gesamtstromverbrauch und die Einnahmen durch Einspeisung und auch die Ausgaben durch den Zukauf von Strom.
conf/rules/sma.rules
rule "Total Power Consumption"
when
Item inverter1PowerDrawn received update
then
val Number TotalPower = (inverter1ActivePower.state as QuantityType<Number>
+ inverter2PreBatDischarge.state as QuantityType<Number>
+ inverter1PowerDrawn.state as QuantityType<Number>
- inverter2PreBatCharge.state as QuantityType<Number>
- inverter1PowerGridFeedIn.state as QuantityType<Number>)
if ( TotalPower >= 0|"W" ) {
TotalPowerConsumption.postUpdate(TotalPower)
}
val Number PowerBatIncl = (inverter1ActivePower.state as QuantityType<Number>
+ inverter2PreBatDischarge.state as QuantityType<Number>
+ inverter1PowerDrawn.state as QuantityType<Number>
- inverter1PowerGridFeedIn.state as QuantityType<Number>)
if ( TotalPower >= 0|"W" ) {
PowerConsumptionBatIncl.postUpdate(PowerBatIncl)
}
end
Sitemap
Hier ein Bespiel wie die untenstehende Sitemap aussieht.
conf/sitemaps/sma.sitemap
sitemap sma label="SMA PV Installation"
{
Frame label="Summary" {
Text item=TotalPowerConsumption
Text item=PowerConsumptionBatIncl
Text item=inverter1ActivePower label="Total Production"
Text item=inverter1PowerGridFeedIn
Text item=inverter1PowerDrawn
Text item=inverter2PreBatCharge
Text item=inverter2PreBatDischarge
Text item=inverter2BatStateCharge
Text item=inverter1PowerA {
Text item=inverter1DC1Volt_input
Text item=inverter1DC1Cur_input
Text item=inverter1PowerA
}
Text item=inverter1PowerB {
Text item=inverter1DC2Volt_input
Text item=inverter1DC2Cur_input
Text item=inverter1PowerB
}
}
Frame label="SMA Inverter 1" {
Text item=inverter1Status
Text item=inverter1DevType
Text item=inverter1GridContactor
Text item=inverter1OpMode
Text item=inverter1MaxPower
Text item=inverter1SetMaxPower
Text item=inverter1InternalTemperature
}
Frame label="Solar Panels" {
Text item=inverter1PowerA {
Text item=inverter1DC1Volt_input
Text item=inverter1DC1Cur_input
Text item=inverter1PowerA
}
Text item=inverter1PowerB {
Text item=inverter1DC2Volt_input
Text item=inverter1DC2Cur_input
Text item=inverter1PowerB
}
Text item=inverter1ActivePower label="Total Watt"
Text item=inverter2BatStateCharge
Text item=inverter2PreBatCharge
Text item=inverter2PreBatDischarge
}
Frame label="Yield" {
Text item=inverter1DailyYield
Text item=inverter1TotalYield
}
Frame label="Grid voltage & Power" {
Text item=inverter1_voltG1
Text item=inverter1PowerL1
Text item=inverter1_voltG2
Text item=inverter1PowerL2
Text item=inverter1_voltG3
Text item=inverter1PowerL3
}
Frame label="SMA Inverter 2" {
Text item=inverter2Status
Text item=inverter2DevType
Text item=inverter2Power
Text item=inverter2PowerL1
Text item=inverter2GVoltageL1
Text item=inverter2GridRelay
Text item=inverter2DayYield
Text item=inverter2TotalYield
Text item=inverter2InternalTemperature
}
Frame label="PowerDrawn/Feed-in" {
Text item=inverter2PowerDrawn
Text item=inverter2PowerGridFeedIn
Text item=inverter2PowDraGridL1
Text item=inverter2PowGridFeedL1
Text item=inverter2PowDraGridL2
Text item=inverter2PowGridFeedL2
Text item=inverter2PowDraGridL3
Text item=inverter2PowGridFeedL3
}
Frame label="BYD B-Box HVS 10.2" {
Text item=inverter2BatteryStatus
Text item=inverter2BatAppArea
Text item=inverter2BatCapacity
Text item=inverter2BatNormCapac
Text item=inverter2BatStateCharge
Text item=inverter2PreBatCharge
Text item=inverter2PreBatDischarge
Text item=inverter2BatTemp
}
}
Stromkosten / Einspeisevergütung berechnen
Man kann nun noch mit Hilfe des SMA Energy Monitor Bindings, den SMA Energy Meter, oder SMA Home Manager auslesen und so zum Beispiel die gesamte Einspeisevergütung berechnen. Wie das geht, könnt ihr hier nachlesen: