I’m trying to move a rollershutter to a previous state…but I have no idea how.
What I want to do is…
rule “Küche lüften”
when
Item EGKuecheFenstersensor changed from CLOSED to OPEN
then
if (EGKuecheRolladenFenster.state == 100){
sendCommand(EGKuecheRolladenFenster, 80)
}
end
Now, if i close the window i want that the shutter goes back down to “100” (CLOSED)
You would have to store the state (or at least set a marker) to restore position after window has been closed:
var Boolean EGKuecheRollladenFensterZu = false
rule "Küche lüften"
when
Item EGKuecheFenstersensor changed from CLOSED to OPEN
then
if (EGKuecheRolladenFenster.state == 100) {
EGKuecheRollladenFensterZu = true
sendCommand(EGKuecheRolladenFenster, 80)
}
end
rule "Küche lüften fertig"
when
Item EGKuecheFenstersensor changed from OPEN to CLOSED
then
if (EGKuecheRollladenFensterZu == true) {
EGKuecheRollladenFensterZu = false
sendCommand(EGKuecheRolladenFenster, 100)
}
end
Please check the correct spelling, as I’m not at home and so can’t check with Designer.
thanks for your fast reply. In the meantime i found also a solution. Here we go:
import java.util.Map
var Map shutterPreviousState = null
rule "Küche lüften (öffnen)"
when
Item EGKuecheFenstersensor changed from CLOSED to OPEN
then
if (EGKuecheRolladenFenster.state == 100){
logInfo("AbschattungRules:Rolladen Küche lüften", "Küche lüften (öffnen)")
shutterPreviousState = storeStates(EGKuecheRolladenFenster)
logInfo("AbschattungRules:Rolladen Küche lüften", "Küche lüften (öffnen)"+ shutterPreviousState)
sendCommand(EGKuecheRolladenFenster, 80)
}
end
rule "Küche lüften (schließen)"
when
Item EGKuecheFenstersensor changed from OPEN to CLOSED
then
if (EGKuecheRolladenFenster.state != 100){
logInfo("AbschattungRules:Rolladen Küche lüften", "Küche lüften (schließen)")
restoreStates(shutterPreviousState)
shutterPreviousState = null
}
end
Now to be 100% sure, i want to query the “state” in the “shutterPreviousState”
The “shutterPreviousState” looks like this:
I am not sure about the return type of storeStates() but you defined shutterPreviousState as a Map and I am pretty sure that a Map has no state member.
[Update]
What happens if you try it with shutterPreviousState.get("state")
[/Update]