You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: configuration/yaml/ruletemplates.md
+68-24Lines changed: 68 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ This page describes the `ruleTemplates` element for [YAML Configuration](./).
11
11
12
12
The `ruleTemplates` top-level key contains a map of rule templates, defined by their template UIDs.
13
13
The main building blocks of rules are triggers, conditions and actions, collectively called modules.
14
-
Rule templates lets you reuse the same definition in multiple rules, reducing duplication and improving maintainability, by using placeholders in the module configurations.
14
+
Rule templates let you reuse the same definition in multiple rules, reducing duplication and improving maintainability, by using placeholders in the module configurations.
15
15
When instantiating/generating a rule from a rule template, you define the values of the placeholders, which will then be substituted before the rule template becomes a rule.
16
16
That way you can apply the same logic to several situations.
17
17
@@ -100,30 +100,30 @@ ruleTemplates:
100
100
A rule template uses placeholders in the module configurations.
101
101
These placeholders must be substituted with actual values before a rule can be instantiated from a rule template.
102
102
The `configDescriptions` section defines these placeholders as configuration description parameters.
103
-
There must be one configuration description parameters per placeholder, and their names must match.
103
+
There must be one configuration description parameter per placeholder, and their names must match.
104
104
Otherwise, generating rules from the rule template will fail.
| `description` | ☐ | The parameter description. |
110
+
| `type` | ☑ | The parameter type, One of `TEXT`, `INTEGER`, `DECIMAL` and `BOOLEAN`. |
111
+
| `context` | ☐ | The parameter context, triggers special behavior in the UI like a lookup or syntax validation. See [Supported Contexts](../../developers/addons/config-xml.md#supported-contexts) for details. |
112
+
| `filterCriteria` | ☐ | Can be used in combination with certain `context`s to filter e.g. `Item`s that are shown in the lookup. See [Supported Contexts](../../developers/addons/config-xml.md#supported-contexts) for details. |
113
+
| `default` | ☐ | The default parameter value. |
114
+
| `required` |☑ | Whether the parameter is required. Defaults to `false`, but should be `true` for rule template parameters. |
115
+
| `min` | ☐ | The minimum parameter value, applies to `INTEGER` parameters only. |
116
+
| `max` | ☐ | The maximum parameter value, applies to `INTEGER` parameters only. |
117
+
| `step` | ☐ | The parameter value step size, applies to `INTEGER` parameters only. |
118
+
| `pattern` | ☐ | A regular expression used for validation, applies to `TEXT` parameters only. |
119
+
| `readOnly` | ☐ | Makes the parameter read-only. Defaults to `false`. |
120
+
| `advanced` | ☐ | Makes the parameter hidden unless advanced parameters are shown. Defaults to `false`. |
121
+
| `unit` | ☐ | The parameter value unit. |
122
+
| `unitLabel` | ☐ | The parameter value unit label. |
123
+
| `options` | ☐ | A list of predefined parameter values. Each option have a `value` and an optional `label`. |
124
+
| `multiple` | ☐ | Allows selecting more than one option if `options` are defined. Defaults to `false`. |
125
+
| `multipleLimit` | ☐ | Defines the maximum number of selectable options, if `options` are defined and `multiple` is `true`. |
126
+
| `limitToOptions` | ☐ | Allows custom values in addition to the predefined `options` if `false`. Defaults to `true`. |
127
127
128
128
### Modules Sections
129
129
@@ -135,7 +135,7 @@ The only difference is that the `config` sections can contain placeholders of th
135
135
```yaml
136
136
version: 1
137
137
138
-
rules:
138
+
ruleTemplates:
139
139
lights-on:
140
140
label: "Turn on light at sunset"
141
141
description: "This rule turns on the living room light when the sun sets."
@@ -195,4 +195,48 @@ rules:
195
195
sink: enhancedjavasound
196
196
text: Welcome
197
197
type: Say
198
+
light_control_template:
199
+
label: Light Control Template
200
+
description: A template for controlling lights based on time.
201
+
configDescriptions:
202
+
room_name:
203
+
type: TEXT
204
+
required: true
205
+
label: Room Name
206
+
description: The name of the room where the light is located.
207
+
start_time:
208
+
type: TEXT
209
+
required: true
210
+
pattern: '^([01]\\d|2[0-3]):?([0-5]\\d)$'
211
+
label: Start Time
212
+
description: The time to turn on the light (HH:mm).
213
+
end_time:
214
+
type: TEXT
215
+
required: true
216
+
pattern: '^([01]\\d|2[0-3]):?([0-5]\\d)$'
217
+
label: End Time
218
+
description: The time to turn off the light (HH:mm).
0 commit comments