Home Control Assistant Newsletter for August 23

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.
A useful technique: Mark, Find, and Process

In past week's "one day builds" I used "Tags". Today I'll show a technique I use in several places in my own HCA design. I call this technique, "Mark, Find, and Process".

Suppose that at some scheduled time or in response to some event I want to perform an action on some of my devices. What would that action be? Maybe to get their status, check their battery level, or control in some way that a group can't be used for.

 As I have said in previous messages, I'm really liking the sensors that Hubitat and SmartThings support. Some of my sensors auto report changes in the environment and others don't and I have to periodically request their status. One place I need to do that is when HCA starts, perhaps after a pesky Windows update. I can't do this using the programmer "Get Status" element as that adds the status requests for the selected devices to a "status request queue" for processing when HCA has a free moment. Generally, this happens right away but it can't be predicted, and I want to do something only after I know that all the sensors have been polled.

I could create a program to do this with a Test element for each sensor to force a status poll. Each time I add a new sensor I would need to change the program. Not that isn't hard, but instead I will use a technique involving marking the sensors I want to get status from, and then creating a program that finds them and processes each one found.

To "mark" devices I use a "tag". A "tag" is just a name (the "tag name") for a piece of state (the "tag value"). A tag is like a global variable as it too has a name and a value, but a tag isn't part of the big pile of global variables, instead it is attached to a single device.  For this usage I'll add a tag to "mark" the devices that I want my action to affect. How to do that? Open the device properties, choose the "tags" property and manually enter the tag. Like this:

Next, let's create a program that finds each device that has the "sensor poll" tag and gets its state. I can then use that program any time I need it – like at HCA startup.

Before we create that program, let's pause for a minute. What have we gained from this? We still have a program to create, right? By using this method, anytime I want to change the devices effected – to remove one or add some new ones – all I need to do is to add or remove the "sensor poll" tag on the devices. If we do this correctly, no programs need to be changed regardless of how many new sensors I want to include or how many sensors I want to exclude.

Let's begin. Here is the program. I'll go step-by-step.

The first Compute element uses the DesignOpen function to find all devices that have the "sensor poll" tag. Like this:

hDesign = _DesignOpen(1, "", "sensor poll");

The first argument to DesignOpen is a code and "1" means to look at all devices (the codes are in the user guide expressions chapter). The second argument is what room/folder to look in. By using "" for the room/folder name means to look in all rooms and folders for device. The 3rd argument is the name of the tag to look for.

The next Compute element gets a name from this list:

name = _DesignName(hDesign);

We could be at the end of the list of devices, so we must check for that in this Compute-test element:

name == ""

If we are not at the end of the list, then we have a device that is marked for "sensor poll". It is then a simple matter to get its status:

void = _IsOn(name);

OK, about that "void" as I get questions all the time about it. All functions in HCA expressions generate some sort of result.  To be a valid expression there must be an assignment of that value to some variable. In this case I don't care what the result is. I just want the operation to happen. When I have a "I don't care what the result is" situation I create a variable called "void" and assign to it. Why the word "void" and not "ignore" or "x", or "I_do_not_care_about_the_result"? It's just being a programmer for too many years I guess, and its common in that world. You are free of course to use a name that makes sense to you.

At this point the first device on the list has its status retrieved – a side effect of the _IsOn function. Now all we need to do is to go back to the element that gets the next name and then process that device. And keep doing that until we run out of devices so marked. From the image of the program you can see that is exactly what it does.

And that's it! Now anytime I need to add a new sensor or remove one that I don't want to get status from, all I need do is to add or remove the "sensor poll" tag to it.

Remember that this is just one use: There are many kinds of functions you can build with this same "mark, find, and process" method. How about for checking battery levels for any device that has a "battery" tag? Or changing the light color to any device that has a "color" tag?
Another nice feature of this: A program can also add or remove tags on a device. So, one program could implement this "mark, find, and process" technique. Another program could mark and unmark devices based upon some event. In effect, one program is controlling the action of another program. This could be a "Good thing" as Martha used to say.

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 25
The HCA 17 open beta this week is new: Release 17.0.25.

Please remember after installing to carefully read the release notes for the changes in this build and previous builds if you skipped any. This beta makes some incompatible changes from version 16 so know what you are doing.

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