Do not install!
Due to limitations on how rule templates can be installed and configured I need to publish this on the marketplace. However, this rule template doesn’t do anything except provide examples of ways to define parameters. The notes explain some lessons learned and limitations.
See Configuration Descriptions | openHAB for additional contexts one can use (e.g. IP address, URL, email address, etc.)
Notes:
-
Item filtering doesn’t appear to work, or I’m using it incorrectly.
-
It appears not to work when selecting --Scratchpad-- as a rule to run. The ${script} won’t be replaced.
-
Multiple selections appears as an array but there are not quotes so it probably can’t be used directly. Example:
[Default_Afternoon, Default_Bed, Default_Day, Default_Evening, Default_Night]
. Parsing will be required in the rule. -
Multiple selections will always be sorted in alphabetical order. The order can be changed in the code tab.
-
All non-required parameters must have a default or else the rule will fail to render.
-
Can’t figure out how to define Parameter Groups.
Language: JavaScript
Dependencies:
None
Changelog
Version 0.1
- initial release
Resources
uid: rules_tools:parameter_experiments
label: Parameters Tests and Experiments
description: Demonstrates examples for different types of rule template parameters
configDescriptions:
- name: dateTime
label: Date Time Item
description: Only allow selection of Switch and Contact Items
type: TEXT
context: item
filterCriteria:
- name: type
value: Switch,Contact
defaultValue: default
required: false
- name: group
label: Group
description: Only show Group:Switch Items
type: TEXT
context: item
filterCriteria:
- name: type
value: Group
defaultValue: default
required: true
- name: multi
label: Multiple Items
description: Select more than one DateTime Item
type: TEXT
context: item
filterCriteria:
- name: type
value: DateTime
required: false
multiple: true
defaultValue: default
- name: script
label: Script to Call
description: Only show Scripts and Rules
type: TEXT
context: rule
defaultValue: default
required: false
- name: text
label: Arbitrary Text
description: Any arbitrary text
type: TEXT
defaultValue: default
required: false
- name: integer
label: Integer
description: An integer > 0, defaults to 7
type: INTEGER
required: false
defaultValue: 7
min: 0
- name: thing
label: Thing
description: Select a Thing
type: TEXT
context: thing
required: false
defaultValue: default
- name: channel
label: Event Channel
description: Select an Event Channel
type: TEXT
context: channel
filterCriteria:
- name: kind
value: TRIGGER
required: false
defaultValue: default
- name: list
label: List Selection
description: Select from a list, default is ==
type: TEXT
options:
- label: "== equals"
value: "=="
- label: "!= not equals"
value: "!="
- label: "< less than"
value: "<"
- label: "<= less than equal"
value: "<="
- label: "> greater than"
value: ">"
- label: ">= greater than equal"
value: ">="
limitToOptions: true
required: false
defaultValue: ==
- name: decimal
label: Decimal
description: A decimal value
type: DECIMAL
required: true
defaultValue: 12.34
- name: time
label: Time
description: Select a time
type: TEXT
context: time
defaultValue: 01:10
required: false
defaultValue: default
- name: tag
label: Tag identifying the Items
description: Tag on Items that should be processed by this rule.
type: TEXT
context: tag
required: false
defaultValue: default
- name: multiScript
label: Multiple Scripts to Call
description: Only show Scripts and Rules
type: TEXT
context: rule
defaultValue: default
required: false
multiple: true
triggers: []
conditions: []
actions:
- inputs: {}
id: "1"
configuration:
type: application/javascript
script: >-
console.info('Parameters as substituted:');
console.info('Date Time Item: ' + '{{dateTime}}');
console.info('Script to Call: ' + '{{script}}');
console.info('Group: ' + '{{group}}');
console.info('Arbitrary Text: ' + '{{text}}');
console.info('Integer: ' + '{{integer}}');
console.info('Thing: ' + '{{thing}}');
console.info('Event Channel: ' + '{{channel}}');
console.info('List Selection: ' + '{{list}}');
console.info('Decimal: ' + '{{decimal}}');
console.info('Time: ' + '{{time}}');
console.info('Tag: ' + '{{tag}}');
console.info('Multiple Items: ' + '{{multi}}');
console.info('Multiple Scripts: ' + '{{multiScript}}');
type: script.ScriptAction