HousePanel can be used to automate things in your home using the integrated Rule engine. The Rule engine is activated through the Tile Customizer described in that section of this documentation.
To define a rule, in the Tile Customizer, add a new field and select the type “Rule” from the drop down box as shown below:
You must then enter a unique “User Field Name” as shown in the bottom left corner. 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 shown in the list above.
The Rule is then defined in the “Custom Rule” text box shown in the upper right corner of the above figure.
Simple Single Rule Actions
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. In the above example the Rule:
if contact==closed, 117=switch=on
is activated when the tile’s contact field is set to “closed”. The “tileid1” value is the Tile ID of the tile to be controlled when the Rule “if test” is evaluated to TRUE status. Tile ID’s can be obtained from the Show Info page or they are shown in the title bar when a tile is brought into the Tile Editor or Tile Customizer. Tile ID’s are can also be found by scanning the “hmoptions.cfg” file or inspecting the tile on the main page in Google Chrome of MS Edge. In our example above, the Tile ID of 117 corresponds to a Lamp in my office. The “fielda” value is the attribute of Tile ID to control. The “valuea” is the value to set the attribute “fielda” to. In the above example, the switch on Tile 117 (which is my office lamp) will turn on when the contact is closed on this tile. In this example, the Rule is defined on a contact switch connectdd to a pressure pad on my chair, so my lamp turns on when I sit down in my office (pretty cool eh).
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 Rule Logic
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.
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:macro” item in the tile, where “macro” is the name of this rule’s field. Again, “macro” can be any name that is unique.
Rules by default show up in a tile as “Rule:fieldname” where fieldname is the unique name of the field given when writing the macro in the Tile Customizer. This text can be hidden in the Tile Editor by changing the Opacity to 0.01 and then any graphical icon desired can be assigned. When this is one the field height will also need to be increased. Any styling of the rule field is possible, just like with any other field.