# Complex Rule optimization

**URL:** <https://community.openhab.org/t/complex-rule-optimization/82091>\
**Category:** Scripts & Rules\
**Created:** [September 17, 2019, 9:22pm UTC](https://community.openhab.org/t/complex-rule-optimization/82091 "2019-09-17T21:22:28Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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 17, 2019, 11:04pm UTC](https://community.openhab.org/t/complex-rule-optimization/82091/2 "2019-09-17T23:04:42Z")

</div>

I don’t have time to do a full analysis but the general approach is to put the test in a separate rule that there when ever one of the values changes, and put the result into an item. See [Design Pattern: Separation of Behaviors](https://community.openhab.org/t/design-pattern-separation-of-behaviors/15886) and for a more specific example for using this approach on time see [Design Pattern: Simple State Machine (e.g. Time Of Day)](https://community.openhab.org/t/design-pattern-time-of-day/15407).

[Generic Presence Detection](https://community.openhab.org/t/generic-presence-detection/17878) may also be of interest.

---

_[View the full topic](https://community.openhab.org/t/complex-rule-optimization/82091)._
