Rollershutter to previous state

Hi,

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)

best regards

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.

Hi Udo,

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:

{EGKuecheRolladenFenster (Type=RollershutterItem, State=100)=100}

So i´ve tried

if (EGKuecheRolladenFenster.state != 100 && shutterPreviousState.state == 100)

…doesn´t work :frowning:

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]

so you mean like this?

if (EGKuecheRolladenFenster.state != 100 && shutterPreviousState.get(“State”) == 100 ){
The Designer doesn´t complain :smile:

But now it´s not executing the rule…so seem it doesn´t match