# \#designpattern

**URL:** https://community.openhab.org/tag/designpattern/957.md?match_all_tags=true&page=1&tags%5B%5D=designpattern

[Latest](https://community.openhab.org/latest.md) · [Categories](https://community.openhab.org/categories.md) · [Tags](https://community.openhab.org/tags.md)

**Page:** 2

---

## [Design Pattern: Switch & Dimmer](https://community.openhab.org/t/design-pattern-switch-dimmer/66893)

<div class="topic-metadata">

**Author:** [@bechte](https://community.openhab.org/u/bechte)\
**Replies:** 21\
**Last updated:** [January 15, 2021, 9:04pm UTC](https://community.openhab.org/t/design-pattern-switch-dimmer/66893 "2021-01-15T21:04:30Z")

</div>

Please see Design Pattern: What is a Design Pattern and How Do I Use Them to understand the scope and purpose of this and other Design Patterns. Problem Statement When using a switch to control a dimmable light, one ma…

---

## [Design Pattern: Using Item Metadata as an Alternative to Several DPs](https://community.openhab.org/t/design-pattern-using-item-metadata-as-an-alternative-to-several-dps/78610)

<div class="topic-metadata">

**Author:** [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Replies:** 13\
**Last updated:** [January 9, 2021, 6:14pm UTC](https://community.openhab.org/t/design-pattern-using-item-metadata-as-an-alternative-to-several-dps/78610 "2021-01-09T18:14:31Z")

</div>

Please see Design Pattern: What is a Design Pattern and How Do I Use Them for details on what a DP is and how to use them. Problem Statement There will be times when one has data that is associated with a specific Item…

---

## [Design Pattern: Bayesian Sensor Aggregation](https://community.openhab.org/t/design-pattern-bayesian-sensor-aggregation/109627)

<div class="topic-metadata">

**Author:** [@cweitkamp](https://community.openhab.org/u/cweitkamp)\
**Replies:** 4\
**Last updated:** [December 22, 2020, 8:19pm UTC](https://community.openhab.org/t/design-pattern-bayesian-sensor-aggregation/109627 "2020-12-22T20:19:40Z")

</div>

Bayesian Sensor Aggregation Yesterday I announced a community post about my talk on the topic “Bayesian Sensor Aggregation” to share my example and open the topic for further discussion and improvements. Note: The slides…

---

## [Design Pattern: Expire Binding Based Timers](https://community.openhab.org/t/design-pattern-expire-binding-based-timers/32634)

<div class="topic-metadata">

**Author:** [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Replies:** 50\
**Last updated:** [December 12, 2020, 11:56am UTC](https://community.openhab.org/t/design-pattern-expire-binding-based-timers/32634 "2020-12-12T11:56:28Z")

</div>

Problem Statement One often needs to schedule some code to execute at some time in the future. The “usual” way to achieve this is by using a Timer which lets you create and schedule a lambda to execute at a given date …

---

## [Jsr233 Community scripts - time\_utils problem](https://community.openhab.org/t/jsr233-community-scripts-time-utils-problem/102700)

<div class="topic-metadata">

**Author:** [@james\_2\_roberts](https://community.openhab.org/u/james_2_roberts)\
**Replies:** 2\
**Last updated:** [July 24, 2020, 6:38am UTC](https://community.openhab.org/t/jsr233-community-scripts-time-utils-problem/102700 "2020-07-24T06:38:54Z")

</div>

Hardware: RPi 3 OS: Raspbian GNU/Linux 8 (jessie) JRE: OpenJDK Runtime Environment (Zulu 8.31.1.122-linux\_aarch32hf) (build 1.8.0\_181-b122) OH: 2.5.6 (Build) I’m trying to install the openhab-rules-tools (ephem\_tod and …

---

## [Design Pattern: Rule Refresh](https://community.openhab.org/t/design-pattern-rule-refresh/102317)

<div class="topic-metadata">

**Author:** [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Replies:** 3\
**Last updated:** [July 15, 2020, 3:17pm UTC](https://community.openhab.org/t/design-pattern-rule-refresh/102317 "2020-07-15T15:17:20Z")

</div>

Please see Design Pattern: What is a Design Pattern and How Do I Use Them for a desciption of DPs. Notes This is based largely off of the work of @CrazyIvan359 which I’ve extracted and made generic. Also, this design p…

---

## [Design Pattern(?): Deferred Automated Actions](https://community.openhab.org/t/design-pattern-deferred-automated-actions/61778)

<div class="topic-metadata">

**Author:** [@Jaffa](https://community.openhab.org/u/Jaffa)\
**Replies:** 4\
**Last updated:** [October 11, 2019, 7:29pm UTC](https://community.openhab.org/t/design-pattern-deferred-automated-actions/61778 "2019-10-11T19:29:11Z")

</div>

Problem Statement You have an item you want to send a command to after a delay, but if there’s another rule or user interaction with that item in the meantime, cancel the automated action. For example, open a blind at t…

---

## [A State Machine Primer with HABlladin, the openHAB Genie](https://community.openhab.org/t/a-state-machine-primer-with-hablladin-the-openhab-genie/17787)

<div class="topic-metadata">

**Author:** [@billeccles](https://community.openhab.org/u/billeccles)\
**Replies:** 6\
**Last updated:** [December 5, 2019, 9:33pm UTC](https://community.openhab.org/t/a-state-machine-primer-with-hablladin-the-openhab-genie/17787 "2019-12-05T21:33:58Z")

</div>

(Gunzips and rubs openHAB TARball. Out pops HABlladin, the openHAB genie.) Hey, how’s it going?! What is is you’d like? You get three wishes. Well, it’s simple, really. When I come home after dark and open the garage d…

---

## [MQTT long press design pattern (dimmer)](https://community.openhab.org/t/mqtt-long-press-design-pattern-dimmer/29885)

<div class="topic-metadata">

**Author:** [@Jelle\_Victoor](https://community.openhab.org/u/Jelle_Victoor)\
**Replies:** 20\
**Last updated:** [December 5, 2019, 8:44pm UTC](https://community.openhab.org/t/mqtt-long-press-design-pattern-dimmer/29885 "2019-12-05T20:44:05Z")

</div>

I have simple push butons that send out an ON message on a mqtt topic and an OFF message to the same topic when they are released. This works great for turning lights on and off with a simple rule rule "toggle" when …

---

## [Design Pattern: Unbound Item (aka Virtual Item)](https://community.openhab.org/t/design-pattern-unbound-item-aka-virtual-item/15993)

<div class="topic-metadata">

**Author:** [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Replies:** 9\
**Last updated:** [October 26, 2019, 1:44am UTC](https://community.openhab.org/t/design-pattern-unbound-item-aka-virtual-item/15993 "2019-10-26T01:44:17Z")

</div>

Problem Statement Sometimes one needs to create a flag, control, switch, or some other control that is not bound to a device or channel. For example, a Switch to override presence detection. Concept Create an Item tha…

---

## [Design Pattern: State Machine Driven Groups](https://community.openhab.org/t/design-pattern-state-machine-driven-groups/76116)

<div class="topic-metadata">

**Author:** [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Replies:** 6\
**Last updated:** [September 26, 2019, 10:56am UTC](https://community.openhab.org/t/design-pattern-state-machine-driven-groups/76116 "2019-09-26T10:56:15Z")

</div>

Please see Design Pattern: What is a Design Pattern and How Do I Use Them to understand the scope and purpose of a design pattern. As with all DPs, the DP is not limited for the use demonstrated in the examples. Problem…

---

## [Design Pattern: Do While](https://community.openhab.org/t/design-pattern-do-while/22534)

<div class="topic-metadata">

**Author:** [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Replies:** 4\
**Last updated:** [June 12, 2019, 2:09pm UTC](https://community.openhab.org/t/design-pattern-do-while/22534 "2019-06-12T14:09:09Z")

</div>

Problem Statement Sometimes a user wants to perform some sort of action or activate polling during a certain period of time after another event occurs. This Design Pattern is deprecated. Please see Design Pattern: Loo…

---

## [NodeRED Flow for "Time of Day" Design Pattern](https://community.openhab.org/t/nodered-flow-for-time-of-day-design-pattern/49118)

<div class="topic-metadata">

**Author:** [@Carywin](https://community.openhab.org/u/Carywin)\
**Replies:** 1\
**Last updated:** [January 29, 2019, 6:53am UTC](https://community.openhab.org/t/nodered-flow-for-time-of-day-design-pattern/49118 "2019-01-29T06:53:39Z")

</div>

Here’s a NodeRED flow using BigTimer nodes that replicates the functionality of the popular Time of Day design pattern. I made this when I became terminally frustrated with the Astro binding failing and the rules engine …

---

## [Design Pattern: Recursive Timers](https://community.openhab.org/t/design-pattern-recursive-timers/17114)

<div class="topic-metadata">

**Author:** [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Replies:** 10\
**Last updated:** [December 18, 2018, 8:04pm UTC](https://community.openhab.org/t/design-pattern-recursive-timers/17114 "2018-12-18T20:04:11Z")

</div>

Problem Statement Often one finds a situation where at the end of a triggered timer one wants to reschedule the timer to go off again. But if you do this in the normal way that means you need a full copy of the Timer’s…

---

## [Design Pattern: DRY, How Not to Repeat Yourself in Rules DSL](https://community.openhab.org/t/design-pattern-dry-how-not-to-repeat-yourself-in-rules-dsl/60105)

<div class="topic-metadata">

**Author:** [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Replies:** 3\
**Last updated:** [December 17, 2018, 5:14pm UTC](https://community.openhab.org/t/design-pattern-dry-how-not-to-repeat-yourself-in-rules-dsl/60105 "2018-12-17T17:14:39Z")

</div>

Please see Design Pattern: What is a Design Pattern and How Do I Use Them for details on what a DP is and how to use it. Problem Statement Do Not Repeat Yourself (DRY) Often an inexperienced programmer will find that …

---

## [Design Pattern: Encoding and Accessing Values in Rules](https://community.openhab.org/t/design-pattern-encoding-and-accessing-values-in-rules/36210)

<div class="topic-metadata">

**Author:** [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Replies:** 3\
**Last updated:** [December 16, 2018, 7:47pm UTC](https://community.openhab.org/t/design-pattern-encoding-and-accessing-values-in-rules/36210 "2018-12-16T19:47:24Z")

</div>

Edit: Added link to item\_init library. Please see Design Pattern: What is a Design Pattern and How Do I Use Them for how to read and use a DP. Problem Statement Often a user has the desire to be able to store and retri…

---

## [\[SOLVED\] Light patterns](https://community.openhab.org/t/solved-light-patterns/54695)

<div class="topic-metadata">

**Author:** [@Landstad](https://community.openhab.org/u/Landstad)\
**Replies:** 16\
**Last updated:** [October 27, 2018, 10:13am UTC](https://community.openhab.org/t/solved-light-patterns/54695 "2018-10-27T10:13:37Z")

</div>

Hello, I currently use two main patterns for adjusting light levels: Adjusting lights that are currently ON based on time of day (Astro is not a good idea in Norway as we have few non-sunny hours in the summer and few…

---

## [Design Pattern: Human Readable Names in Messages](https://community.openhab.org/t/design-pattern-human-readable-names-in-messages/34117)

<div class="topic-metadata">

**Author:** [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Replies:** 10\
**Last updated:** [July 31, 2018, 6:28am UTC](https://community.openhab.org/t/design-pattern-human-readable-names-in-messages/34117 "2018-07-31T06:28:12Z")

</div>

Please see Design Pattern: What is a Design Pattern and How Do I Use Them for details on what a DP is and how to use them. Problem Statement Sometimes one wants to create a message or log statement that references certa…

---

## [Cron expression](https://community.openhab.org/t/cron-expression/48099)

<div class="topic-metadata">

**Author:** [@a.tibi](https://community.openhab.org/u/a.tibi)\
**Replies:** 8\
**Last updated:** [July 21, 2018, 11:43am UTC](https://community.openhab.org/t/cron-expression/48099 "2018-07-21T11:43:48Z")

</div>

Dear Community, I have action to trigger every minute between 6:00 AM to 14 (2:00 PM), first I made cron expression every minutes as “0 \* \* ? \* \*”. However my concern is not to exhaust the system for comparison every mi…

---

## [Way to save system settings](https://community.openhab.org/t/way-to-save-system-settings/48009)

<div class="topic-metadata">

**Author:** [@a.tibi](https://community.openhab.org/u/a.tibi)\
**Replies:** 2\
**Last updated:** [July 18, 2018, 7:10pm UTC](https://community.openhab.org/t/way-to-save-system-settings/48009 "2018-07-18T19:10:43Z")

</div>

Dear Community, I want to make settings files for my home automation, so the system can read it and populate its values to system variables (items), Therefore, I would like to take your advises for couple of questions: …

---

## [Design Pattern: How to Structure a Rule](https://community.openhab.org/t/design-pattern-how-to-structure-a-rule/45360)

<div class="topic-metadata">

**Author:** [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Replies:** 3\
**Last updated:** [July 16, 2018, 6:50am UTC](https://community.openhab.org/t/design-pattern-how-to-structure-a-rule/45360 "2018-07-16T06:50:39Z")

</div>

If you are unfamiliar with Design Patterns, please see Design Pattern: What is a Design Pattern and How Do I Use Them. Problem Statement Rules developers will frequently encounter situations where they have to perform o…

---

## [Opinion on rule set for programmable watering system](https://community.openhab.org/t/opinion-on-rule-set-for-programmable-watering-system/44669)

<div class="topic-metadata">

**Author:** [@fpalinf](https://community.openhab.org/u/fpalinf)\
**Replies:** 26\
**Last updated:** [June 2, 2018, 11:36pm UTC](https://community.openhab.org/t/opinion-on-rule-set-for-programmable-watering-system/44669 "2018-06-02T23:36:54Z")

</div>

I am a fresh beginner of openhab. I already like it. It went quite smooth and I am starting to develop my own set of rules for a watering system. Platform information: openHAB version: docker image openhab/openhab:2.2…

---

## [Design Pattern: Sensor Aggregation](https://community.openhab.org/t/design-pattern-sensor-aggregation/15157)

<div class="topic-metadata">

**Author:** [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Replies:** 11\
**Last updated:** [March 14, 2018, 1:53pm UTC](https://community.openhab.org/t/design-pattern-sensor-aggregation/15157 "2018-03-14T13:53:00Z")

</div>

Please see Design Pattern: What is a Design Pattern and How Do I Use Them for an explanation of what a DP is and how to use them. Problem Statement There are often times where one has a number of sensors of different ty…

---

## [Best practice to check state as result of command \[jython\]?](https://community.openhab.org/t/best-practice-to-check-state-as-result-of-command-jython/39756)

<div class="topic-metadata">

**Author:** [@Euphi](https://community.openhab.org/u/Euphi)\
**Replies:** 0\
**Last updated:** [February 7, 2018, 9:14pm UTC](https://community.openhab.org/t/best-practice-to-check-state-as-result-of-command-jython/39756 "2018-02-07T21:14:22Z")

</div>

I use Homie (convention for MQTT) for my home automation. If you don’t know it, the important concept is, that the state is updated via a command to set set the state, e.g. send message “ON” to homie/switch/light/state/…

---

## [How to say if a switch was pressed manually / physically](https://community.openhab.org/t/how-to-say-if-a-switch-was-pressed-manually-physically/38461)

<div class="topic-metadata">

**Author:** [@Moerky](https://community.openhab.org/u/Moerky)\
**Replies:** 2\
**Last updated:** [January 8, 2018, 7:38pm UTC](https://community.openhab.org/t/how-to-say-if-a-switch-was-pressed-manually-physically/38461 "2018-01-08T19:38:18Z")

</div>

I have searched around but haven’t found an appropriate answer. I have a ZWave switch which is connected to a physical light switch to turn a light on or off. It can be operated manually (by pressing the switch) or via m…

---

## [An Approach for Better Light Timers](https://community.openhab.org/t/an-approach-for-better-light-timers/24936)

<div class="topic-metadata">

**Author:** [@Mike\_Bagdanoff](https://community.openhab.org/u/Mike_Bagdanoff)\
**Replies:** 18\
**Last updated:** [December 7, 2017, 8:30pm UTC](https://community.openhab.org/t/an-approach-for-better-light-timers/24936 "2017-12-07T20:30:44Z")

</div>

edit: I’ve updated the code to show the final form of what I have in my rules file, having to work around limitations of the language caused it to diverge from my original idea, but it works well and makes the rest of my…

---

## [Decoupling notification service](https://community.openhab.org/t/decoupling-notification-service/34920)

<div class="topic-metadata">

**Author:** [@teaserr](https://community.openhab.org/u/teaserr)\
**Replies:** 7\
**Last updated:** [October 25, 2017, 9:18am UTC](https://community.openhab.org/t/decoupling-notification-service/34920 "2017-10-25T09:18:19Z")

</div>

Hi all, I’m quite new to rules in OpenHAB. I implemented my first rules last weekend and this weekend I added some more, including sending of some notifications. Since my wife and I both use Telegram on our phones, I se…

---

## [Design Pattern: Cancel Activity](https://community.openhab.org/t/design-pattern-cancel-activity/21058)

<div class="topic-metadata">

**Author:** [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Replies:** 18\
**Last updated:** [September 11, 2017, 3:08am UTC](https://community.openhab.org/t/design-pattern-cancel-activity/21058 "2017-09-11T03:08:43Z")

</div>

See Design Pattern: What is a Design Pattern and How Do I Use Them Problem Statement Occasionally one has a long running rule that includes a while or for loop to slowly adjust an Item or Items until some criteria is re…

---

## [Usage of push buttons to toggle output + feedback on design](https://community.openhab.org/t/usage-of-push-buttons-to-toggle-output-feedback-on-design/29685)

<div class="topic-metadata">

**Author:** [@Jelle\_Victoor](https://community.openhab.org/u/Jelle_Victoor)\
**Replies:** 11\
**Last updated:** [June 11, 2017, 12:14pm UTC](https://community.openhab.org/t/usage-of-push-buttons-to-toggle-output-feedback-on-design/29685 "2017-06-11T12:14:43Z")

</div>

I’m fairly new with openhab, I have been working with it for a small week now. My input is driven by on mqtt and my output is driven by modbus. I’m communicating with a wago 750-881 plc. I’m using push buttons to hand…

[Previous page](https://community.openhab.org/tag/designpattern/957.md?match_all_tags=true&tags%5B%5D=designpattern)
