QUESTION OnAir Light

ddorminey

Member
Joined
Dec 11, 2007
Messages
78
Reaction score
0
Has anyone done anything like an 'OnAir' light and tied it into Asterisk? I'd like to light up an LED if a trunk, extension or list of extensions is off hook (you know, a call is in progress).

Thanks!

---Devin
 

billsimon

Well-Known Member
Joined
Jan 2, 2011
Messages
1,540
Reaction score
729
What are you using to switch the LED?

You could monitor the system using AMI (Manager interface) or the HTTP version of it. You could also trigger the light in the dial plan by issuing a system call when a certain pattern is dialed. Or you could script a "core show channels" at the CLI and run that in cron to decide whether the light should be on.
 

ddorminey

Member
Joined
Dec 11, 2007
Messages
78
Reaction score
0
What are you using to switch the LED?

You could monitor the system using AMI (Manager interface) or the HTTP version of it. You could also trigger the light in the dial plan by issuing a system call when a certain pattern is dialed. Or you could script a "core show channels" at the CLI and run that in cron to decide whether the light should be on.


I was thinking an Arduino or RasPi type of thing.

I found this http://www.cyberdata.net/voip/011087/ , for future reference but its about $350 more than I would be willing to spend.

I've gotten some clues from the post below that lead me to think a quick java program could do what I want and then trigger a pin on the arduino...

If any one has done this or wants to knock one out, let me know. I'll work on it too, as I'm able.

---D
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,633
Reaction score
842
A stub, add your event loop or just poll.

#!/usr/bin/perl
use Asterisk::AMI;
use v5.14;
# set some variables change to suit your /etc/asterisk/manager*.conf settings

my $host = 'yourhost';
my $amiusername = 'youraccount';
my $amipass = 'yourpassword';
my @extens = ();

# check for fluxbulbs
sub fluxctrl
{
system("flux_led.py @_");
}
my $flux = `flux_led.py -s `;
chomp $flux;
my @bulbs = split /\n/, $flux;
my @count = split /\s+/, $bulbs[0];
if ( not $count[0] ) { print "no bulbs found";exit 1};

# check for connectivity
my $astman = Asterisk::AMI->new(PeerAddr => $host ,Username => $amiusername,Secret => $amipass );
die "Unable to connect to asterisk" unless ($astman);
&fluxctrl("-sS -1 --volatile >/dev/null");
&fluxctrl("-sS -c 'black b --volatile '>/dev/null" );

#check for bulb in database and name un-named ones
foreach my $bulb (1..$#bulbs){
(my $null, my $mac, my $ip) = (split /\s+/, @bulbs[$bulb]) ;
&putbulb($mac, 'ip', $ip);
if ( not &getbulb($mac, 'name')){
&fluxctrl("$ip -p 56 100 --volatile ");
say "Please identify the flashing bulb with a name . . . ";
my $getinput = <>;
chomp $getinput;
&putbulb($mac, 'name', $getinput);
&fluxctrl("$ip -c black --volatile");
}
}

# main work here

# subroutines here
sub showbulbs
{
my $showbulbs = $astman->action({Action => 'Command',Command=> 'database show BULBS'});
return $showbulbs->{'CMD'};
}

sub getbulb
{
my @args = @_;
my $getdb = $astman->action({Action => 'DBGet',Family => "BULBS/$args[0]", Key => "$args[1]"});
return $getdb->{'GOOD'};
}

sub putbulb
{
my @args = @_;
my $putdb = $astman->action({Action => 'DBPut',Family => "BULBS/$args[0]", Key => "$args[1]", Val => "$args[2]"});
}

sub getsip
{
my $getsip = $astman->action({ Action => 'Command',Command => 'SIP show peers' });
return $getsip->{'CMD'};
}

sub getiax2
{
my $getiax2 = $astman->action({ Action => 'Command',Command => 'IAX2 show peers' });
return $getiax2->{'CMD'};

}

# Start script

my @Sip = @{&getsip};
pop @Sip;shift @Sip;
foreach my $ext (0..$#sip){
my $exten = (split /\s+|\// , @Sip[$ext])[0];
if ( $exten =~ /^\d+$/){ push @extens, grep(/\d+/, $exten)};
}

my @iax = @{&getiax2};
pop @iax;shift @iax;
foreach my $ext (0..$#iax){
push @extens, (split /\s+/ , @iax[$ext])[0];
}


my @blubs = @{&showbulbs};
pop @blubs;
foreach my $blub (0..$#blubs){
my @data = split /\s+:\s+/, @blubs[$blub];
my ($famkey, $value) = (split /\s+:\s+/, @blubs[$blub])[0, 1];
my @words = split /\//, $famkey;
shift @words;
my $key = pop @words;
my $family = join '/' , @words;;
say "family= $family , key= $key, value= $value";
}

foreach (@extens) {
my $status =$astman->action({Action => 'ExtensionState', Exten => "$_"}, )->{ 'PARSED' }->{ 'Status' };
print "Exten. $_ \tStatus $status\n";
}


# End script
exit 0;
 

Members online

No members online now.

Forum statistics

Threads
25,810
Messages
167,754
Members
19,240
Latest member
nikko
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top