Rule for Rollershutters - with proxy items and reed-contacts

Hi,
i have working rollershutter rules for automatic open/close in the mornig and evening.

Now i want to include my magnet contact of one door, so that in future my rollershutter will stay open, if the door is not closed. So i can still go into the house, when it´s at night and i´m outside and at this time the shutters will close automatically by rule.

My idea was a rollershutter-proxy-item, which will get the state, the shutter would have, if the door is closed.

So maybe:
Door is open, all rollershutters close --> this rollershutter still stays open. Proxy-item will get the state: 100% closed

After that, when i come in and close the door, the proxy-item will be compared to the real state of the rollershutter. If it is different, then send command “close” to the rollershutter.

I have a KNX installation, so there is a possibility to lock the actuator channel, but in this way, i will not be able to send commands (maybe manually close) to the rollershutter channel any more. So my idea was to do this by rule inside openhab.

Any ideas?

Is this working, when i make a rollershutter-item and send commands to it? How will the rollershutter-proxy item get the state 100% - this will normaly come from the rollershutter-actuator?

Or do i have to use another sort of item? string? switch? I can send “down” or “100%” to my rollershutters, and in both cases they will close completely. So i have to check for both commands, not only for up/down, also for numbers.

Why use a proxy item at all.
Do a rule like this:

When door close
If at night
Then if rollershutter open then close it

I want to include automatic shading in a later stage too. So i have to check for multiple conditions… I think in this way, a proxy item would be the way with less work?

That’s more work for now
Get it working without your proxy item and introduce it later on when needed

I think, that is no good idea.

Imagine the following as an example:

Door is opened.
–> rule sends “rollo down” to all shutters, because it is night
–> i send manually “all shutters up”, because i have guests, make party or what ever…
Then i come in and close the door
–> with your idea, the shutter will immediately close, all other shutters are still open
–> with my idea, shutter will stay open, because of proxy_item has the new state “open” instead of “closed”

EDIT:
I made a small rule for logging the state of the proxy-rollershutter-item. It works, seems that i don´t need to send the percentage with an extra command. If i send “down” rollershutter changes to 100%. That is a little bit wired, because the real rollershutter still stays at 0% until the knx-actuator sends the right percentage to the item. This is done “after” the rollershutter has moved and it has stopped again.

So you want this roller shutter to have the same state as the other roller shutters when you close the door after dark?

See my EDIT in the last post, also.


Yes, i want it this way, because the rollershutter is a member of a group. And when the door is closed, all members of this group should have the same state.

So i will have to remove the real rollershutter from this group and put the proxy-item into this group.

When proxy-item changes (or door-contact) changes, then compare door-contact. If door open - do nothing, if door closed, send the proxy-command to the real rollershutter.

Another way, create another rollershutter group WITHOUT this roller shutter but all the others
then when you close the door do rollershutter.sendCommand(gRollerShutter2.state)

Hm, and when i manually open only one of the member shutters of group2, the state of the group is not “closed” anymore, i think?

What is the bad thing with my idea?

In the first step, i only want to include this door, but i have some more doors. So i need a defined group-state and this will be the proxy-item-state. So i can keep the state “which should be” and can manually open/close all shutters without any problem.

Ok, so what exactly do you want to achieve?

The biggest problem, that i have currently is, that i´m outside on my terrace and it gets dark, then all shutters go down. If all other doors are locked and i´m alone at home, i will have no change to get in any more. I don´t take the key with me, when i only go to the terrace.

So biggest problem will be solved, when the rollershutter simply stays open.

Then the next problem is, that the state of the rollershutters can change during the day or night, maybe because of the weather (sun, wind, day/night) or something else (manually override, …). So the shutter should automatically go to the right state, which it would have, when the door never got opened.

I don’t think you need a proxy Item for this.

You can solve this generically using Design Pattern: Associated Items.

Instead of relying on sending the command to a Group to close the shutters, iterate through the shutters and for each one check the associated Item (the reed sensor) before deciding to close the shutter.

    gRollershutters.members.forEach[ rs |
        val sensor = gRollershutterContacts.members.findFirst[ s | s.name = rs.name+"_Sensor" ]
        if(sensor == null || sensor.state == CLOSED) rs.sendCommand(DOWN)
    ]

Then you need another Rule that triggers when the sensors you care about close. In this rule check to see if the shutter should be closed based on all your criteria (time of day, temperature, weather, etc). Since 2.3 nearing release I’ll show the 2.3 way:

rule "Close rollershutters when doors close if necessary"
when
    Member of gRollershutterContacts changes to CLOSED
then
    // check all your states to determine if the rollershutters should be down

    if(shouldBeDown) sendCommand(triggeringItem.name.replace("_Contact",""), DOWN)
end

I purposefully check for null in the first Rule so you do not need to have a sensor for every member of gRollershutters.

1 Like

Hm, i don´t know if this is a better way. So if i change one of the criterias, i have to do this inside the rollershutter-rule for closing all shutters and then in this rule a second time…

I will have a look at this and make some tests.

You would have to do this anyway if you use a proxy item. No matter your approach, you have to have code somewhere that determines whether the rollershutters need to be down or not.

However, if you use Design Pattern: Separation of Behaviors (Design Pattern: Time Of Day is a specific implementation of this) you can, and should centralize the calculation of whether or not the shutters should be down and set a flag Item. Then in the original rule and in the second rule you just need to check the flag.

So it becomes:

rule "Calculate the desired shutter state"
when
    // whatever events indicate that the rollershutters should change state
    System started
then
    // Calculate whether the rollershutters should be open or not

    DesiredRollerShutterState.sendCommand(newState)
end

rule "Control rollershutters"
when
    Item DesiredRollerShutterState changes
then
    gRollershutters.members.forEach[ rs |
        val sensor = gRollershutterContacts.members.findFirst[ s | s.name = rs.name+"_Sensor" ]
        if(sensor == null || sensor.state == CLOSED) rs.sendCommand(DesiredRollerShutterState.state)
    ]
end

rule "Close rollershutters when doors close if necessary"
when
    Member of gRollershutterContacts changes to CLOSED
then
    if(DesiredRollerShutterState.state != triggeringItem.state) 
        sendCommand(triggeringItem.name.replace("_Contact",""), DOWN)
end