- Joined
- Dec 3, 2007
- Messages
- 8,069
- Reaction score
- 12
Hi all.
I made a small code to switch on/off some lamps from Elastix / Asterisk.
I use ab USB stick to manage several devices. It's a radio frequency transmitter that plugs into your computer.
I use also some X10 modules like TM13, LM12, and AM12.
The X10 protocol is based on CPL.
At first, download the driver and software HERE.
Followed the instructions.
Be careful to file permissions /dev/ttyUSB0!!
Use this agi script and past it into /var/lib/asterisk/agi-bin/domotic.php
Do that :
# chmod 755 /var/lib/asterisk/agi-bin/domotic.php
# chmod 666 /var/state/telldus-core.conf
Declare every devices with a d in front like this:
Use /etc/tellstick.conf
Insert this part into extensions_custom.conf.
Create a custom destination with this: Domotic,2.,1
Next, create some misc applications with its device code (211, 212, 213, ...etc.) with the destination Domotic.
Next, create some blf:
When you would dial 212, the device d212 will switched on, and dial again to switched off.
Enjoy.
Regards
I made a small code to switch on/off some lamps from Elastix / Asterisk.
I use ab USB stick to manage several devices. It's a radio frequency transmitter that plugs into your computer.
I use also some X10 modules like TM13, LM12, and AM12.
The X10 protocol is based on CPL.
At first, download the driver and software HERE.
Followed the instructions.
Be careful to file permissions /dev/ttyUSB0!!
Use this agi script and past it into /var/lib/asterisk/agi-bin/domotic.php
Code:
#!/usr/bin/php -q
<?php
$cmd="/usr/local/bin/tdtool --list | grep ".$argv[1];
$status_device = exec($cmd);
echo "NoOP $status_device\n";
if (preg_match("/\bOFF\b/i",$status_device)){
$cmd="/usr/local/bin/tdtool -n d".$argv[1];
echo "SET VARIABLE DEVICE_STATE(Custom:$argv[1]) INUSE\n";
}
else
{
$cmd="/usr/local/bin/tdtool -f d".$argv[1];
echo "SET VARIABLE DEVICE_STATE(Custom:$argv[1]) NOT_INUSE\n";
}
exec($cmd);
exit;
?>
Do that :
# chmod 755 /var/lib/asterisk/agi-bin/domotic.php
# chmod 666 /var/state/telldus-core.conf
Declare every devices with a d in front like this:
Code:
# tdtool --list
Number of devices: 4
1 d211 OFF
2 d212 OFF
3 d213 OFF
4 d214 OFF
Use /etc/tellstick.conf
Code:
deviceNode = "/dev/ttyUSB0"
device {
id = 1
name = "d211"
protocol = "sartano"
model = "extel"
parameters {
code = "0000001000"
}
}
device {
id = 2
name = "d212"
protocol = "sartano"
model = "extel"
parameters {
code = "0000010000"
}
}
device {
id = 3
name = "d213"
protocol = "x10"
model = "codeswitch"
controller = 1
parameters {
house = "A"
unit = "1"
}
}
...Etc.
Insert this part into extensions_custom.conf.
Code:
[Domotic]
exten => 2.,1,Answer()
exten => 2.,n,NoOp(Domotic)
exten => 2.,n,Set(Device=${CALLERID(DNID)})
exten => 2.,n,AGI(domotic.php,${Device})
exten => 2.,n,Hangup()
Create a custom destination with this: Domotic,2.,1
Next, create some misc applications with its device code (211, 212, 213, ...etc.) with the destination Domotic.
Next, create some blf:
Code:
exten => 211,hint,Custom:211
exten => 212,hint,Custom:212
exten => 213,hint,Custom:213
exten => 214,hint,Custom:214
When you would dial 212, the device d212 will switched on, and dial again to switched off.
Enjoy.
Regards