Home Control Assistant Newsletter for August 9

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

And if you are looking for answers to the most common questions about HCA check out our Frequently Asked Questions page.
Bugs I have known and deeply un-loved

I have been doing most of my work these days using the HCA Visual Programmer to rebuild several of the major packages in the online library. This includes SmartThings, Hubitat, Ecobee thermostat, TPLinc, and many others big and small. The goal is to improve them in many ways, and you will soon see the results of all this work.

But during this time, I have kept track of some of the mistakes I made, and I wanted to share them in the hopes of making your life a bit easier by avoiding them. Here are my top five "I got it wrong".

The plus sign
I've written about this before, but it still gets me, even though I should know better. The plus sign means two different things: addition and string building. One good part of HCA expressions is that variables "adapt" to the type needed and generally this is what you want. Suppose a variable "v1" has a date-time. It is quite correct to construct a string of it like this:

"The time is " + v1

And no worrying about figuring out how to turn a date-time into a string as HCA does it for you and then builds the result. Now suppose you have a variable v2 containing the string "10". If you write this:

X = v2 + 1;
Y = v2 – 1;

You don't get quite what you expected. In the first case you wind up with a string "101". That's because HCA took the string "10" and saw the "+" sign, thought "string building" because one side of the plus sign was a string, then "helpfully" converted the 1 into a string and made the result is "101". No surprise that it isn't what was wanted.

In the second expression above, the minus sign is unambiguous. HCA converts both sides to numbers and  Y is assigned the value of 9 as expected.

To fix the first expression you could do this:
X = _int(v2) + 1;

To avoid: Take care anytime you use the "+" sign. Enough said.

The uninitialized string
This was a fun one. I was creating a string that had names of devices separated by commas. Like this: "Lamp,Counter Lights,Bookcase Lights". And I did that by adding a comma to the string I was building, and then the name of the device. I thought I was smart by doing this:

Text = text + _iif(_Length(text) == 0, deviceName, "," + deviceName);

The idea was to see if the string was empty, and if so I didn't need to add a comma and the name, only the name since it was the first addition to the string. If the string had something in it, then I needed to add a comma and then the name.

But here is the problem. I never assigned a value to the variable "text" before. As all variables in a program are initialized to a Boolean "no", what I got was this: "No,Lamp,Counter Lights Bookcase Lights"

As HCA "helpfully" converted the value of the variable "text", which contained a Boolean No, to the string "No". That made my test say the string wasn't empty so it added the comma and the first device name.

To avoid: Initialize variables as needed. I added this at the start: text = "" and all was well.

Is it a string or an expression?
This one gets me again and again. When starting a parameterized program, you supply the values of the arguments. Suppose the program controls a device to a percentage over a specified number of seconds. Like this:


That works great. Now suppose instead of supplying the values in that way you wanted to do some computation on the number of seconds and then start the program supplying the value of the variable that holds the result of the calculation. Suppose that variable is called "rampTime". I do this:

And it is wrong! What gets supplied to a program for one of its parameters is just a piece of text. HCA "helpfully" gives the program the string "rampTime" and not the value of rampTime like I wanted. I need to do this:

Putting the expression in %'s has HCA evaluate it before building the value of the parameter to give to the started program.

To avoid: Make sure to enclose expressions in %'s when supplying them to the parameters of a program.

You must do Error checking
This isn't a specific issue but more of a general principal. Many of the expression functions tell you if they worked or not by a specific value they generate. For example, the FileOpen function either gives back a file handle or a -1. If you don't check for the -1, signifying the file didn't open, then your program continues, and things probably don't go well. 

To avoid: Always check the value from a function that tells you if it worked by the value it returns. It could be some correctable issue in your program that is causing it to fail, and even if not – a file not found error for example – at least you can construct your program to handle the issue.

If it is wrong in one place, it may be wrong others
This is another "point of philosophy" but I have worked with too many developers who don't do this. If you find a problem in one area, maybe just a "typo" or a misunderstanding of how something works, you may have made the same error elsewhere. 

In the section above on providing the result of an expression to a start-program element, last time this happened I made the fix and then remembered to check the other start-program elements in the program. Sure enough I found another place I made the same error and fixed it.

To avoid: Find a problem in one place, look for other places you may have made the same error. Don't wait to hit problems when you can proactively prevent them.

HCA Server machines
We still have available Windows 10 small footprint computers that are perfect for running the HCA Server. We do all the updates for you - yes, even the big Windows 2004 update, install HCA, and get it all ready for 24/7 operation. And with the HCA design backup/computer move tool, getting up and running only take minutes after you get this new machine. Want more info? It's all on the website HCA Server Computer page.

V17 Open beta now available - beta 22
The HCA 17 open beta this week release 17.0.22. 

Please remember after installing to carefully read the release notes for the changes in this build and previous builds if you skipped any.

Want in on the version 17 beta? All you need do is to enter your HCA registration code into the
online form as usual, and the resulting page contains a link to the beta page for download. The beta zip file password is the same as your V16 password. Please read fully and carefully the build notes. One suggestion: If you are using SmartThings or Hubitat you really should get on board with the beta as there is new stuff heading your way that needs this beta version.
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.

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