Copy

Home Control Assistant Newsletter for December 13

Have you looked over the version 17 release notes? Lots of changes that you can incorporate into your designs right away. Easy upgrade.

Looking for answers to the most common questions about HCA? Check out our
Frequently Asked Questions page.
 
“Funny” characters
Many years back, during the design of HCA, the first piece of that design was what we now call the “Visual Programmer”. The idea was that programming is difficult and a method that could allow a user to “string together” a few elements and have it perform something useful without any “scripting” would be a win. That was accomplished. 17 versions later it still is the main way HCA programs are built.

For the most part HCA is free of the sort of syntax issues that plague many scripting languages with lots of rules to learn. But there are times when you need to get your “hands into the bits” and that’s where expressions and the Compute and the Compute-Test element come into play.

With that sort of programming comes along a few “funny characters”. That’s my term for anything that has a use beyond what is usual. For example, while the minus sign – or dash character - still means subtraction as usual, it is also a way in HCA to separate the room or folder name from the object name. For example, “Kitchen – Lights”. The “dash” character takes on special meaning. Let’s tackle some others.

Square Brackets
The left and right square brackets are used to enclose the name of a variable that contains spaces. Suppose you have a variable called “Start Time”. You think you could write this in an expression:


Start Time = _now()

But it wouldn’t work as HCA doesn’t figure out that “start blank time” is a variable name. For variables that contains spaces in expressions you must enclose them in square brackets. Like this:

[Start Time] = _now()

Percent signs
The percent sign is a way to embed an expression into a place where HCA is expecting just a piece of text. As an example, consider the Email element. Suppose in the body of the email message you want to include the current “alert color” (red, yellow, green). There is an expression function that gives you that called ProblemLevel. You could put this in the body of the email in the messaging element.


The HCA color is %_Choose(_ProblemLevel() + 1, “Green”, “Yellow”, “Red”)%

The first argument to the Choose function is a number starting at 1 and generates as its result the value of the nth parameter. ProblemLevel returns the alert color as a number 0, 1, or 2. Where 0 is green, 1 is yellow, and 2 is red. We need to add one to get it in the range that the Choose function uses.

During processing of the messaging element, HCA finds the expression in the body text, evaluates it, and replaces the section with %’s with the result of that expression.

Dollar signs
The dollar sign is the method HCA uses to distinguish a program parameter from the name of a variable. Suppose a program has 3 parameters: StartTime, Count, and Action. Suppose it also has local variables called counter and previousAction. Here are some example expressions:


counter = $count
previousAction = $action


“counter” and “previousAction” don’t get prefixed with a dollar sign as they are just variables. “action” and “count” do have the $ prefix so HCA knows that they are the names of parameters.

Colon
The colon isn’t commonly used but there are times it is needed. Suppose you have a motion sensor that has two parts as many do. The first part is for motion and the second part tells if it is light or dark. In a program if you want to test the state of the light/dark sensor you would do it like this:


_IsOn(“Kitchen-Motion:2”)

The colon included in the name of the device tells HCA that it has more than one part and you want the status of the 2nd part, which in this case is the light/dark part of the sensor.

Vertical Bar ( | ), Tilde ( ~ ), Circumflex ( ^ )
These three characters can be used in expressions and are real hard-core programmer stuff. Vertical Bar means a binary OR, tilde means binary NOT, and circumflex means binary XOR. If you don’t know what these are don’t be too concerned. Just know that those characters can’t be in names for devices or variables.

When to embed expressions and when not to
This is a common question: when to enclose an expression in %’s? In some visual programmer elements whose properties contain text you can embed in that text an expression enclosed in percent signs. In the section above on percent signs I showed an example of this. There are many elements where you can do this: the messaging element, the show-message element, the log element, and several others. Want the full details? Review
technical note #119 on the website.

In a Compute or Compute-Test element there is no use of percent signs as the entire element contents are an expression. For example, if I want to create a string that shows the HCA color as we did above, this is what to put in the Compute element:

Text = “The HCA color is “ + _Choose(_ProblemLevel() + 1, “Green”, “Yellow”, “Red”);

Note the absence of percent characters as it is all one expression. The plus sign in this case glues two strings together which makes the result we want.

Since I titled this weekly message “Funny Characters”, how about I end with this: A font walks into a bar. The bartender says, “Hey you, get out. We don’t want your type in here”. Cheers.

Stay safe, Wear a mask. Be a member of a community that helps. Science will save us.
 
User-to-User forum

An HCA User who wanted to set up a forum for user-to-user communication. I'm passing this on, but please know that this is not a HCA company project and I will not be spending much time there so I don't know how this will work out. Here is a link to what he set up.


https://www.reddit.com/r/HomeControlAssistant/

 
Want to take the next step in automation? Want to get started with Amazon Alexa and Google Assistant and control HCA by voice commands? Even if you are a long-time user of HCA, the Getting Started guides have all the info you need on client-server, mobile applications, DDNS, and voice assistants.

All of the
Getting Started Guides are available on the support website.
 
Copyright © 2020 Advanced Quonset Technology, Inc, All rights reserved.


Want to change how you receive these emails?
You can update your preferences or unsubscribe from this list.

Email Marketing Powered by Mailchimp