Menu Close

RULE Engine

HousePanel can be used to automate things in your home using the integrated HousePanel Rules engine. The Rule engine is activated using the Tile Customizer. To define a rule add a new field and select the type “Rule” from the drop down box as shown below:

HousePanel Rules engine using Tile Customizer
Defining Rules in the Tile Customizer

You must then enter a unique “User Field Name”. This name should be a simple word without spaces and without special characters, and it should not be the same name as one of the existing fields.

The Rule is then defined in the “Custom Rule” text box shown in the upper right corner of the above figure. Rules are written in plain text using an if-then language construct with the “if” block separated from the “then” block uisng a simple comma. Multiple “then” commands can be provided by separating them with commas.

Simple HousePanel Rules

A simple Rule follows the following syntax

    if field1==test1, tileid1=fielda=valuea

where “field1” is the name of the field in the tile where the Rule is being defined, and test1 is the value to compare it to for truth. If field1 is equal to the value given for test1, then the value of fielda will be set to valuea on tile tileid1. Consider the following example:

    if contact==closed, 117=switch=on

If the tile’s contact field is set to “closed”, tile #117 will set it’s swtich field to “on”.  The “tileid” values can be obtained from the Show Info page or they are shown in the blue circles when you are in edit mode.  In our example above, the “tileid” value of 117 corresponds to a Lamp in my office. So what happens is my lamp will turn on when the contact is closed. Of course this simple example can also easily be implemented in Hubitat using Rule Engine or any of the other automation apps, but it simply wouldn’t work if the switch was on an ISY hub. But this is no problem for HousePanel.

Multiple Actions in a Rule

The above is a very simple rule. More complex rules are allowed, including Rules that activate more than one tile or multiple fields in any given tile. To do this just add additional statements separated by a comma to the Rule. For example, if I wanted a rule that activates tile 117 and two other tiles, the above Rule would be modified as follows:

if contact==closed, 117=switch=on, 45=switch=off, 118=switch=toggle

In this more complex rule, the act of closing the contact will turn on tile 117’s switch, turn off tile 45’s switch, and toggle the state of tile 118. Any number of actions can be included in the rule. Because multiple rules are supported a best practice is to keep any one rule relatively simple and add additional logic to new rules.

More Complex HousePanel Rules

The first block in a Rule statement can be more complex than a single “if” statement. The HP Rule engine supports any combination of “and” and “or” comparisons to use as a trigger for the commands that follow. While “and” and “or” statements can be mixed, the order of the logic processing cannot be altered using parentheses; therefore it is only safe to mix “and” and “or” once in any given Rule if statement. Here are a few examples:

if playbackStatus==playing and volume > 50, 121=switch=on

In the above example the switch for tile #121 will turn on when a track is playing and the volume is greater than 50%.

if playbackStatus==playing and volume > 50, 456=trackname=$trackDescription

This example documents a very powerful feature of the Rule engine where it will add a new field to the target tile based on the value of an existing field in the trigger tile. In this example TIle #456 will get a new field called “trackname” with the name of the playing track but only when the volume is greater than 50. This magic is invoked by using a “$” prefix to an existing field in the trigger tile.

HousePanel Rules as Macros

The Rule engine can also be used as a simple macro generator by omitting the “if” statement altogether. In this mode any number of commands can be stringed together that will be executed when the field is clicked on in the GUI. Note that even those rules with an “if” statement will be manually executed irregardless of the if state when they are manually clicked on in the GUI. For example, the following is a Rule macro that will change the state of several switches and sets the mode to Home.

21=switch=on, 55=switch=off, 72=themode=Home

As with other Rules, this must be assigned to a unique field name. It will not be executed automatically because there is no “if” statement. The user must click on the rule item in the tile for it to execute. These are hidden by default so the tile editor will need to be used to unhide it to click on it.