{"id":8105,"date":"2012-12-08T11:35:27","date_gmt":"2012-12-08T16:35:27","guid":{"rendered":"http:\/\/scruss.com\/blog\/?p=8105"},"modified":"2013-02-08T16:20:03","modified_gmt":"2013-02-08T21:20:03","slug":"x10-home-automation-with-raspberry-pi-heyu","status":"publish","type":"post","link":"https:\/\/scruss.com\/blog\/2012\/12\/08\/x10-home-automation-with-raspberry-pi-heyu\/","title":{"rendered":"X10 home automation with Raspberry Pi: heyu"},"content":{"rendered":"<p>I never quite get the hang of setting timers for lights. Either I forget daylight savings completely, or I set something so general that I find the lights coming on mid-afternoon when it&#8217;s still light. Minor annoyances require the over-application of technology, and fast!<\/p>\n<p>I scored an <a href=\"http:\/\/www.x10.com\/catalog\/cat_automation.htm\">X10<\/a> ActiveHome Starter Kit for cheap(ish) on eBay. X10 is a pretty old technology (1970s! Scottish!) and has some severe limitations (slow! prone to interference! unencrypted!) but has a large user base, and did I mention it&#8217;s pretty cheap?<\/p>\n<p>The key component of a computer controlled X10 system is the CM11 computer interface. It takes serial commands from a computer, and pushes them out (slowly) as signals modulated over your house wiring. Various plug-in modules pick up these signals, and if the device address in the command matches that of the module, the module turns on (or off, or dims).<\/p>\n<p>Since the version of the CM11 interface that I have is serial, I&#8217;ll need a USB\u00e2\u2020\u2019Serial converter. All I had lying around was a very old Prolific PL2303 interface, which works fine with Raspbian, but I&#8217;d prefer an FTDI one for more reliability. Long-term stability of USB Serial on the Raspberry Pi is currently questionable; there&#8217;s some good <a href=\"http:\/\/www.raspberrypi.org\/phpBB3\/viewtopic.php?f=44&amp;t=8010&amp;start=75#p181751\">discussion on kernel parameters that might help<\/a>.<\/p>\n<p>To send X10 commands from a Raspberry Pi (or indeed, any Linux computer) you need <a href=\"http:\/\/www.heyu.org\/\">heyu<\/a>. You have to build it from source, but the instructions are clear, and it takes about 10 minutes to build on a 256 MB Raspberry Pi. The install script asks you where your serial port is, and for my device it is <code>\/dev\/ttyUSB0<\/code>.<\/p>\n<p>(<strong>Update<\/strong>: I re-imaged the Raspberry Pi that runs these tasks today and rebuilt heyu without success. <em>Don&#8217;t<\/em> assume you can do a <code>.\/configure; make; sudo make install<\/code> here. You <em>have<\/em> to run heyu&#8217;s own <code>.\/Configure.sh<\/code> first before make. It does some non-obvious magic. Read the README and you&#8217;ll be fine, unlike me &#8230;)<\/p>\n<p>Most of the lights in our house are fluorescent, which is a problem for the standard X10 lamp modules. CFLs are not dimmable, and the standard <a href=\"http:\/\/www.x10.com\/products\/x10_lm465.htm\">lamp module<\/a> doesn&#8217;t work with them. The lamp modules don&#8217;t work very well with low-voltage halogen lamps, either; extreme buzzing ensues, with a faint brownish light oozing out from the bulb and a vague burning smell. Best avoided, and better to use an <a href=\"http:\/\/www.x10.com\/products\/x10_am486.htm\">appliance module<\/a>, which is a simple mechanical relay.<\/p>\n<p>The only controller that came with the kit that would work with my lights was the X10 transceiver, which also includes an appliance switch. I gave this device an address of H9 (house code H, unit code 9), and plugged in a lamp. To turn it on, I issued this command:<\/p>\n<pre>heyu on H9<\/pre>\n<p>After <del>about 8-10<\/del> a couple of seconds and a loud CLUNK from the controller&#8217;s relay, the light came on (if it&#8217;s taking longer, <a href=\"http:\/\/scruss.com\/blog\/2012\/12\/08\/x10-home-automation-with-raspberry-pi-heyu\/comment-page-1\/#comment-243640\">read this comment<\/a>). To turn it off, I told it:<\/p>\n<pre>heyu off H9<\/pre>\n<p>Whoa! Raw power! I can now turn AC devices on and off from my Raspberry Pi (<a title=\"Work # 227: The lights going on and off.\" href=\"https:\/\/www.youtube.com\/watch?v=MDqU8hhy99M\">Martin Creed<\/a>, watch out!). I guess I could set up cron jobs to control the lights, but cron doesn&#8217;t know about solar time (<a href=\"http:\/\/www.risacher.org\/sunwait\/\">Sunwait<\/a> and <a href=\"http:\/\/stenarson.com\/projects\/suncron\/\">SunCron<\/a> do, if you want to futz with them). I&#8217;ve got <a href=\"http:\/\/misterhouse.sourceforge.net\/\">MisterHouse<\/a> running on the Raspberry Pi for more clever control, but more on setting that up later.<\/p>\n<p>Incidentally, if you&#8217;re in Europe, <a href=\"http:\/\/www.marmitek.com\/en\/products\/home-automation-security\/x-10-home-automation.php\">Marmitek<\/a> sell a variety of 220 V 50 Hz X10 modules. Their website is much clearer than the angry-fruit-salad that is <a href=\"http:\/\/www.x10.com\/\">x10.com<\/a>. It looks like X10 have <a href=\"http:\/\/www.x10.com\/products\/cm15a_sp_kpmis_fb189.html\">updated their starter kit<\/a> to include the newer CM15 USB interface which will likely not work with heyu.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I never quite get the hang of setting timers for lights. Either I forget daylight savings completely, or I set something so general that I find the lights coming on mid-afternoon when it&#8217;s still light. Minor annoyances require the over-application of technology, and fast! I scored an X10 ActiveHome Starter Kit for cheap(ish) on eBay. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7],"tags":[2600,2602,270,2510,2601],"class_list":["post-8105","post","type-post","status-publish","format-standard","hentry","category-computers-suck","tag-heyu","tag-home_automation","tag-linux","tag-raspberrypi","tag-x10"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pQNZZ-26J","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/8105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/comments?post=8105"}],"version-history":[{"count":6,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/8105\/revisions"}],"predecessor-version":[{"id":8291,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/8105\/revisions\/8291"}],"wp:attachment":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/media?parent=8105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/categories?post=8105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/tags?post=8105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}