# Set default state of a group

**URL:** <https://community.openhab.org/t/set-default-state-of-a-group/34047>\
**Category:** Beginners\
**Tags:** rules, items, groupitems\
**Created:** [September 9, 2017, 6:16am UTC](https://community.openhab.org/t/set-default-state-of-a-group/34047 "2017-09-09T06:16:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![psyciknz](https://community.openhab.org/user_avatar/community.openhab.org/psyciknz/32/17347_2.png) [@psyciknz](https://community.openhab.org/u/psyciknz)\
**Post date:** [September 9, 2017, 6:16am UTC](https://community.openhab.org/t/set-default-state-of-a-group/34047/1 "2017-09-09T06:16:37Z")

</div>

I saw in [[SOLVED]Set default item state to OFF instead of NULL](https://community.openhab.org/t/solved-set-default-item-state-to-off-instead-of-null/20612) that I can use a rule to set a default state of items.

Is there an easy way I can set a whole group - ie all my motion\_detection items in one command:  
eg g\_motion\_detection.postUpdate(OFF)  
Is that possible, or do I have to iterate them?

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [September 9, 2017, 2:19pm UTC](https://community.openhab.org/t/set-default-state-of-a-group/34047/2 "2017-09-09T14:19:30Z")

</div>

It definitely works with sendCommand. I’m not sure if it works with postUpdate.

Give it a try and report back here.

---

<div class="post-metadata">

**Author:** ![psyciknz](https://community.openhab.org/user_avatar/community.openhab.org/psyciknz/32/17347_2.png) [@psyciknz](https://community.openhab.org/u/psyciknz)\
**Post date:** [September 11, 2017, 5:59am UTC](https://community.openhab.org/t/set-default-state-of-a-group/34047/3 "2017-09-11T05:59:57Z")

</div>

I believe not.  
There were contact items though.  
So

> `g_motion_detection.postUpdate(CLOSED)`

did nothing, but I’ve managed to replicate what I want with:

> ```
> g_motion_detection.allMembers.forEach[g |
> logInfo("AlarmSetOff","Item " + g.name + " state: " + g.state.toString )
> g.postUpdate(CLOSED)
> ]
> 
> ```
