All rolleshutters to a value

items

Number           Scene_Rollershutter
Rollershutter   A_Shutter                "Rollershutter [%d %%]"       <rollershutter>    (gShutter)                                 {channel="zwave:device:efddf849:node5:blinds_control"}
Rollershutter   B_Shutter             "Rollershutter [%d %%]"         <rollershutter>    (gShutter)                              {channel="zwave:device:efddf849:node4:blinds_control"}
Rollershutter   C_Shutter             "Rollershutter [%d %%]"         <rollershutter>    (gShutter)                              {channel="zwave:device:efddf849:node6:blinds_control"}

Group:Rollershutter:OR(UP, DOWN)   gShutter   "Rollershutter"      <rollershutter>   (Home)

sitemap

Selection label="All" item=Scene_Rollershutter mappings=[0="All down", 20="20%", 40="40%", 60="60%", 80="80%", 100="All up"]

rules

rule "All"
when
    Item Scene_Rollershutter received update
then
    gShutter.members.forEach[S |
        if (Scene_Rollershutter.state == NULL || Scene_Rollershutter.state == "") {
            S.sendCommand(Scene_Rollershutter.state)
            Thread::sleep(200)
        }
    ]
end

Nothing happens. What’s wrong? thanks

try

gShutter?.members.forEach[S |
if (Scene_Rollershutter.state == NULL || Scene_Rollershutter.state == "")

if NOTHING then NOTHING…

1 Like

Same

Yes. Never enter inside the IF

I don’t think this will work. A Rollershutter can receive UP/DOWN as a command, but it stores its state as a PercentType so the Group aggregation function needs to work on PercentType. Perhaps something like

Group:Rollershutter:MAX

would be more appropriate.

Add some logging to verify that the Rule is running at all.

Don’t put your if inside the forEach. Instead:

if(Scene_Rollershutter.state == NULL || Scene_Rollershutter.state < 0 || Scene_Rollershutter.state > 100) return;

gShutter.members.forEach[ S |
    S.sendCommand(Scene_Rollershutter.state)
    Thread::sleep(200)
]

Note that what Vincent was saying is that in your original you only send the command to S when Scene_Rollershutter.state is NULL or “” which doesn’t make sense. You want to send the command when Scene_Rollershutter.state is NOT NULL or “”.

Also, since Scene_Rollershutter is a Number, its state can never be “” so testing for that is basically a noop.

How many rollershutters do you have? Just these three or are there more? If a lot more then I have some problems with the Thread::sleep. But if we are talking 5 or less this should be fine.

Also notice the space between the [ and the S. This is required in ON 2.3+.

1 Like
Group:Rollershutter:MAX

Works great. Thank you (MAX stands for?)

I have 5 rollershutter

rule

rule "All"
when
    Item Scene_Rollershutter received update
then
    logInfo("Debug", "I enter here")
    gShutter.members.forEach[ S |
        S.sendCommand(Scene_Rollershutter.state)
        Thread::sleep(200)
    ]
end

log

2018-05-29 21:45:45.452 [INFO ] [eclipse.smarthome.model.script.Debug] - I enter here
2018-05-29 21:45:45.453 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'All': Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(org.eclipse.smarthome.core.items.Item,java.lang.String) on instance: null

Maximum

You got rid of the if statement. Is Scene_Rollershutter in a valid state?

Add back in

if(Scene_Rollershutter.state == NULL || Scene_Rollershutter.state < 0 || Scene_Rollershutter.state > 100) return;

rule

rule "All"
when
    Item Scene_Rollershutter received update
then
    if(Scene_Rollershutter.state == NULL || Scene_Rollershutter.state < 0 || Scene_Rollershutter.state > 100) return;

    logInfo("Debug", "I enter here")

    gShutter.members.forEach[ S |
        S.sendCommand(Scene_Rollershutter.state)
        Thread::sleep(200)
    ]
end

log

2018-05-29 22:01:07.494 [vent.ItemStateChangedEvent] - Scene_Rollershutter changed from 0 to 60
2018-05-29 22:01:07.554 [INFO ] [eclipse.smarthome.model.script.Debug] - I enter here
2018-05-29 22:01:07.561 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'All': Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(org.eclipse.smarthome.core.items.Item,java.lang.String) on instance: null

try S.sendCommand(Scene_Rollershutter.state.toString)

It works. But i think that I have to send an Intval not a string. No?

The sendCommand action will parse the string into and integer automagicaly