Fully Enabling the Home Automation ProjectTo 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 TextingTo 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:
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:
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 TimersSome 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:
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 RuggeduinosThe Ruggeduino Devices (Arduino Devices) have all been stubbed out. The Scripts containing the Ruggedunio Devices are:
In each of the 4 Scripts comment the run_script" line which adds a stub. It looks like:
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:
In the Pi 1 Script, the "arduino_port" parameters are set in 2 lines which look like:
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 DevicesThe 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:
Open each of the 3 Scripts in your editor and find the 2 lines which start with:
Change each of the 2 lines as follows. Within the line, there is an 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:
Find the lines which start with:
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 UpThat'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). |