Seite 1 von 1
Rule: Aktion, wenn Batteriespeicher Voll
Verfasst: 23. Mär 2025 13:40
von astrong
Hi Zusammen,
ich kämpfe mal wieder mit dem DSL Scripten... über die klassische WebGui Bedingungen bekomme ich es nicht zusammengeklickt.
Ich möchte:
Wenn: Batteriespeicher Voll (100% Value vom Item)
Dann: Führe Aktion aus
Wenn: Batteriespeicher kleiner 100%
Dann: Stoppe o.g. Aktion
Aktuell komme ich schon bei der ersten Aktion nicht weiter:
Code: Alles auswählen
configuration: {}
triggers:
- id: "1"
configuration:
type: application/vnd.openhab.dsl.rule
script: >
var PercentType vol = new
PercentType(45) if((Fronius_Symo_Inverter_Battery_State_of_Charge.state
as Number) > 99)
type: script.ScriptAction
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
itemName: UG_Schaltaktor_8_Vorgarten_Wasserpumpe_Brunnen
command: ON
type: core.ItemCommandAction
Re: Rule: Aktion, wenn Batteriespeicher Voll
Verfasst: 24. Mär 2025 17:10
von nojo
Hi,
ich hab eine ähnliche Rule wo ich den Status der Batterie einfach erfasse und über Telegram weitergebe.
wenn ich deine Items übertrage dann würde sowas rauskommen.
wenn du kein Telegram hast, einfach rausnehmen.
Gruß,
nojo
Code: Alles auswählen
rule "Wasserpumpe_BatterieStatus_Fronius"
when
Item Fronius_Symo_Inverter_Battery_State_of_Charge changed
then
val telegramAction = getActions("telegram","telegram:telegramBot:xxxxxxxxxx")
if(!(previousState instanceof Number)) {
logWarn("Batterie_Status","previousState keine gültige Zahl! ({})",previousState)
return;
}
if(!(newState instanceof Number)) {
logWarn("Batterie_Status","newState keine gültige Zahl! ({})",newState)
return;
}
if(previousState <= 99.0 | % && newState > 99.0 | %) {
telegramAction.sendTelegram("%.5s Prozent, die Batterie ist voll, Wasserpumpe wird eingeschaltet", Fronius_Symo_Inverter_Battery_State_of_Charge.state.toString)
UG_Schaltaktor_8_Vorgarten_Wasserpumpe_Brunnen.sendCommand(ON)
}
if(previousState >= 97.0 | % && newState < 97.0 | %) {
telegramAction.sendTelegram("%.5s Prozent, die Batterie wird entladen, Wasserpumpe wird ausgeschaltet", Fronius_Symo_Inverter_Battery_State_of_Charge.state.toString)
UG_Schaltaktor_8_Vorgarten_Wasserpumpe_Brunnen.sendCommand(OFF)
}
end
Re: Rule: Aktion, wenn Batteriespeicher Voll
Verfasst: 30. Mär 2025 15:55
von astrong
hi,
sorry für die verspätete Rückmeldung.
Anbei meine Integration deines Scripts
Leider bekomme ich beim Ausführen:
> openhab.log <==
2025-03-30 15:53:49.081 [WARN ] [ab.core.model.script.Batterie_Status] - previousState keine gültige Zahl! ({})
Wo nimmt er previousState überhaupt her?
Code: Alles auswählen
configuration: {}
triggers:
- id: "1"
configuration:
itemName: Fronius_Symo_Inverter_Battery_State_of_Charge
type: core.ItemStateUpdateTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
type: application/vnd.openhab.dsl.rule
script: >2+
if(!(previousState instanceof Number)) {
logWarn("Batterie_Status","previousState keine gültige Zahl! ({})",previousState)
return;
}
if(!(newState instanceof Number)) {
logWarn("Batterie_Status","newState keine gültige Zahl! ({})",newState)
return;
}
if(previousState <= 99.0 | % && newState > 99.0 | %) {
UG_Schaltaktor_8_Vorgarten_Wasserpumpe_Brunnen.sendCommand(ON)
}
if(previousState >= 50.0 | % && newState < 50.0 | %) {
UG_Schaltaktor_8_Vorgarten_Wasserpumpe_Brunnen.sendCommand(OFF)
}
type: script.ScriptAction
Re: Rule: Aktion, wenn Batteriespeicher Voll
Verfasst: 30. Mär 2025 16:18
von astrong
ich habe es jetzt damit probiert, leider auch ohne aktion.
Immerhin keine Fehlermeldung im log
Code: Alles auswählen
configuration: {}
triggers:
- id: "1"
configuration:
itemName: Fronius_Symo_Inverter_Battery_State_of_Charge
type: core.ItemStateUpdateTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
type: application/vnd.openhab.dsl.rule
script: |2
if (Fronius_Symo_Inverter_Battery_State_of_Charge.state > 95) {
UG_Schaltaktor_8_Vorgarten_Wasserpumpe_Brunnen.sendCommand(ON)
}
if (Fronius_Symo_Inverter_Battery_State_of_Charge.state < 95) {
UG_Schaltaktor_8_Vorgarten_Wasserpumpe_Brunnen.sendCommand(OFF)
}
type: script.ScriptAction
Re: Rule: Aktion, wenn Batteriespeicher Voll
Verfasst: 30. Mär 2025 16:41
von astrong
Update, damit hab ichs nun hinbekommen...
Code: Alles auswählen
configuration: {}
triggers:
- id: "1"
configuration:
itemName: Fronius_Symo_Inverter_Battery_State_of_Charge
type: core.ItemStateUpdateTrigger
conditions: []
actions:
- inputs: {}
id: "2"
configuration:
type: application/vnd.openhab.dsl.rule
script: >
if (Fronius_Symo_Inverter_Battery_State_of_Charge.state instanceof
Number) {
val batteryLevel = (Fronius_Symo_Inverter_Battery_State_of_Charge.state
as Number)
if (batteryLevel > 99) {
UG_Schaltaktor_8_Vorgarten_Wasserpumpe_Brunnen.sendCommand(ON)
} else if (batteryLevel < 75) {
UG_Schaltaktor_8_Vorgarten_Wasserpumpe_Brunnen.sendCommand(OFF)
}
} else {
logWarn("BatteryRule", "Battery state is NULL or UNDEF!")
}
type: script.ScriptAction