Ich habe alles per file erstellt.
import org.openhab.core.model.script.ScriptServiceUtil
/* beispielhafte items
Number PARTYKELLERSoll "PARTYKELLER Soll [%.1f °C]" <temperature> (gKeller, gPARTYKELLER, gSoll) {channel="livisismarthome:RST:SHCJLE01:1111111111111111111111111:set_temperature"}
Number PARTYKELLERSollSetpoint "PARTYKELLER Setpoint [%.1f °C]" <temperature> (gKeller, gPARTYKELLER, gSollSetpoint)
Switch PARTYKELLERWindowReduction "PARTYKELLER Window Reduction" (gEG, gInnogyWindowReduction)
Contact PartykellerFenstersensor "Partykeller Fenster [MAP(de.map):%s]" (gKeller, gFenster,gSicherheitInnen, gSicherheitAussen) {channel="livisismarthome:WDS:SHCJLE01:2222222222222222222222222222222:contact"}
Vorraussetzungen
1. Zu jedem Item mit set_temperature gibt es ein passendes Number ItemSetpoint welches den Sollwert speichert falls das/die Fenster geöffnet werden und der Sollwert set_temperature auf 6 Grad geht
2. es gibt noch eine Valiable kWinter welche die Anlage zwischen Winter und Sommerbetrieb umschaltet. Im Sommer ist set_temperature immer 30 Grad um die Antriebe und die Ventilfeder zu Entlasten (andere Rule). Deswegen ist die Windowreduction nur im Winterbetrieb aktiv
3. all items, die eine set_temperature sind in der Gruppe gSoll
Funktion
1. wann immer Item mit set_temperature sich ändert wird ItemSetPoint geschrieben. Das passiert bei manueller Änderung am Ventil, Zeitplan von SHC oder Kommando von OH
2. alle 20 sec wird geprüft, ob ein Fenster offen ist. Falls ja, wird das set_temperature auf 6 kommandiert
Kommentar Ende
*/
val org.eclipse.xtext.xbase.lib.Functions$Function5<NumberItem, NumberItem, ContactItem, ContactItem, SwitchItem, Number> funcWindowReduction = [
NumberItem SollSetpointItem,
NumberItem SollItem,
ContactItem Window1,
ContactItem Window2,
SwitchItem WindowReduction
|
var Number nSollSetpoint
var Number nSoll
//logInfo("funcWindowReduction", "Aufruf " + SollItem.name.toString +" " + SollItem.state.toString +" " + SollSetpointItem.name.toString +" " + SollSetpointItem.state.toString +" " + Window1.name.toString +" " + Window1.state.toString +" " + Window2.name.toString +" " + Window2.state.toString )
if ( SollSetpointItem.state == NULL || SollSetpointItem.state.toString == "6" ){
sendCommand (SollSetpointItem, 15)
}
nSollSetpoint = SollSetpointItem.state as DecimalType
nSoll = SollItem.state as DecimalType
//logInfo("funcWindowReduction","nSoll " + nSoll + " nSollSetpoint " + nSollSetpoint)
if (kWinter.state.toString == "ON"){
if(Window1.state.toString == "OPEN" || Window2.state.toString == "OPEN") {
if (nSoll != 6 ){
sendCommand(SollItem, 6)
sendCommand(WindowReduction, ON)
logInfo("funcWindowReduction", "Windowreduction EIN " + SollItem.name.toString)
}
}
else {
if (nSoll != nSollSetpoint){
logInfo("funcWindowReduction", "Windowreduction AUS " + SollItem.name.toString)
sendCommand(SollItem, nSollSetpoint)
sendCommand(WindowReduction, OFF)
}
}
}
]
rule "WindowReductionRooms"
when
Time cron "*/20 * * * * ?"
then
//OG
funcWindowReduction.apply(OG_ESSZIMMERSollSetpoint,OG_ESSZIMMERSoll,OG_ESSZIMMERFenstersensor,OG_WOHNZIMMERFenstersensor, OG_ESSZIMMERWindowReduction)
funcWindowReduction.apply(OG_DuscheSollSetpoint,OG_DuscheSoll,OG_DUSCHEFenstersensor,OG_DUSCHEFenstersensor, OG_DuscheWindowReduction)
funcWindowReduction.apply(OG_AUSSENBUEROSollSetpoint,OG_AUSSENBUEROSoll,OG_AUSSENBUEROFenstersensor,OG_AUSSENBUEROFenstersensor, OG_AUSSENBUEROWindowReduction)
//EG
funcWindowReduction.apply(BueroSollSetpoint,BueroSoll,BueroFenstersensor,BueroFenstersensor, BueroWindowReduction)
funcWindowReduction.apply(WohnEssZimmerSollSetpoint,WohnEssZimmerSoll,WohnzimmerTuersensor,WohnzimmerFenstersensor, WohnEssWindowReduction)
funcWindowReduction.apply(KUECHESollSetpoint,KUECHESoll,KUECHEFenstersensor,KUECHEFenstersensor, KuecheWindowReduction)
funcWindowReduction.apply(BADSoll,BADSollSetpoint,BADFenstersensor,BADFenstersensor, BadWindowReduction)
funcWindowReduction.apply(RAUM1SollSetpoint,RAUM1Soll,RAUM1Fenstersensor,RAUM1Fenstersensor, RAUM1WindowReduction)
//KG
funcWindowReduction.apply(PARTYKELLERSollSetpoint,PARTYKELLERSoll,PartykellerFenstersensor,PartykellerFenstersensor, PARTYKELLERWindowReduction)
end
rule "UpdateSollSetpoint"
when
Member of gSoll changed
then
var String sbuffer
var Number Soll
//logInfo("UpdateSollSetpoint", "The item " + triggeringItem.name + " changed state from " + previousState + " to " + triggeringItem.state)
sbuffer = triggeringItem.name + "Setpoint"
//logInfo("UpdateSollSetpoint", "sbuffer = " + sbuffer)
Soll = triggeringItem.state as DecimalType
if (Soll > 6){
ScriptServiceUtil.getItemRegistry.getItem(sbuffer).postUpdate(Soll)
}
end
Display More