Einrichtung der openHAB Umgebung und allgemeine Konfigurationsthemen.
Moderatoren: seppy , udo1toni
astrong
Beiträge: 39 Registriert: 10. Nov 2020 09:14
Answers: 0
Beitrag
von astrong » 23. Mär 2025 13:40
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
nojo
Beiträge: 40 Registriert: 17. Mai 2020 22:09
Answers: 0
Beitrag
von nojo » 24. Mär 2025 17:10
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
astrong
Beiträge: 39 Registriert: 10. Nov 2020 09:14
Answers: 0
Beitrag
von astrong » 30. Mär 2025 15:55
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
astrong
Beiträge: 39 Registriert: 10. Nov 2020 09:14
Answers: 0
Beitrag
von astrong » 30. Mär 2025 16:18
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
astrong
Beiträge: 39 Registriert: 10. Nov 2020 09:14
Answers: 0
Beitrag
von astrong » 30. Mär 2025 16:41
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