Software Overview  |  Sitemap  |  Downloads  |  Developers  |  Forums
Small_clear_logo_llc

Fully Enabling the Home Automation Project

To allow this system to run without physical devices, we altered some of the Scripts. Here, we will go over which Scripts we altered and how you can recreate a fully functioning system.

In most cases, we've replaced a functioning Device with a simpler one which has the same terminals, but performs no actions. We call these simple devices, "stubs", and the act of replacing them "stubbing". Stubs are implemented as simple StateMachines, which do nothing. In much of this section, we'll be replacing stubs with fully functioning Devices.

When you want to alter a Script, the easiest thing to do is to use the Script Editor. Find the Script on the Scripts page and click on its "Edit" action to edit the Script.

Enabling Emailing and Texting

To enable emailing and texting, we will replace 4 stubbed Devices with 4 real ones. Each of the 3 Pis performs their own emailing and texting using EMail Devices, and there is one Script for each Pi which creates all its EMail Devices. The Script files are:

alarm_email_pi1.script
alarm_email_pi2.script
alarm_email_pi3.script

Pi 1's Script has 2 EMail Devices, and Pi 2 & 3's Scripts each have 1 Email Device. You need to edit each of the 3 Scripts. Find the lines which look like:

# make a stub and comment out the real EMail device
run_script("Scripts/Device/Virtual/StateMachine", ...

Comment out the "run_script" line and uncomment any commented "run_script" lines immediately below it. Pi 1's Script has 2 Devices you need to replace, and Pis 2 & 3 each have one.

When adding back an EMail Device, you'll need to tell it about your email address and email account, so the Device can send and receive messages. Be sure to change the default parameters in the "run_script" lines so they work for you. For more information about these parameters, see EMail Devices.

Orient Your Solar Clock Timers

Some of the system's timers turn on and off based on when the sun sets and rises. The default values are only correct if you are located at longitude 0.00, latitude 0.00, so you will probably need to adjust your timers. The solar timers are in Script files:

solar_clock_late_day.script
solar_clock_night.script
solar_clock_day.script
solar_clock_evening.script

Edit each of the files and modify the "longitude" and "latitude" parameters for your location. The Devices you are modifying are Sun Interval Timers. See Sun Interval Timers to learn more about them.

Enable the Ruggeduinos

The Ruggeduino Devices (Arduino Devices) have all been stubbed out. The Scripts containing the Ruggedunio Devices are:

ruggeduino1.script
ruggeduino2.script
ruggeduino3.script
ruggeduino4.script

In each of the 4 Scripts comment the run_script" line which adds a stub. It looks like:

# Use an Arduino stub instead of creating a real Arduino Device.
# If you want to use a real Arduino, comment the line below and uncomment
# the (3 commented) Arduino run_script lines.
run_script("Scripts/Device/Virtual/StateMachine", file_name:"Scripts/user/home_automation/ruggeduino1_stub.yaml", id:"ruggeduino1", table_name:"")

Below this line, add back the Ruggeduinos by uncommenting the 3 commented "run_script" lines.

Next, you need to set the "arduino_port" parameters for your 4 Ruggeduinos. They are set in the following 3 Scripts:

startup_pi1.script
startup_pi2.script
startup_pi3.script

In the Pi 1 Script, the "arduino_port" parameters are set in 2 lines which look like:

# Add the Ruggeduinos

run_script("Scripts/user/home_automation/ruggeduino1.script", arduino_port:"/dev/ttyACM0")
run_script("Scripts/user/home_automation/ruggeduino2.script", arduino_port:"/dev/ttyACM1")

In Pis 2 & 3, there is one such line.

The default "arduino_port" parameter values work when installing Ruggeduinos on Raspberry Pis. You should check to see if the default values are right for your system. For details on finding your "arduino_port" parameter values, read about the "port_location" parameter in the Arduino Installation and "port_location" FAQ pages. Ruggeduinos and Arduinos are software compatible, so you can use any pin compatible Arduino device as a "Ruggeduino" (Arduino Unos are good substitutes).

Be sure your "Ruggeduino" devices are running the Firmata software. Our Ruggeduinos did not come with Firmata pre-installed, though our Arduinos did. To learn more about installing Firmata on Arduino compatible devices, read the How To Install Firmata page.

Set Up the Terminals Sharing Devices

The 3 Pis in the system share signals using Terminals Sharing Devices. The Scripts were changed so all the Pis and all these Devices could reside the same host. When you build your own home automation system, you may want to run it on separate hosts (3 Pis, for example). We're going show you how to do that.

First, you need to know the network names of your hosts. If you hosts don't have network names, you need to know their IP addresses. We'll assume you want to run your system on 3 hosts that have network names host1, host2, and host3. host1 will be running the Pi 1 system, host2 the Pi 2 system, and host3 the Pi 3 system.

There are Terminals Sharing Devices that implement the heartbeat function. Each Pi sends regularly spaced events (heartbeats) to the other two Pis, and each receives heartbeats from the other two Pis. When a Pi doesn't receive a heartbeat, it sends an error message. The heartbeat function is implemented by the following Scripts:

heartbeat_pi1.script
heartbeat_pi2.script
heartbeat_pi3.script

Open each of the 3 Scripts in your editor and find the 2 lines which start with:

run_script("Scripts/Device/Sharing/TerminalSharer", ...

Change each of the 2 lines as follows. Within the line, there is an other_host and an other_host_port parameter. Look at the value of the other_host_port parameter. If it is 4567, set other_host to "host1"; if it is 4568, set other_host to "host2"; if it is 4569, set other_host to "host3". Lastly, set the other_host_port parameter to 4567 (if it's not already).

In another set of Script files, there are 2 signals, the house_preset signals, which are shared by all the host systems. These are encoded signals which give the overall state of the system ("summer_here", "winter_away", ... ). The actual signals enter via Pi 1's Ruggeduino 1. From there, they are shared with the other two systems. The house_preset signals are set up in Script files:

wire_pi1.script
wire_pi2.script
wire_pi3.script

Find the lines which start with:

run_script("Scripts/Device/Sharing/TerminalSharer", ...

There are 2 such lines in the Pi 1 Script and one in both the Pi 2 & 3 Scripts. Perform the same modifications you did when modifying the heartbeat files.

Wrap Up

That's all the modifications you need to do to get a fully functioning system. Feel free to skip some of these modifications, as each can be done independently. For example, if you are interested in testing out some real hardware, add back the Ruggeduinos and leave the EMail stubs in place (so you don't get a lot of messages).

Catalina Computing, LLC.

Copyright © Catalina Computing, LLC. (2013-2017)




Page last updated: Tue Jul 14 22:58:56 2015 (UTC)