garylm

System Controllers for Z-Wave

200 posts in this topic

David Powell's recent how-to article on using a hardware controller to bridge X10 to Z-Wave using an Elk M1G has me thinking about what would be the best system controller if I didn't have anything other than Z-Wave in the house.

With the upcoming crop of Z-Wave sensors, I'll be wanting to implement more complex event logic, including an alarm system.

I do Windows-based controls for a living, but I wouldn't trust a Windows-based event engine to handle something as critical as an intrusion alarm. I've seen plenty of Windows BSODs, anti-vir apps locking critical files, and the computer rebooting itself. That's fine as long as a human watches over the system, but for an unattended system, I think the closer I can get to a hardware solution, the better. I want my box to be as reliable as my plumbing.

A ladder logic controller would be ideal. I've got SLC-500 boxes out in the field that have been up for years. There are currently two such controllers with Z-Wave support, but...

-Elk seems to lack enthusiasm for adding support for Leviton 2-way communications.

-HAI has full support for Leviton 2-way, but their Omni box comes with a lot of UPB baggage that I don't need.

UNIX-like systems are also very stable. Many of the current crop of Z-Wave "gateway" boxes have Linux under the hood, but I'm not sure that they'll give me full flexibility for programming my events. Their ability to support devices outside of their product family seems questionable. The documentation I've seen for these boxes so far has been poor. Most of these gateway boxes want you to sign up for a monthly fee.

Cooking my own Linux box has appeal. I've been eavesdropping on the LinuxMCE project's board. They spend a lot of time spinning their wheels getting various motherboards to work with various peripheral cards with various drivers. They don't seem to have one sure-fire hardware combination that they can recommend. That is understandable with hardware being constantly phased in and out. Another problem is that their Z-Wave support isn't as solid as it once was. They've had problems with open-source licensing and the proprietary Z-Wave information that they were using from the dev kit.

I just want to write event logic. I'm almost willing to come up to speed on Linux. But I don't want to mess around trying to find hardware and drivers.

Our buddy Genesis' HomeDaemon project looks enticing. It uses the Leviton RZC0P interface, which has really opened up Z-Wave for some serious tinkering. If we could get some links here that would bring us up to speed on the FreeBSD operating system, which is supposedly very stable, I might go for it.

If cooking up a HomeDaemon-based system control box is a better solution for some of us than buying an off-the-shelf black box, and if there is a lot of interest, we'll be wanting to generate some HomeDaemon tutorials for future adopters. And to make such a box as turn-key as possible for the average Z-Waver, maybe we ought to come up with a standard hardware platform, that will still be around 18 months from now, that we can document and recommend.

The eBox-2300SX-JSK might be a candidate for a HomeDaemon box. It's a diskless, fanless Mini PCI box with 3 x USB, 2 x RS-232, 24-bit GPIO, Ethernet, 44-pin IDE header, and is powered from an external 5VDC source.

I don't want to turn this into a computer hardware forum, but maybe we can find a consensus on a Z-Wave system control solution that we would all enjoy reading about and writing about and tinkering with.

Summary (updated April 11, 2008):

Installing FreeBSD and HomeDaemon on an eBox 4850

  • HomeDaemon runs well on the eBox 4850, available through WDL Systems for less than $300. Make sure to request the power adapter for your region. (They've been known to ship the wrong adapter.)
  • Diskless options are available for the 4850 such as this 4GB, 44-pin DOM. (Follow these instructions for customizing HomeDaemon to run with the DOM.)
  • You will need to install the FreeBSD operating system on your 4850 before loading HomeDaemon. A good way to load FreeBSD is from an external USB CD drive with a bootable CD, created from the disc1 iso image for Intel 386 at FreeBSD.org. You won't need the other discs in the distribution if you connect your 4850 to the Internet during the install.
  • The BIOS settings on your box should automatically select the bootable CD drive if no other bootable drives are found.
  • Follow these instructions to load FreeBSD onto your 4850 box. When it comes time to name your host, call it "HomeDaemon". (Using this name will help to avoid confusion when following examples from the README files.)
  • After the install, you will need to reboot the box and load some additional files via your Internet connection. Follow these instructions.
  • Now that you've got FreeBSD on your box, you may be needing a UNIX command cheat sheet if you're a bit rusty. This vi Editor cheat sheet may also come in handy.
  • Remember to set the time on your box.
  • Create the "xten" user ID and a "HomeDaemon" user ID; you can use the "adduser" function to do this. Make sure "HomeDaemon" is added to the "wheel" group so that it can use the "su" function to gain root privileges
  • Install HomeDaemon on your box
    • Type: "cd ~HomeDaemon" (as root, with a "#" prompt)
    • Get the install file by typing: "fetch http://www.denninger.net/HomeDaemon.tar.gz"
    • Type: "gunzip HomeDaemon.tar.gz" (unzips it, and removes the ".gz")
    • Type: "tar xvf HomeDaemon.tar" (now you have a directory full of source files)
    • Type: "ls -la /usr/local" and make sure the following directories exist (use the "mkdir" function if they don't exist):
      • /usr/local/share
      • /usr/local/bin
      • /usr/local/etc
    • Type: "make" (compiles all the files you just unpacked)
    • Type: "gmake install" (installs what you built)
  • Follow the instructions for running HomeDaemon on a diskless system and also the README files that came with the HomeDaemon package.
Enable HomeDaemon Speech
  • HomeDaemon uses the Festival module that we loaded earlier to announce events through the audio out port.
  • Edit file "/usr/local/share/festival/lib/init.scm". Comment out all supported audio methods listed ahead of method freebsd16audio.
  • The default voice used by Festival isn't as good as the "ked" voice. To change voices, edit the file: /usr/local/share/festival/lib/siteinit.scm. Uncomment and change the following line to read:

    (set! voice_default 'voice_ked_diphone)

  • Edit file /usr/local/share/HomeDaemon/lib/events.english and add an "echo" command, piped through Festival, to one of your events:

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    Turn lamp on if back door open
    z Back-Door ON
    +
    Z Bedside-Lamp 70
    Z Alarm-Siren ON
    E echo 'The back door is open' | /usr/local/bin/festival --tts
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Using the Apache service and the eBox's IP address to access HomeDaemon from a web browser within the home network
  • I mostly followed the instructions in this how-to guide from FreeBSDMadeEasy.com, but I was able to skip the download and "make" steps because apache-2.2 has already been installed through the sysinstall utility that we used above when installing FreeBSD.
    1. Enable the apache22 daemon upon bootup by adding the following line to /etc/rc.conf:

      apache22_enable="YES"

    2. Locate the "ServerName" configuration parameter in /usr/local/etc/apache22/httpd.conf and enter either the registered DNS name of your host or its IP address:

      ServerName 192.168.0.6:80

    3. Use the "mv" command to move the entire contents from under the /usr/local/www/apache22/ directory to /usr/local/www/data/ leaving the sub-directory structure intact. (I don't know if this move is absolutely necessary.)
    4. Now that everything is moved, you will have to edit /usr/local/etc/apache22/httpd.conf, replacing every instance of "/www/apache" with "/www/data" For example, the "ScriptAlias" line should read:

          ScriptAlias /cgi-bin/ "/usr/local/www/data/cgi-bin/"

    5. Start the accf_http module from the command prompt: # kldload accf_http
    6. Also add the following line to /boot/loader.conf to load the accf_http module upon bootup:

      accf_http_load="YES"

    7. Before you start apache, verify the syntax of your httpd.conf by issuing the following command at the prompt: # apachectl configtest
    8. Start apache, using the following command at the prompt: # apachectl restart
    9. Point your browser at your server (in my case: http://192.168.0.6/) and you should see "Index of/" and the contents of your /usr/local/www/data directory.
  • Setup HomeDaemon to display an html summary of your system:
    1. Copy file /usr/local/share/HomeDaemon/lib/status.cgi.sample to /usr/local/share/HomeDaemon/lib/status.cgi and change its mode to 644 (chmod 644 /usr/local/share/HomeDaemon/lib/status.cgi)
    2. Copy file /usr/local/bin/HomeDaemon-status.cgi to /usr/local/www/data/cgi-bin/status
    3. chmod 7411 /usr/local/www/data/cgi-bin/status
    4. chown xten /usr/local/www/data/cgi-bin/status
  • Secure your HomeDaemon cgi file from unwelcome guests. Refer to this FreeBDSMadeEasy article or this older but more detailed "Apache Week" article.
    1. Configure apache to require authorization for accessing HomeDaemon directories by adding the following <Directory> sections to your httpd.conf file:

          AllowOverride AuthConfig
          Options ExecCGI
          Order allow,deny
          Allow from all
      </Directory>

      <Directory "/usr/local/share/HomeDaemon/lib">
          AllowOverride AuthConfig
          Options ExecCGI
          Order allow,deny
          Allow from all
      </Directory>
      <Directory "/usr/local/www/data/cgi-bin">
    2. Restart apache to make the above change effective.
    3. Create two .htaccess files, one residing in each of the two directories for which we required authorization in step 1 above. The contents of both files should look like:

        AuthType Basic
        AuthUserFile /usr/local/etc/httpd/users

        require valid-user
        AuthName "restricted stuff"
    4. Chmod 644 both .htaccess files.
    5. Create a list of authorized users with encrypted passwords using the following command:
      # htpasswd -c /usr/local/etc/httpd/users genesis

      Enter and re-enter a password for user "genesis" when prompted.
    6. Add additional users to the same file by using the same htpasswd command but ommiting the "-c" option.
      • View your HomeDaemon page by pointing your browser to: http://192.168.0.6/cgi-bin/status (Substitute your box's IP address for mine, of course). You should be prompted for a username and password before the HomeDaemon page is displayed.
      Access your HomeDaemon box over the Internet, using dynamic DNS

      If you don't have a static IP address, you can use one of many free DNS services on the web to create a hostname that will point to your dynamic IP address. I chose the dyndns service because that is what fellow Z-Waver Rob recommends.

      • Follow the how-to instructions at dyndns.com to create an account.
        1. The hostname that you choose does not need to be the name of your HomeDaemon box. It's probably better to choose some other unique name, as you will be using one of the free domains from their list, and "HomeDaemon" is probably already taken. Using some other name helps me to remember that the DNS hostname has more to do with my router than it does any of the computers in my network.
        2. I selected the "wildcard" option for allowing 4th-level hostnames.
        3. Use the default TTL setting.
        4. Select "A-record pointed to IP address" as the service type.
        5. The signup routine will query for the current IP address used by your router and display it. If you are signing up for the service from home, use the IP address shown. Otherwise, use the current IP address of your home router.
        6. "Web hop" - not selected
        7. "Mail routing" - use the default setting
      • Install an IP update client on your HomeDaemon box. This will monitor your network for the inevitable address changes and then automatically notify the dyndns service so that your hostname can be re-mapped to the new IP address. I chose the "inadyn" client, which is available on the FreeBSD update site.
        1. Use the FreeBSD update update utility: # /usr/sbin/sysinstall (Refer to this post if you need a refresher course on sysinstall.)
        2. Find and select "inadyn" under the "dns" category.
        3. inadyn requires "libtool", which is under the "devel" category. Find it and select it.
        4. The installer will automatically download and install these files.
        5. Create or edit the file "/usr/local/etc/inadyn.conf" using example 3 from this dyndns how-to. If you will be starting dyndns at boot time, you should add to this file the line: --background (Using the --background option will cause dydns to run in the background. If you don't specifically tell it to run in the background, it will run in the foreground and freeze your terminal, which is not a good thing if you are booting up.)
        6. Run inadyn from the command line: # inadyn (running it with no arguments will cause it to load by default the information from the file created above.)
        7. If you want to start inadyn at boot time, create the file /usr/local/etc/rc.d/inadyn.sh with the following contents:


              /usr/local/bin/inadyn
              #! /bin/sh

          Then chmod 555 the new file.

      • Configure port-forwarding on your router.
        1. Select your router from the list on this site.
        2. You will be presented with a list of applications. Select "apache."
        3. Follow the specific instructions for enabling apache port forwarding on your router. Remember to use the IP address of your HomeDaemon box. (Use the ifconfig command to find your box's IP inet address.)
      • Modify the "ServerName" parameter in /usr/local/etc/apache22/httpd.conf, replacing the IP address with your new hostname and domain name.
      • Restart apache
      • You can now browse to your HomeDaemon page using your hostname.domainname/cgi-bin/status

Share this post


Link to post
Share on other sites

FreeBSD is BEYOND stable.

I ran an ISP on it, and was the CEO and chief bottle washer.

In THIS sort of application it literally runs YEARS without an unsolicited reset.

I've had HomeDaemon on FreeBSD running my house since 1998. In that time the number of unsolicited resets and failures that I've suffered has been ZERO.

Using ADICON modules (direct-wire relay and analog sensors) I run DIRECT CONTROL of my HVAC plant. That is, using FORM C relays I actually emulate a thermostat, closing contacts to call for heat (2 separate stages), call for cooling, and call for fan. I trust the system sufficiently to do this and have never had a problem with doing so.

Now I have a UPS which talks to the machine, and will shut it down before its batteries run out. But in an application where "this is all it does", you don't care. If it goes down, so what? It comes back up when the power comes back on.

FreeBSD and HomeDaemon will literally run on any "junk" PC in terms of CPU and memory.

As for HomeDaemon, all you have to do is write an event file. Here is an excerpt from mine:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Foyer Evening
z Foyer-Motion ON
V Outdoor-Dark = 1
X Indicator-Night OFF
X Indicator-Lock OFF
+
X Dining-Cans DIM 30
X Foyer-Light DIM 30
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

This says:

"If we just saw the ZWave PIR called "Foyer-Motion" turn on, AND the variable Outdoor-Dark has the value 1, AND the X10 device code "Indicator-Night" is OFF AND the X10 device code "Indicator-Lock" is OFF then we want to send the devices "Dining-Cans" and "Foyer-Light" both Leviton X10 extended DIMs to 30%"

Another example, this one all Zwave:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Master Motion Night - High
z MBed-Motion ON
V Outdoor-Dark = 1
X Indicator-Night OFF
V Master-Level = 0
V Master-Lock-Ind = 0
V Master-Holdoff = 0
+
Z Master-Cans DIM 90
Z Master-Bed DIM 90
Z Master-ZFan ON
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

This says:

"If we just saw the ZWave PIR called "Mbed-Motion" turn on and the variable "Outdoor-Dark" is 1 and the X10 code "Indicator-Night" is off and the variable "Master-Level" is zero and the variable "Master-Lock-Ind" is zero and the variable "Master-Holdoff" is zero THEN send the ZWave commands to DIM Master-Cans and Master-Bed to 90%, and set the Zwave Device "Master-ZFan" to ON.

The "Master-Level" variable is used, by the way, to allow multiple "scene levels"; that is, I can push a button on the headstand set that variable to "1", which results in a lower light level, or "2" which results in an even lower one (a "romantic" level)

The "lock-ind" variable is used to "lock" the lights and fan on, so they will not "time out" due to lack of motion detected in the room, and is one of the buttons on a wireless X10 transmitter on the headboard.

The master bathroom also checks these when it sees motion, so the levels are consistent although the zones are totally separate.

Here's an example from the Master Bathroom - two separate events that are intertwined:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Master Bath - Daytime
z MBath-Motion ON  
V Outdoor-Dark = 0
+
Z MBath-Vanity DIM 75
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Master Bath - Is Cooling
z MBath-Motion ON
i Temp-Outdoors > 75
V Outdoor-Dark = 0
+
Z MBath-Fan ON
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

The cute part of this is that the two events both trigger off one "action" (the instance of seeing motion by the PIR) yet the second one checks the outdoor temperature and turns on the exhaust fan only if it is warm outside. So in the winter, we do not blow the desireable heat (and humidity!) out into the cold air, but in the summer we exhaust both (which are undesireable) to the outside.

And again, these only trigger if it is light (Outdoor-Dark is zero; that value is computed in a different set of events; the code knows how to compute sunrise and sunset given your latitude and longitude.)

And just for completion, here is the companion event that shuts it off when it times out:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Master Bath - Nobody There
Z MBath-Vanity ON 0:10
+
Z MBath-Vanity OFF
Z MBath-Fan OFF
Z MBed-Hall OFF
Z MBath-Tub OFF
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

This says that if the ZWave Device "Mbath-Vanity" has been on for 10 minutes (and has not been retriggered - each PIR motion "hit" above retriggers the timer) then we turn off all of the Vanity, Tub lights, Hall lights and the Fan.

There is almost no limit to what the event code can accomplish; my current "event set" at the house comprises over 300 separate entries.

A machine with an IDE header is interesting as you can plug a relatively-inexpensive (couple hundred dollar) solid state disk in. These are available in modest sizes (~2gb) which is more than enough room for something like this; in fact, a 1GB disk is plenty big enough if you don't care about keeping any sizeable amount of logfile. This gives you a "zero moving parts" device.

I could very easily come up with what amounts to a disk image in an ISO file that would contain an operating system for a given hardware configuration. MOST common hardware is currently supported; for the serial ports you can use either standard COM ports on a PC-style motherboard or FTDI-based USB serial concentrators. (Other USB-based chipsets are troublesome at best and have been known to lock up under heavy load - the FTDI ones are ok)

HomeDaemon will also run under Linux, by the way, but I don't officially support it as I'm more of a FreeBSD person. However, there are many people who have successfully compiled and are running it under Linux - there is nothing particular about the code that would make this difficult.

This system here would PROBABLY work (my concern would be the ethernet card... its not EXPLICITLY listed as supported, but similar Via chipsets are, and it PROBABLY will work as a consequence.....)

http://www.e-itx.com/via-en-t3310-fanless-...itx-system.html

Share this post


Link to post
Share on other sites

Genesis,

Does HomeDaemon support nested parenthetic expressions such as: ((A OR B) AND C)?

Is it possible to set up polling for a list of specific Z-Wave devices that do not support two-way communication?

Share this post


Link to post
Share on other sites
Genesis,

Does HomeDaemon support nested parenthetic expressions such as: ((A OR B) AND C)?

No; that would be done with two (or more) events. You can accomplish it but there is no explicit "or" support in the event list; that is, all conditions listed are "ands".

If you want "ors", you use multiple events in sequence.

I have contemplated re-writing the event processor to understand RPN as an option - there is already an RPN parser in the Applied Digital analog input module, so 90% of the work has been done (this is very useful for analog input scaling) The nice thing about RPN as a syntax is that other than stack depth limitations there is no limit to the complexity of expressions that can be evaluated.

The trick with doing so is to not break the existing syntax, lest a lot of really unhappy surprises show up in existing installations.

Here's an example of the input scaling from the appdig.devices control file:

# Outdoor temperature
I       2               1               1       U251 2 / 4.0 -

This declares Appdig Device #2, Unit #1 as Input #1, with an upper boundary of 251 (values over 251 are considered "out of range"), we then push 2 on the stack (the input's raw value is already there), divide, push 4.0 on the stack and subtract. The result gets stored in Input #1 (which the Event processor can then operate on)

If you're used to an HP calculator then this syntax makes perfect sense. If not...... :)

HomeDaemon's event processor actually uses an external program to "tokenize" the english event file when it starts up (or receives a signal 1, which tells it to re-read the event list.) 10 years ago CPU resource was a serious issue for the event processor; the original PC that I ran this on at my home was a 200Mhz Pentium Pro, and performing full-text parsing during runtime was excessively burdensome. As such the decision was made to tokenize the event file before it is loaded for processing so that the event processor can perform a simple arithmetic computation to determine a device address (rather than have to scan a full-text table for each entry)

The event processor runs on a timed basis (once every 10 seconds) and is also poked whenever the shared memory module receives a state-change message; it then makes one run through the entire event list to find things that need to be done.

While CPU pressure has eased with advancing technology there still is a good reason to keep overhead as reasonable as possible in that it helps response time a LOT compared to "fully parsed" command languages such as "Misterhouse".

Is it possible to set up polling for a list of specific Z-Wave devices that do not support two-way communication?

That's automatic and the interval on which the "universe" will be polled is configurable.

All the "wired in" devices I've tested send a hail on a local status change. HomeDaemon responds to that by initiating an immediate status request aimed at the device which sent the hail.

The notable exception is plug-in modules from Intermatic, which do not say ANYTHING when locally controlled.

Share this post


Link to post
Share on other sites
If you want "ors", you use multiple events in sequence.

Suppose I want to turn thePorchLight on if it's afterSunset OR myLightSensor says it's dark outside AND the alarm system is armed. Would you write multiple AND rules for driving thePorchLight?

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Porch Light - Sunset
V AlarmArmed ON  
V Sunset = 1
+
Z Porch-Light ON
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Porch Light - Dark
V AlarmArmed ON
V Outdoor-Dark = 1
+
Z Porch-Light ON
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Porch Light - Daylight
V AlarmArmed ON
V Outdoor-Dark = 0
+
Z Porch-Light OFF
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Porch Light - Sunrise
V AlarmArmed ON
V Sunset = 0
+
Z Porch-Light OFF
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Don't you run the risk of multiple rules fighting each other for control of the device? For example: it's after sunset but still light outside, it's after sunrise but still dark outside.

I've been checking out The Mat PLC Project and The Classic Ladder Project. That's the kind of event logic I'm dreaming of. I guess I can go ahead and dream, because the real work is in the Z-Wave interface, touch panel control, browser interface, and automation framework. And I don't have any of that.

Share this post


Link to post
Share on other sites

I would do it this way:

@@@@@@@@@@@@@@@@@@@@
Turn on Porch Light if sunset and alarm is armed
V See-Dark = 1
V Alarm-Armed = 1
Z Porch-Light OFF
+
Z Porch-Light ON
@@@@@@@@@@@@@@@@@@@@
Turn on Porch Light if dark and alarm is armed
V Outdoor-Dark = 1
V Alarm-Armed = 1
Z Porch-Light OFF
+
Z Porch-Light ON
@@@@@@@@@@@@@@@@@@@@
Turn off Porch Light if on and both not dark and daytime and the alarm is set
V Outdoor-Dark = 0
V See-Dark = 0
V Alarm-Armed = 1
Z Porch-Light ON
+
Z Porch-Light OFF
@@@@@@@@@@@@@@@@@@@@

That should do it, assuming you only want the OFF and ON sent if the alarm is enabled.

This of course assumes you have another set of events that maintain the "See-Dark" and "Outdoor-Dark" variables.

What I do for "Outdoor-Dark" is use the internal "sunset" and "sunrise" computations, with an offset.

For example:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Pre-Dark Evening Set
s before 1:30
+
V Outdoor-Dark 1
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Evening Reset (in case of boot during night time)
Night
V Outdoor-Dark = 0
+
V Outdoor-Dark 1
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Cancel Night
S
+
V Outdoor-Dark 0
#
# Bunch of other stuff I do when the sun comes up!
#
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

The "s" test is "Sunset" and the "S" (upper case) is "Sunrise". Both are computed by the code daily given your latitude and longitude; the "before" (and "after") keywords are allowed to set an offset. The "If lost" event is present because the set and clear events are valid only once during the minute during which they actually occur. "Night" is a test that is valid during the hours between sunset and sunrise, and "Day" is a test that is valid during the hours between sunrise and sunset, respectively.

For obvious reasons you do not want to use either "Day" or "Night" standing alone, or the event will retrigger on every pass when its day or night (you need other gating "ANDs" in the event to prevent retriggering on every pass.)

The test for the light being in the OFF state avoids sending repetitive commands for a device already in the desired state. Since Zwave is "supervised", you won't miss anything (if someone turns OFF the porch light when the conditions are met, the system will immediately turn around and "fix it")

"See-Dark" would have be maintained by something. If you had a ZWave (or X10) device that actually kept a state for whether or not there was light outdoors, you could use that directly (as a device instead of a variable); otherwise you'd have to maintain that with some other set of events.

Share this post


Link to post
Share on other sites

I just talked to Brandon at Automated Outlet. He says that HAI currently has the best Z-Wave support and that, notwithstanding all the built-in UPB support, I wouldn't be wasting my money if I got the HAI to control only Z-Wave equipment.

Brandon says that he thinks there is an Alpha release of the Elk M1G's serial expansion firmware for Vizia RF, but he hasn't heard any feedback.

I wanted to know why the HAI Omni costs more than the M1G. Brandon says the Omni comes with built-in Ethernet, where it's a $200 add-on for the M1G, and the HAI has two more serial ports than the M1G. He says the Omni has all the on-board I/O that I'll need.

Now I need to find out if I can program the HAI to put my PIR to sleep, or if that is something that would normally occur down at the driver level, over which I have no control.

Share this post


Link to post
Share on other sites

Why do you want a dedicated device?

That's the first question to answer..... HAI (or any other dedicated system) is INSANELY expensive compared to an open-source solution running on commodity hardware.

Share this post


Link to post
Share on other sites

Genesis,

So you can achieve a "nesting" effect by creating variables that represent a single AND operation or OR (two parallel rules) operation and then reusing those variables in other logical expressions further down the sequential chain?

Can you call the rule scan recursively if a variable changes further down the chain which affects an expression at the top of the chain? How would you limit the recursion depth?

Share this post


Link to post
Share on other sites
Why do you want a dedicated device?

My only reason for wanting a dedicated device is that if I spend too much time trying to get it to work, my wife will uncork all the contempt she has for me and my gadgets.

Share this post


Link to post
Share on other sites
Genesis,

So you can achieve a "nesting" effect by creating variables that represent a single AND operation or OR (two parallel rules) operation and then reusing those variables in other logical expressions further down the sequential chain?

Yep.

Can you call the rule scan recursively if a variable changes further down the chain which affects an expression at the top of the chain? How would you limit the recursion depth?

The ENTIRE rule set is scanned once on the occurance of:

1. A change (or retriggering; e.g. a PIR is on but sends a second "ON") of any device, variable, input or output in the system.

2. The passage of 10 seconds of clock time without a change.

So if you create a variable that represents the product of some other AND set of conditions, and an event that follows it in the list tests that variable, it will do exactly what you expect.

You can do something like this:

@@@@@@@@@@@@@@@@@@
First of two conditions
V Its-Dark-Outside = 1
+
V Night 1
@@@@@@@@@@@@@@@@@@
Second of two conditions - an X10 PIR has its "night" flag on
X PIR-Night-Sensor ON
+
V Night 1
@@@@@@@@@@@@@@@@@@
Clear "night" if both of the ORs above are false
X PIR-Night-Sensor OFF
V Its-Dark-Outside = 0
+
V Night 0
@@@@@@@@@@@@@@@@@@
If the "night" flag is on, and the Porch light is off, turn it on
V Night = 1
Z Porch-Light OFF
+
Z Porch-Light ON
@@@@@@@@@@@@@@@@@@

You can also specify whether a device is tested on the "edge" of a change or its "level"; the "Z" test above is a LEVEL change (we don't care how the light got off, if its off and night, turn it on) but you can also use the "z" command which is an "EDGE" change (that is, its valid exactly once each time that event occurs.)

For example on PIRs you'd use the "edge" triggering, since you don't want the event to fire again every pass through when the PIR is "on".

So you'd do:

@@@@@@@@@@@@@@@@@@@@
If night and the foyer sees motion, turn the light on
V Night = 1
z Foyer-Motion ON
+
Z Foyer-Light ON
@@@@@@@@@@@@@@@@@@@@

Again, the reason for the "z" is that you want the event to trip on the "Edge" of the PIR motion detection, not on the "Level" of the PIR being "on" - at least if you're using the PIRs in "Pulse" mode.

If you're using them in "Timed" mode, then you could use the level function instead, but there is risk there - if you miss an "OFF" due to a communications problem (PIRs won't answer polls when they're sleeping!) you're screwed - the light won't turn off!

For this reason what I Recommend is something like this:

@@@@@@@@@@@@@@@@@@@@
Turn on foyer light at night if we see motion
z Motion-Foyer
V Night = 1
+
Z Light-Foyer ON
@@@@@@@@@@@@@@@@@@@@
Turn off the foyer light after 20 minutes of no motion
Z Light-Foyer ON 00:20
+
Z Light-Foyer OFF
@@@@@@@@@@@@@@@@@@@@

This will turn on the light only if motion is seen when the "Night" variable is set to "1", and turn it off 20 minutes after the last time it has been retriggered.

If the PIR sees motion several times, each time it sees motion it will re-set the "last poked" state for the Light and reset the timer.

Note that during the daytime, since the PIR event will never fire, if you turn on the Foyer light by hand (local control) it will shut off after 20 minutes whether you trip the PIR or not, because the "Night" flag is not set - thus, the trigger never fires.

Share this post


Link to post
Share on other sites

Genesis,

Thanks for these explanations. My confidence is increasing.

How do you implement the Z-Wave commands? Are they hard-coded or read from a file? (I'm assuming that a "Z Porch-Light ON" launches a Vizia >N?SE??? command.)

Share this post


Link to post
Share on other sites

This document from HAI discusses the firmware update that added Z-Wave support to the OmniPro. They discuss only Z-Wave lighting control - nothing there about thermostats. And there's this statement:

Note: When a Z-Wave signal is received over the network, OmniPro II will automatically update the status of the device.

That's the two-way comm. support we're looking for. Supposedly you could then incorporate that device's status into a logical expression.

I still haven't found the document that discusses HAI's event logic. But even more importantly, we'll be wanting some command scripting that takes advantage of the RZC0P. Without that, there will be no way to put Z-Wave sensors to sleep and read battery levels and such. I doubt that HAI has implemented all the RZC0P commands for us.

Share this post


Link to post
Share on other sites
Genesis,

Thanks for these explanations. My confidence is increasing.

How do you implement the Z-Wave commands? Are they hard-coded or read from a file? (I'm assuming that a "Z Porch-Light ON" launches a Vizia >N?SE??? command.)

They're part of the code, yes.

A "Z Porch-Light ON" would generate a ">N3,ON". A "Z Porch-Light DIM 30" would generate a ">N3,L30".

The device description section of the event file is coded for the "type" of device (switch, dimmer, PIR, etc) and the code looks at that to figure out how to deal with it, both in sending commands and also when polling (for example there's no point in polling a PIR, as it will almost certainly be sleeping and thus not respond.) In addition the CGI display module (if you use it) looks at device type to figure out if, for example, a DIMmed level is valid or if it needs to display just "on" and "off", and whether the battery level field is active and means something (only for PIRs). Also, the event processor has a "Battery Alarm" event test that looks at the device type coding as well (are any devices displaying a low battery level, etc)

The Zwave module itself is a state machine that recognizes the different types of "status messages" (e.g. hails, async check-ins from PIRs, etc) and acts on them. If it is told to do so, it will attempt to initialize all PIRs in the system on startup and put them in "battery friendly" mode. The configuration file is checked every couple of minutes; if you change it, it will change the parameters in the PIRs as you request (so you can, for example, shut off power management if you want - or need - to. As an example if you intend to do a "network rediscovery" you have to turn off PIR power management first, because "network rediscovery" requires that all nodes be reachable. If you go from "off" to "on" in power management you must restart the ZWave module because a PIR that is not programmed to go to sleep will never check in and thus will never get asked for its configuration, compared, and put to sleep.

When the event processor wants to turn on a ZWave device it sends a message down the socket associated with the ZWave module. That module is responsible for picking up the command when the transmitter (RZC0P) is idle, sending it, waiting for the acknowledgement of both parsing and transmission, and sending any appropriate message(s) back to the shared segment handler when the command is acknowledged. That module also handles polling and asynchronous notification from devices (e.g. local control HAILs) and the requests that generates. It also handles sending periodic ">UP" (update controller matrix) commands to the network so the state machines in each device and controller (e.g. wall controllers) are maintained and "fresh".

The entire system is modular with each piece communicating using sockets, so you can run only the pieces you want. If you have no X10 devices then there is no need to run the X10 piece; ditto if you have no ADICON devices and/or no ADICON Leopard(s) in your system.

All of this is supplied in source code so if for some reason you wanted to change how all this is handled - you can.

Share this post


Link to post
Share on other sites

I went through the HAI OmniPro Owner's Manual and firmware release document, and I wasn't satisfied that it would be possible for a user to write handshaking logic that might become necessary with future Z-Wave devices. Just one finicky Z-Wave device could make the $1000-plus OmniPro look like a boat anchor.

So I think it's time to pick a Unix box. I think it should be a box that might be useful even if this control box idea doesn't work.

These Linux folks struggled with the eBox 2300 that I had my eye on earlier, but they had success with the ebox 4853. I don't think I need the 4853's dual LAN or compact flash slot, but I think it would be good to have more than one RS-232 port. The 4850 has two RS-232 ports, and it can be had for less than $300. There are 1, 2, 3, and 4 GB "Embeddisk" 44-pin IDE flash options available for this box.

Share this post


Link to post
Share on other sites

The second RS232 is extremely useful, as it allows the use of both X10 and ZWave without buying a FTDI USB serial concentrator.

The RealTek chipset SHOULD work, but again, that EXACT chipset is not listed in the FreeBSD compatability list for hardware.

Under $300? I might have to buy one to try it - with a 2GB flash disk its under $400. That's pretty damn attractive......

Note that if FreeBSD won't "find" the Ethernet port but Linux does you CAN run HomeDaemon under Linux. I just don't officially support it due to my preference for FreeBSD, but there are dozens if not hundreds of users who ARE running HomeDaemon on Linux..... I've heard from a few of them.

Share this post


Link to post
Share on other sites

That's a great little box especially for what you would be using it for.

The hard disk limitation is something that would slow me down from getting one simple because I run CQC which is a large application. 2GB sounds barely enough to load Windows on but it's probably plenty for linux I am assuming. Even 4GB is not much for windows and if you get the 8GB compact flash card as additional space it will probably show up as a second drive and not be very user friendly. I need a box like this for my theater. It has to run windows and have several gigs of spare space.

Share this post


Link to post
Share on other sites

You can stick a 2.5" HD in it if you want, from what I understand.

Those are available up to 120GB now.

2 or 4GB is more than enough for a minimal FreeBSD (and I presume Linux) installation.

The key "trick" is that you must insure that the machine does not run out of physical memory and need to swap. This is not at all difficult in this sort of environment.

Oh, the AC97 Codec should work with FreeBSD. The interesting part of that comes in that you can load Festival for "Text to Speech", and HomeDaemon will actually announce things if you want.

I have this operating at my home - it will say things like "The Hottub is ready" :)

Supporting that will likely require a real hard disk however, simply due to the size of the Festival package.

Share this post


Link to post
Share on other sites

I've ordered up one of these with a 4GB disk-on-module flash drive.

I already have a couple of extra notebook drives if I need to use one.......

If I can get this to work "cleanly" I can make a disk image for these flash drives that can be put into a file and then "DD'd" onto a different flash drive for installation and/or simply sell disk-on-modules preloaded with FreeBSD and the software.

I'll update when the machine gets here... the PXII boot means I should be able to network boot it off my existing infrastructure, but if not for some reason I'll plug a USB CDROM into it and load it that way.

Share this post


Link to post
Share on other sites
I've ordered up one of these with a 4GB disk-on-module flash drive.

I couldn't sit by and watch everyone else have all the fun, so I ordered one as well.

Now I need to get set up with a bootable CD for my USB drive.

Share this post


Link to post
Share on other sites

The bootable CD is easy. Go over to www.freebsd.org, download the ISO images and burn them onto a CDROM.

It may be necessary to build the system on a different machine, strip the size, and then load it onto the flash disk. I am going to experiment with this and, if the latter becomes necessary, I will come up with an image file that can be "DD'd" to the flash drive to initialize it.

I tried to order it with the 4GB flash module but they are apparently out - they have a sub (which is actually cheaper!) but I am waiting for them to confirm that it is otherwise compatable and can ship. If so, it should be on the way shortly.

Share this post


Link to post
Share on other sites
I couldn't sit by and watch everyone else have all the fun, so I ordered one as well.

Now I need to get set up with a bootable CD for my USB drive.

Cool, would either of you like to do a full review of the system for the Z-Wave World main pages. I'd have to talk to the editor to make sure it would get published but if you would like to do a review let me know. Otherwise I would love to hear what you have to say about it once you have had time to play with it.

Do you guys know if the VGA output could be converted to Component output easily? Also, how would you go about loading another OS on this thing if I were to put in a 2.5" IDE drive? Along the same lines how do you load software onto it? Do you just use the USB ports and/or external USB CD Driver or is there some other trick?

Share this post


Link to post
Share on other sites
Do you guys know if the VGA output could be converted to Component output easily? Also, how would you go about loading another OS on this thing if I were to put in a 2.5" IDE drive? Along the same lines how do you load software onto it? Do you just use the USB ports and/or external USB CD Driver or is there some other trick?

The "T" option of the eBox-4850T gives you S-Video out. At least that should get your video signal through any switch gear you have in the path.

I hope to load from a USB boot CD.

Hopefully we've chosen a good box out of the many ITX boards and thin client boxes that are available. I think it's semi-important to chose a readily available hardware platform so that anybody who follows this thread can build a system controller box without worrying about drivers and compatibility.

Having zero experience with other boxes that are intended to serve as system controllers, I doubt that I could give a balanced "review" of this box. I do want to share my experience with getting everything loaded and running, but Genesis has probably done dozens of boxes like this, and he doesn't seem hesitant at all to document what he's done. Just Google for "Home Daemon", and you'll find his how-to articles scattered all over the place.

I haven't yet found a dedicated Home Daemon forum, so I might be making a lot of noise here in the coming weeks. I'll try to keep the focus on Z-Wave though. I don't want to hog forum bandwidth, talking about just this box, and I don't want to keep pushing other people's topics down the page. Perhaps we need a quiet corner for our dialog while we're working out all the kinks. I do think that if we keep this discussion in the open, rather than doing it by private e-mail, that we'll leave a trail for others to follow, and who knows, maybe somebody will chime in and show us the error of our ways.

I know how difficult it is to maintain an online forum, keeping the discussion civil, and keeping troublemakers out. I appreciate this space.

Share this post


Link to post
Share on other sites

I have forum code (and the server to run it) too.... already doing it for investing (see http://tickerforum.org) - if this gets out of hand I can move it there.

Happy to do a writeup once I've got my hands on it and have run it for a while.

Component is probably easiest done via a conversion from VGA to HDMI, DVI or similar.

Share this post


Link to post
Share on other sites

Do I dare power my eBox off of a 6-Volt supply/charger? The eBox spec. says 5V and doesn't list an input voltage tolerance. That particular power supply wants to put out at least 6.5 Volts.

If this box is going to stay up for 10 years without a reboot, I'll probably want a battery or UPS somewhere in the line.

edit: I guess I could go with a 4-Volt battery and turn the power supply voltage down to float charge it, but the funkier the battery voltage, the more likely that it's been on the shelf for awhile.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now