# Wiki source code of ti103

Last modified by Richard Johnson on 2018/08/01 00:46
Export
Office Formats
Export as PDF
Other Formats

Select the pages to export:

select all/ none

Legend:
  Created Page
  Modified Extension Page
  Clean Extension Page

Export as HTML

Hide last authors

author | version | line-number | content
--- | --- | --- | ---
| 1.1 | 1 |
|  | 2 |
|  | 3 | The [[X10 protocol>>url:https://en.wikipedia.org/wiki/X10_(industry_standard)]] allows a person to control devices (on, off, bright, dim, etc.) by sending commands over power lines. This protocol is extremely old (developed in 1975). I remember it being sold in Radio Shack catalogs when I was in high school, long before I knew anything about computers! This was the original "Home Automation". The protocol is actually pretty interesting in that it modulates the AC line during the short time when it's "crossing zero" (60 times a second). Commands are rather simple, but the devices have been around for many years and thus there's an X10 device for just about anything, and they're a lot cheaper than other, newer, Home Automation devices.
|  | 4 | \\One of the devices is named "TI103". It's an interface between a serial line and the electrical system. You plug one side into a terminal serial line (I have mine plugged into a serial line to USB adapter and thus into a USB port), and the other inside plugs into your wall outlet. It can read and write X10 commands on the electrical system. As such, it allows the computer to both control other devices as well as see what other X10 commands are being sent elsewhere. This is important because (1) some X10 devices will send signals when they detect something, such as a motion sensor, and (2) if you use an X10 button box to turn on and off devices, the computer needs to know when this has happened, even though it didn't initiate the command, so it can track device state.
|  | 5 | \\I purchased my TI103 device, then downloaded the hardware manual and wrote my own controller program. It's simple, yet it does everything I need. It serves as the backbone of all X10 interfaces in my home network. It allows me to turn on and off devices, track the state of devices, and initiate actions based on state transitions. This last ends up being very important, allowing me to do such things as turning on a light (X10 or even Wink controlled) when a motion sensor detects something. Since this is a script, it can even determine when an action is appropriate by looking at other information, such as whether or not it's past sunset, when recently the action occurred, etc., and sending email, or initiating other actions afterward.
|  | 6 | \\[[Here's the source of the ti103.c program.>>url:https://github.com/rajid/ti103]]
|  | 7 | \\The program understands the following commands (case doesn't matter):
|  | 8 |
|  | 9 | * "Description <house-code><unit-number> <descriptive string>"
|  | 10 | Associates a descriptive string with the X10 device.
|  | 11 | * "Trigger <house-code><unit-number> <function> <command>"
|  | 12 | Runs the <command> given, when the X10 device specified is sent the <function> given
|  | 13 | E.g., "trigger j10 on /usr/local/etc/send_email.sh"
|  | 14 | <house-code><unit-number> may be "ALL"
|  | 15 | (Note, the command is only triggered upon a state transition change. Multiple functions of the same type will only trigger the command to be executed once.
|  | 16 | * "Always <house-code><unit-number> <function> <command>"
|  | 17 | Always runs the command given when the X10 device receives any function code
|  | 18 | * "Never <house-code><unit-number> <function>"
|  | 19 | Never run any commands when you see this X10 device receive this function.
|  | 20 | * "Reset <house-code><unit-number> <function>"
|  | 21 | Clears any configuration associated with this X10 device.
|  | 22 | * "Dump"
|  | 23 | Dumps all configuration commands.
|  | 24 | * "Events <filename>"
|  | 25 | Specifies the location for an events log
|  | 26 | * "Reinit"
|  | 27 | Simply resets all internal state.
|  | 28 |
|  | 29 | For a small example, here's portion of my ti103 configuration file (this is not the complete file):
|  | 30 |
|  | 31 |
|  | 32 | {{{
|  | 33 | }}}
|  | 34 |
|  | 35 | desc A 4 weather system
|  | 36 |
|  | 37 | desc M12 bird mist
|  | 38 |
|  | 39 | always M06
|  | 40 |
|  | 41 | always M10
|  | 42 |
|  | 43 | never M10
|  | 44 |
|  | 45 | never J04
|  | 46 |
|  | 47 | always M05 ON /usr/local/etc/ti103_scripts/spa_motion.sh ON
|  | 48 |
|  | 49 | always J09 OFF /usr/local/etc/ti103_scripts/birds.sh OFF
|  | 50 |
|  | 51 | trigger M10 OFF /usr/local/etc/ti103_scripts/veranda_dusk.sh OFF
|  | 52 |
|  | 53 | trigger M10 ON /usr/local/etc/ti103_scripts/veranda_dusk.sh ON
|  | 54 |
|  | 55 | always M09 ON /usr/local/etc/ti103_scripts/veranda_motion.sh ON
|  | 56 |
|  | 57 | always J09 ON /usr/local/etc/ti103_scripts/birds.sh ON
|  | 58 |
|  | 59 | trigger all /usr/local/etc/ti103_scripts/notify.sh '%h%u [%d] %f' >/tmp/ti103.out 2>&1
|  | 60 |
|  | 61 | trigger M16 ON /usr/local/etc/ti103_scripts/front_door_dusk.sh ON
|  | 62 |
|  | 63 | trigger M16 OFF /usr/local/etc/ti103_scripts/front_door_dusk.sh OFF
|  | 64 |
|  | 65 | never J12
|  | 66 |
|  | 67 | events /usr/local/etc/events.log
|  | 68 |
|  | 69 | commands /usr/local/etc/ti103_commands.txt
|  | 70 |
|  | 71 |
|  | 72 | Notice that the <command> portion can use some C printf() style encoding in order to substitute house-code, unit-number, description, and function names.

# Applications

# Tips

If you're a new XWiki user, check out the Getting Started Guide.

# Need help?

If you need help with XWiki you can contact:

- Community Support
- Professional Support

XWiki Debian 13.10.2