-
Notifications
You must be signed in to change notification settings - Fork 2
/
README
217 lines (147 loc) · 7.6 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
mochad is a Linux TCP gateway daemon for the X10 CM15A RF (radio frequency) and
PL (power line) controller and the CM19A RF controller.
mochad stands for Multiple Online Controllers for Home Automation Daemon.
0.1.16 Fix "Could not find endpoints" problem.
0.1.15 Add support for 2011 CM19A.
0.1.14 Fix OpenRemote too many open sockets problem. Add shutters/blinds command.
0.1.13 Fix -d debug option. Add support for DS12A.
0.1.12 Add --raw-data option.
0.1.11 Fix xdim (extended dim) that only worked for unit code 3.
0.1.10 Fix major client problem. Commands from clients stopped working.
0.1.9 Add support for OpenRemote 2.0 with iPhone and Android clients.
0.1.8 Add support for Chumby application.
== Build it
mochad compiles and runs on Ubuntu 10.04 and 10.10. The libusb-1.0 development
files are required. To install,
sudo apt-get install libusb-1.0-0-dev
If you are building on a Beagleboard/Beaglebone (http://beagleboard.org)
using the native compiler, do the following to install libusb-1.0.
opkg install libusb-1.0-dev
The usual pattern for building the code applies.
tar xzf mochad-...tar.gz
cd mochad-...
./configure
make
sudo make install
Please see http://sourceforge.net/apps/mediawiki/mochad/index.php?title=Main_Page
for details on building for OpenWrt.
== Run it
Plugging a CM15A or CM19A should launch mochad. There no need to run mochad
by hand or run it from /etc/rc.local. mochad is launched by a udev rule that
matches the CM15A and CM19A USB vendor and product ID codes.
== Use it
Connect to mochad using netcat. For example,
nc localhost 1099
You can connect to mochad from another host by specifying the IP of the host
running mochad. netcat is available for Windows at
<http://joncraton.org/blog/netcat-for-windows>.
Everything sent by mochad appears on netcat standard output. In the simplest
use case, mochad/netcat can be used to see X10 PL and RF activity. For example,
run mochad on one host with a CM15A then connect to it using netcat from a
netbook. Walk around with various X10 RF remote controls and the netbook to see
which remotes work from various locations.
Sample output:
12/07 20:49:10 Rx RF HouseUnit: C3 Func: Off
12/07 20:49:10 Tx PL HouseUnit: C3
12/07 20:49:10 Tx PL House: C Func: Off
12/07 20:49:10 Rx RF HouseUnit: C3 Func: Off
12/07 20:49:10 Tx PL HouseUnit: C3
12/07 20:49:10 Tx PL House: C Func: Off
12/07 20:49:17 Rx RFSEC Addr: 0x11 Func: Lights_Off_SH624
12/07 20:49:17 Rx RFSEC Addr: 0x11 Func: Lights_Off_SH624
12/07 20:49:37 Rx RFSEC Addr: C6:1B:00 Func: Motion_alert_MS10A
12/07 20:49:37 Rx RFSEC Addr: C6:1B:00 Func: Motion_alert_MS10A
12/07 20:49:37 Rx RFSEC Addr: C6:1B:00 Func: Motion_alert_MS10A
12/07 20:49:37 Rx RFSEC Addr: C6:1B:00 Func: Motion_alert_MS10A
Everything sent to netcat standard input is sent to mochad. The following is a
brief list of mochad commands.
pl a1 [on|off]
pl a1 [dim|bright] 0..31
pl a1 xdim 0..255
pl a1
pl a2
pl a [on|off|dim|bright|xdim|all_lights_on|all_lights_off|all_units_off]
rf a1 [on|off|dim|bright]
st -- show device status including RF security devices
By default, received RF X10 commands are repeated on the PL interface for all
house codes. This can be changed using the rftopl command (RF to PL repeater).
rftopl * -- enable all house codes (default)
rftopl abc -- enable for house codes A, B, and C. Disable for all others.
rftopl 0 -- disable for all house codes. This is useful if more than
one CM15A is in use. Leaving both enabled will result in
PL collisions and redundant commands.
Please see http://sourceforge.net/apps/mediawiki/mochad/index.php?title=Main_Page
for more details on command and event messages.
If you want to debug X10 RF, or gateway raw frames to another program, you can
use the --raw-data argument.
See apps/mochad.scr for an example on how to gateway frames with misterhouse.
Another use is to simply be able to get all the raw RF frames to see if the
multiple copies received are identical (good), off by a few bits (RF marginal),
or nonsensical (bad).
07/01 23:34:42 Rx RF HouseUnit: A1 Func: Off
07/01 23:34:42 Raw data received: 5D 20 60 9F 20 DF
07/01 23:34:42 Raw data received: 5D 20 60 9F 20 DF
07/01 23:34:43 Raw data received: 5D 20 60 9F 20 DF
07/01 23:34:43 Raw data received: 5D 20 60 9F 20 DF
07/01 23:34:43 Raw data received: 5D 20 60 9F 20 DF
For examples of controlling shutters and blinds, see the following.
https://sourceforge.net/apps/mediawiki/mochad/index.php?title=Shutter_and_Blinds
== Multiple controllers
The Perl program mochamon.pl shows how to monitor more than one instance of
mochad. It is possible to create a master home automation master which talks to
more than one X10 controller. For example, a mocha master could receive RF
commands from controller A then send PL commands on controller B in a detached
building.
== Command line X10 control
Command line control is useful for controlling devices from cron or CGI programs.
$ echo "pl a all_lights_off" | nc localhost 1099
More generally, create a file name x10cmd with the following
echo "$@" | nc localhost 1099
Make the file executable.
$ chmod +x x10cmd
Run x10cmd with command line parameters to control X10 devices.
$ ./x10cmd pl a all_lights_off
== Web Interface
The cgi/ sub-directory holds a simple Perl CGI web application that uses
mochad. The interface is designed for small hand held devices over slow
connections (not broadband) so the web pages are very basic and small.
No GIFs or JPGs are used. To accomodate older devices with limited web browsers,
CSS, Javascript, or AJAX are not used. The web applications has buttons at
the top to send commands to mochad. The remainder shows status information
for three hosts running mochad.
Please see http://sourceforge.net/apps/mediawiki/mochad/index.php?title=Main_Page
for more details.
== Hardware
X10 controllers: CM15A and CM19A
Various X10 devices that have been tested with mochad:
AM486, LM465 softstart, PAM02, RR501 (2 way), DS10A, MS10A, KR10A, SH624,
KR19A
NOTE: CM15A macros and timers are NOT supported. For best results, use AHP
(ActiveHome Pro) to clear interface memory and disable the internal RF to PL
repeater. This ensures the CM15A behaves like a transceiver.
== Files
*.c *.h -- C source files
mochamon.pl -- Perl program showing how to connect to three instance of
mochad and dumping out the output to standard out.
cgi/ -- Sample Perl CGI utilizing more than one mochad
== Acknowledgments
The Perl CGI scripts uses the venerable cgi-lib.pl copyright Steven E. Brenner.
cgi-lib is simpler and smaller than CGI.pm which is appropriate for small
embedded systems such as WiFi routers.
For OpenWrt based systems, using LuCi would make more sense than Perl since
LuCi is already present in the system. However, the Perl CGI scripts work fine
with lighttpd on OpenWrt.
This project in not in any way affliated with X10 Corp. (www.x10.com). Do
not contact them about this driver since they know nothing about it.
== References
The following documents were useful in development of this program.
X10 Power Line Protocol
<http://software.x10.com/pub/manuals/xtc798.doc>
<http://software.x10.com/pub/manuals/xtc798.pdf>
<http://software.x10.com/pub/manuals/xtdcode.pdf>
X10 RF including RF Security Protocol
<http://www.edcheung.com/automa/rf.txt>
X10 CM11A Protocol
<http://software.x10.com/pub/manuals/cm11a_protocol.txt>
Linux Daemon HowTo
<http://www-theorie.physik.unizh.ch/~dpotter/howto/daemonize>