Group rule does not trigger for all members

  • Platform information:
    • Hardware: Raspberry Pi 4, openhab 2.5.0 via docker
    • OS: raspian
    • openHAB version:
  • Issue of the topic:
    Hi there,
    After one year trying around with openhabian and gained knowledge I decided to create my setup from scratch. Furthermore I wanted to include my rollershutters to openhab.

The shutters are working using a REST interface, so I´m able to control them with my own UI since months. AFAIK the openhab rollershutter does not support http bining, so
I have per rollershutter:

  • one rollershutter item
  • one string item for command up
  • one string item for command down
  • one string item that reads back the rollershutter position

Then I have a group for rollershutters and a rule that reflects the rollershutter command to the corresponding string items.

My problem:
The first configured rollershutter does what it should, it displays the position and can be controlled via basic UI rollershutter item (UP and DOWN).
Sadly the subsequent can´t be controlled while they display their position.

I´m sure it is not a big deal to get it working, but I have no clue where to look now.
The rule is not triggered for all other rollershutters.

Items file: logo.items (truncated)

// shutter
Group:Rollershutter:OR(UP, DOWN) gShutters
Group:String gShutterCommands
Group:Number gShutterPosition

Rollershutter GF_LivingRoom_Shutter_E      "Rolladen Wohnzimmer Ost [%d %%]"    (gShutters)
String        GF_LivingRoom_Shutter_E_Up   "Rolladen Wohnzimmer Ost Up"         (gShutterCommands) { http=">[ON:GET:http://127.0.0.1:5000/home/shutter/livingroom/east/up]" }
String        GF_LivingRoom_Shutter_E_Dn   "Rolladen Wohnzimmer Ost Down"       (gShutterCommands) { http=">[ON:GET:http://127.0.0.1:5000/home/shutter/livingroom/east/down]" }
Number        GF_LivingRoom_Shutter_E_Pos  "Rolladen Wohnzimmer Ost Pos"        (gShutterPosition) {        http="<[http://127.0.0.1:5000/home/shutter/livingroom/east:10000:REGEX((.*))]", autoupdate="false" }

Rollershutter GF_LivingRoom_Shutter_SE     "Rolladen Wohnzimmer Südost [%d %%]" (gShutters)
String        GF_LivingRoom_Shutter_SE_Up  "Rolladen Wohnzimmer Südost Up"      (gShutterCommands) { http=">[ON:GET:http://127.0.0.1:5000/home/shutter/livingroom/southeast/up]" }
String        GF_LivingRoom_Shutter_SE_Dn  "Rolladen Wohnzimmer Südost Down"    (gShutterCommands) { http=">[ON:GET:http://127.0.0.1:5000/home/shutter/livingroom/southeast/down]" }
Number        GF_LivingRoom_Shutter_SE_Pos "Rolladen Wohnzimmer Südost Pos"     (gShutterPosition) {        http="<[http://127.0.0.1:5000/home/shutter/livingroom/southeast:10000:REGEX((.*))]", autoupdate="false" }

Rollershutter GF_LivingRoom_Shutter_SW     "Rolladen Wohnzimmer West [%d %%]"   (gShutters)
String        GF_LivingRoom_Shutter_SW_Up  "Rolladen Wohnzimmer West Up"        (gShutterCommands) { http=">[ON:GET:http://127.0.0.1:5000/home/shutter/livingroom/southwest/up]" }
String        GF_LivingRoom_Shutter_SW_Dn  "Rolladen Wohnzimmer West Down"      (gShutterCommands) { http=">[ON:GET:http://127.0.0.1:5000/home/shutter/livingroom/southwest/down]" }
Number        GF_LivingRoom_Shutter_SW_Pos "Rolladen Wohnzimmer West Pos"       (gShutterPosition) {        http="<[http://127.0.0.1:5000/home/shutter/livingroom/southwest:10000:REGEX((.*))]", autoupdate="false" }

shutter.rules

rule "Rollershutter Up: Reflect command from rollershutter to string / http"
when
    Member of gShutters received command UP
then
    sendCommand(triggeringItem.name + "_Up", "ON")
end

rule "Rollershutter Down: Reflect command from rollershutter to string / http"
when
    Member of gShutters received command DOWN
then
    sendCommand(triggeringItem.name + "_Dn", "ON")
end

rule "Rollershutter Position: read position from number, convert range and set rollershutter position "
when
    Member of gShutterPosition changed or
    Member of gShutterPosition received update
then
    val name = triggeringItem.name
    val pos = (triggeringItem.state as Number)
    val inv = 100 - pos
    postUpdate(name.substring(0, name.lastIndexOf('_')), inv.toString)
end
2020-01-03 13:19:37.518 [ome.event.ItemCommandEvent] - Item 'GF_LivingRoom_Shutter_E' received command DOWN
2020-01-03 13:19:37.537 [ome.event.ItemCommandEvent] - Item 'GF_LivingRoom_Shutter_E_Dn' received command ON
2020-01-03 13:19:39.177 [ome.event.ItemCommandEvent] - Item 'GF_LivingRoom_Shutter_E' received command DOWN
2020-01-03 13:19:39.181 [ome.event.ItemCommandEvent] - Item 'GF_LivingRoom_Shutter_E_Dn' received command ON
2020-01-03 13:19:39.928 [vent.ItemStateChangedEvent] - GF_LivingRoom_Shutter_E_Pos changed from 100 to 93
2020-01-03 13:19:39.931 [GroupItemStateChangedEvent] - gShutterPosition changed from 100 to UNDEF through GF_LivingRoom_Shutter_E_Pos
2020-01-03 13:19:39.957 [vent.ItemStateChangedEvent] - GF_LivingRoom_Shutter_E changed from 0 to 7
2020-01-03 13:19:39.961 [GroupItemStateChangedEvent] - gShutters changed from 0 to 100 through GF_LivingRoom_Shutter_E
2020-01-03 13:19:40.743 [ome.event.ItemCommandEvent] - Item 'GF_LivingRoom_Shutter_E' received command UP
2020-01-03 13:19:40.761 [ome.event.ItemCommandEvent] - Item 'GF_LivingRoom_Shutter_E_Up' received command ON
2020-01-03 13:19:46.365 [ome.event.ItemCommandEvent] - Item 'GF_LivingRoom_Shutter_SW' received command DOWN
2020-01-03 13:19:49.259 [ome.event.ItemCommandEvent] - Item 'GF_LivingRoom_Shutter_SW' received command UP
2020-01-03 13:19:50.539 [GroupItemStateChangedEvent] - gShutterPosition changed from UNDEF to 100 through GF_LivingRoom_Shutter_E_Pos
2020-01-03 13:19:50.543 [vent.ItemStateChangedEvent] - GF_LivingRoom_Shutter_E_Pos changed from 93 to 100
2020-01-03 13:19:50.557 [GroupItemStateChangedEvent] - gShutters changed from 100 to 0 through GF_LivingRoom_Shutter_E
2020-01-03 13:19:50.560 [vent.ItemStateChangedEvent] - GF_LivingRoom_Shutter_E changed from 7 to 0

As you can see in the logs the Shutter_E triggers the string item (http REST command) while the Shutter_SW does not triggers the command. I assume sonething with my groups or rules is wrong.

Do you have any pointers? Many thanks in advance!

I see no reason why it wouldn’t but never had a Rollershutter so never had opportunity to try it out. But I would expect the following to work:

Rollershutter GF_LivingRoom_Shutter_E { http=">[UP:GET:http://127.0.0.1:5000/home/shutter/livingroom/east/up]
                                              >[DOWN:GET:http://127.0.0.1:5000/home/shutter/livingroom/east/down"]
                                              <[http://127.0.0.1:5000/home/shutter/livingroom/east:10000:REGEX((.*))]"
                                        autoupdate="false" }

I am surprised the String Items work though for the first one. The ON in the binding config is the command upon which the http binding will issue the GET request. You can’t send ON to a String. I suppose it might work if you sendCommand(“ON”) to a String Item, but if you are doing that, a Switch Item is the more appropriate choice anyway. The Up and Dn Items should be switches.

When you change the membership of a Group, the rules that use Member of need to be reloaded. IIUC, Member of is like a macro that expands to a separate trigger for each member of the Group, but that only occurs when the Rule is first loaded. When you change the Group membership later, you need to regenerate those triggers.

But, like I indicated above, I don’t think you need all this. I think the HTTP binding will work with a Rollershutter Item.

Hi Rich,
many thanks for the quick reply!

To be honest, it was my first attempt to get all the stuff done with just a rollershutter item, but unfortunately it did not work. Then I read about your group pattern and tried to apply it - and for the first item I had success…

I´m not sure if I´m lucky when I change the item with http command from string to switch, I assume that the item will change to ON just once and then remain in that state. And for now - the first shutter works with string item. First make it work, then make it nice :slight_smile:

Back to topic:
How do I reload/regenerate a rule? If it is just editing and save the rules file it will not work so far…

UPDATE:
I restarted the openhab docker container and now the rule is working as expected!
Many thanks for your help!

UPDATE:

Member of is like a macro

This was the missing link. The groups are parsed once and changes in a running setup are ignored.

…yet another

Have you tried turning it off and on again?

moment

I have all the shutters configured now and they work as a charm!