opus
(Jürgen Baginski)
February 12, 2017, 6:47pm
1
Is it possible to do string manipulations within a rule?
I need to build a string out of elements of a String-ArrayList seperated by “,”.
the quick answer is yes
As I am just happen to look at some of this, you may want to check out this post where group names are reconstructed in a rule:
Edit: Updates for OH 4, inclusion of JS Scripting and Blockly examples, removed the doors example as it’s superfluous.
Please see Design Pattern: What is a Design Pattern and How Do I Use Them for how to read and use DPs.
Problem Statement
One powerful way to consolidate code in rules is to use array/list manipulation operations on the members of a Group. For example, filter down to just those members that are ON, get a list of the labels of those Items that are NULL, etc.
Concept
[image]
T…
and this post here:
For who want to have ability to adjust configuration of scenarios in “runtime”, from the app, here you will find a working example of it.
This is a stand-alone example, you have obviously to modify something to integrate it in your system.
First of all, light items, for example lights.items.
// LIGHTS ITEMS & GROUPS
Group gLights
Switch Room1_Light01 "Light 01" (gLights)
Dimmer Room2_Light02 "Light 02" (gLights)
Switch Room3_Light03 "Light 03 RGB" (gLights)
Color Room…
where configurations are saved in a string file
1 Like
opus
(Jürgen Baginski)
February 12, 2017, 7:16pm
3
Thanks for the input, I didn’t know that StringBuilder was possible.