-
Notifications
You must be signed in to change notification settings - Fork 50
Rule Item Library
HABmin provides a rule library to ease the task of creating common rules relating to items. The rule library allows generation of rules in a library, and when the library is updated, all rules can be regenerated. It also takes care of any item name, or other variable data substitution that may be required.
Rules are added using the Rules tab in the item configuration. When you add a rule, HABmin may ask you for parameters for the rule (depending on what the rule does) and these will be added automatically to the rule when it is generated.
The library file is an XML file as shown below. It has sections for the different parts of the rule, and these are combined when the rule file is produced.
<rule>
<name>PowerConsumptionNow</name>
<label>Calculate current power consumption</label>
<type>DerivedItem</type>
<itemtype>SwitchItem</itemtype>
<itemtype>DimmerItem</itemtype>
<description>Calculates the power consumed by the item given a user specified maximum power</description>
<import>org.openhab.core.library.types.*</import>
<import>org.openhab.model.script.actions.*</import>
<trigger>Item %%ItemName%% changed</trigger>
<action>var Number valState = %%ItemName%%.state as DecimalType</action>
<action>var Number valWatts = valState * %%UserWatts%% / 100</action>
<action>postUpdate(%%DerivedItem%%, valWatts)</action>
<variable>
<name>DerivedItem</name>
<label>New Item Name</label>
<type>Number</type>
<value>%%ItemName%%_Watts</value>
<description>The name of the new item.</description>
<scope>Setup</scope>
</variable>
<variable>
<name>UserWatts</name>
<type>Number</type>
<label>User defined Watts</label>
<value>0</value>
<description>Maximum power the item consumes when ON</description>
<scope>Item</scope>
</variable>
</rule>
When HABmin creates the rule file, it looks at all the rules that have been specified, and creates the section with all applicable imports, and then outputs a rule for each item rule.
- Home
- General Configuration
- Item Configuration
- Sitemap Configuration
- Binding Configuration
- Charting
- Persistence stores and graphing
- Rules and Automation
- Rule Designer: Overview
- Rule Designer: Building Blocks
- Rule Designer: Example 1
- Rule Designer: Example 2
- Rule Text Editor
- Technical
- Language Support
- Binding descriptor files
- Z Wave Product Database
- REST Item Config
- REST Item Icons
- REST Persistence
- REST Sitemap Config
- Rule Item Library
- Item Rule Configuration