Sometimes, even despite our best preparation and attention, things go awry:
We’ve worked hard to make Shion as robust as possible, but despite our best efforts, there are a circumstances where Shion will fail and give you a message like the one above. Perhaps you have an overeager puppy who pulled the USB cable from a PowerLinc, you received a faulty controller from the factory, or we did not find a hidden bug in our code.
This recipe shows you how you can configure Shion to respond to these events by taking action to let you know what’s going on.
Similar to the last recipe, we will be using Shion’s event features to catch hardware errors and let us know about the errors using e-mail.
Step 1: Open the Events
interface (using the Shion menubar item by your clock), and create a new event. Give the event a name (“Hardware Error”) and select Hardware Error
as the event type.
Step 2: Open Apple’s Script Editor application. This is typically located in the AppleScript
folder in your Applications
folder.
Step 3: In Script Editor, copy and paste the following code:
tell application "Mail" set theMessage to make new outgoing message↩ with properties {subject:"Home: Shion Error", content:"Shion ↩ has experienced a hardware error and ↩ needs a restart.", visible:true} tell theMessage make new to recipient at end of to recipients ↩ with properties ↩ {address:"my@address.com"} send end tell end tell
Note that the ↩
characters indicate that the line continues. I have inserted them to make the source code more readable.
Replace my@address.com
with your own e-mail address.
Step 4: Compile the script to verify that the code is correct. Run it once to verify that it is indeed sending out an e-mail.
Step 5: Return to Shion and in the Events
interface, select AppleScript
as the action to execute. A file open panel will appear. Use this panel to locate the script that you just created.
Step 6: With your new event in place, unplug the cable connecting your computer to the home automation controller. You should receive the dialog at the beginning of this recipe, as well as an e-mail a couple minutes later. (Restart Shion after you have confirmed that everything is working.)
You can use this technique with other AppleScript-compatible applications to send yourself an IM, text message, or other notification using other channels. For the moment, I will leave these as exercises for the reader, but will be happy to describe them in more detail in future recipes.
Recent Comments