mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
FRITZFON: ringtone
git-svn-id: https://svn.fhem.de/fhem/trunk@7028 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
a7e2740c65
commit
c31a6bccdf
@ -54,23 +54,23 @@ my %fonModel = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
my %ringTone = (
|
my %ringTone = (
|
||||||
0 => "Handset default"
|
0 => "HandsetDefault"
|
||||||
, 1 => "Handset Internal Ton"
|
, 1 => "HandsetInternalTon"
|
||||||
, 2 => "Handset External Ton"
|
, 2 => "HandsetExternalTon"
|
||||||
, 3 => "Standard"
|
, 3 => "Standard"
|
||||||
, 4 => "Eighties"
|
, 4 => "Eighties"
|
||||||
, 5 => "Alarm"
|
, 5 => "Alarm"
|
||||||
, 6 => "Ring"
|
, 6 => "Ring"
|
||||||
, 7 => "Ring Ring"
|
, 7 => "RingRing"
|
||||||
, 8 => "News"
|
, 8 => "News"
|
||||||
, 9 => "Personal Ring Ton"
|
, 9 => "CustomerRingTon"
|
||||||
, 10 => "Bamboo"
|
, 10 => "Bamboo"
|
||||||
, 11 => "Andante"
|
, 11 => "Andante"
|
||||||
, 12 => "Cha Cha"
|
, 12 => "ChaCha"
|
||||||
, 13 => "Budapest"
|
, 13 => "Budapest"
|
||||||
, 14 => "Asia"
|
, 14 => "Asia"
|
||||||
, 15 => "Kullabaloo"
|
, 15 => "Kullabaloo"
|
||||||
, 16 => "lautlos"
|
, 16 => "silent"
|
||||||
, 17 => "Comedy"
|
, 17 => "Comedy"
|
||||||
, 18 => "Funky",
|
, 18 => "Funky",
|
||||||
, 19 => "Fatboy"
|
, 19 => "Fatboy"
|
||||||
@ -83,10 +83,17 @@ my %ringTone = (
|
|||||||
, 26 => "Musicbox"
|
, 26 => "Musicbox"
|
||||||
, 27 => "Blok2"
|
, 27 => "Blok2"
|
||||||
, 28 => "2Jazz"
|
, 28 => "2Jazz"
|
||||||
, 33 => "Internet Radio"
|
, 33 => "InternetRadio"
|
||||||
, 34 => "Music List"
|
, 34 => "MusicList"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
my %ringToneNumber;
|
||||||
|
while (my ($key, $value) = each %ringTone) {
|
||||||
|
$ringToneNumber{lc $value}=$key;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
my @radio=();
|
||||||
|
|
||||||
sub ##########################################
|
sub ##########################################
|
||||||
FRITZFON_Log($$$)
|
FRITZFON_Log($$$)
|
||||||
@ -187,7 +194,7 @@ FRITZFON_Set($$@)
|
|||||||
{
|
{
|
||||||
if (int @val > 0)
|
if (int @val > 0)
|
||||||
{
|
{
|
||||||
FRITZFON_Ring $hash, @val; # join("|", @val);
|
FRITZFON_Ring $hash, @val;
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -219,10 +226,22 @@ FRITZFON_Set($$@)
|
|||||||
return "Missing parameters after command 'set $name $cmd'";
|
return "Missing parameters after command 'set $name $cmd'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
elsif ( lc $cmd eq 'convertringtone')
|
||||||
|
{
|
||||||
|
if (int @val > 0)
|
||||||
|
{
|
||||||
|
return FRITZFON_ConvertRingTone $hash, @val;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "Missing parameters after command 'set $name $cmd'";
|
||||||
|
}
|
||||||
|
}
|
||||||
my $list = "reinit:noArg"
|
my $list = "reinit:noArg"
|
||||||
|
. " convertRingTone"
|
||||||
. " message"
|
. " message"
|
||||||
. " ring"
|
. " ring"
|
||||||
. " startradio";
|
. " startRadio";
|
||||||
return "Unknown argument $cmd, choose one of $list";
|
return "Unknown argument $cmd, choose one of $list";
|
||||||
|
|
||||||
} # end FRITZFON_Set
|
} # end FRITZFON_Set
|
||||||
@ -231,13 +250,19 @@ FRITZFON_Set($$@)
|
|||||||
sub ##########################################
|
sub ##########################################
|
||||||
FRITZFON_Get($@)
|
FRITZFON_Get($@)
|
||||||
{
|
{
|
||||||
my ($hash, $name, $cmd) = @_;
|
my ($hash, $name, $cmd) = @_;
|
||||||
my $result;
|
my $returnStr;
|
||||||
my $message;
|
|
||||||
|
|
||||||
my $list = "";
|
|
||||||
return "Unknown argument $cmd, choose one of $list";
|
|
||||||
|
|
||||||
|
if (lc $cmd eq "ringtones")
|
||||||
|
{
|
||||||
|
$returnStr = "Ring tones to use with 'set <name> ring <intern> <duration> <ringTone>'\n";
|
||||||
|
$returnStr .= "----------------------------------------------------------------------\n";
|
||||||
|
$returnStr .= join "\n", sort values %ringTone;
|
||||||
|
return $returnStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
my $list = "ringTones:noArg";
|
||||||
|
return "Unknown argument $cmd, choose one of $list";
|
||||||
} # end FRITZFON_Get
|
} # end FRITZFON_Get
|
||||||
|
|
||||||
|
|
||||||
@ -251,6 +276,24 @@ FRITZFON_Init($)
|
|||||||
|
|
||||||
readingsBeginUpdate($hash);
|
readingsBeginUpdate($hash);
|
||||||
|
|
||||||
|
# Box Firmware
|
||||||
|
FRITZFON_Init_Reading($hash
|
||||||
|
, "box_fwVersion"
|
||||||
|
, "ctlmgr_ctl r logic status/nspver"
|
||||||
|
, "fwupdate");
|
||||||
|
|
||||||
|
# Internetradioliste erzeugen
|
||||||
|
my $i = 0;
|
||||||
|
@radio = ();
|
||||||
|
while ()
|
||||||
|
{
|
||||||
|
last unless $result = FRITZFON_Init_Reading($hash,
|
||||||
|
sprintf ("radio%02d",$i),
|
||||||
|
"ctlmgr_ctl r configd settings/WEBRADIO".$i."/Name");
|
||||||
|
push @radio, $result;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (1..6)
|
foreach (1..6)
|
||||||
{
|
{
|
||||||
# Dect-Telefonname
|
# Dect-Telefonname
|
||||||
@ -262,9 +305,9 @@ FRITZFON_Init($)
|
|||||||
"dect".$_."_intern",
|
"dect".$_."_intern",
|
||||||
"ctlmgr_ctl r telcfg settings/Foncontrol/User".$_."/Intern");
|
"ctlmgr_ctl r telcfg settings/Foncontrol/User".$_."/Intern");
|
||||||
# Dect-Internal Ring Tone
|
# Dect-Internal Ring Tone
|
||||||
FRITZFON_Init_Reading($hash,
|
# FRITZFON_Init_Reading($hash,
|
||||||
"dect".$_."_intRingTone",
|
# "dect".$_."_intRingTone",
|
||||||
"ctlmgr_ctl r telcfg settings/Foncontrol/User".$_."/IntRingTone");
|
# "ctlmgr_ctl r telcfg settings/Foncontrol/User".$_."/IntRingTone");
|
||||||
# Handset manufacturer
|
# Handset manufacturer
|
||||||
my $brand = FRITZFON_Init_Reading($hash,
|
my $brand = FRITZFON_Init_Reading($hash,
|
||||||
"dect".$_."_manufacturer",
|
"dect".$_."_manufacturer",
|
||||||
@ -273,17 +316,31 @@ FRITZFON_Init($)
|
|||||||
{
|
{
|
||||||
# Ring Tone Name
|
# Ring Tone Name
|
||||||
FRITZFON_Init_Reading($hash
|
FRITZFON_Init_Reading($hash
|
||||||
, "dect".$_."_intRingToneName"
|
, "dect".$_."_intRingTone"
|
||||||
, "ctlmgr_ctl r telcfg settings/Foncontrol/User".$_."/IntRingTone"
|
, "ctlmgr_ctl r telcfg settings/Foncontrol/User".$_."/IntRingTone"
|
||||||
, "ringtone");
|
, "ringtone");
|
||||||
|
# Radio Name
|
||||||
|
FRITZFON_Init_Reading($hash
|
||||||
|
, "dect".$_."_radio"
|
||||||
|
, "ctlmgr_ctl r telcfg settings/Foncontrol/User".$_."/RadioRingID"
|
||||||
|
, "radio");
|
||||||
# Background image
|
# Background image
|
||||||
FRITZFON_Init_Reading($hash,
|
FRITZFON_Init_Reading($hash
|
||||||
"dect".$_."_imagePath ",
|
, "dect".$_."_imagePath "
|
||||||
"ctlmgr_ctl r telcfg settings/Foncontrol/User".$_."/ImagePath ");
|
, "ctlmgr_ctl r telcfg settings/Foncontrol/User".$_."/ImagePath ");
|
||||||
|
# Customer Ring Tone
|
||||||
|
FRITZFON_Init_Reading($hash
|
||||||
|
, "dect".$_."_custRingTone"
|
||||||
|
, "ctlmgr_ctl r telcfg settings/Foncontrol/User".$_."/G722RingTone");
|
||||||
|
# Customer Ring Tone Name
|
||||||
|
FRITZFON_Init_Reading($hash
|
||||||
|
, "dect".$_."_custRingToneName"
|
||||||
|
, "ctlmgr_ctl r telcfg settings/Foncontrol/User".$_."/G722RingToneName");
|
||||||
# Firmware Version
|
# Firmware Version
|
||||||
FRITZFON_Init_Reading($hash,
|
FRITZFON_Init_Reading($hash
|
||||||
"dect".$_."_fwVersion",
|
, "dect".$_."_fwVersion"
|
||||||
"ctlmgr_ctl r dect settings/Handset".($_-1)."/FWVersion");
|
, "ctlmgr_ctl r dect settings/Handset".($_-1)."/FWVersion");
|
||||||
|
|
||||||
# Phone Model
|
# Phone Model
|
||||||
FRITZFON_Init_Reading($hash
|
FRITZFON_Init_Reading($hash
|
||||||
, "dect".$_."_model"
|
, "dect".$_."_model"
|
||||||
@ -313,7 +370,6 @@ FRITZFON_Init_Reading($$$@)
|
|||||||
$replace = ""
|
$replace = ""
|
||||||
unless defined $replace;
|
unless defined $replace;
|
||||||
my $result = FRITZFON_Exec( $hash, $cmd);
|
my $result = FRITZFON_Exec( $hash, $cmd);
|
||||||
chomp ($result);
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
if ($replace eq "model")
|
if ($replace eq "model")
|
||||||
{
|
{
|
||||||
@ -324,6 +380,17 @@ FRITZFON_Init_Reading($$$@)
|
|||||||
{
|
{
|
||||||
$result = $ringTone{$result};
|
$result = $ringTone{$result};
|
||||||
}
|
}
|
||||||
|
elsif ($replace eq "radio")
|
||||||
|
{
|
||||||
|
$result = $radio[$result];
|
||||||
|
}
|
||||||
|
elsif ($replace eq "fwupdate")
|
||||||
|
{
|
||||||
|
my $update = FRITZFON_Exec( $hash, "ctlmgr_ctl r updatecheck status/update_available_hint");
|
||||||
|
$result .= " (old)"
|
||||||
|
if $update == 1;
|
||||||
|
}
|
||||||
|
|
||||||
readingsBulkUpdate($hash, $rName, $result)
|
readingsBulkUpdate($hash, $rName, $result)
|
||||||
if $result;
|
if $result;
|
||||||
} elsif (defined $hash->{READINGS}{$rName} ) {
|
} elsif (defined $hash->{READINGS}{$rName} ) {
|
||||||
@ -377,7 +444,15 @@ FRITZFON_Ring_Run($$)
|
|||||||
|
|
||||||
$duration = 5
|
$duration = 5
|
||||||
unless defined $duration;
|
unless defined $duration;
|
||||||
|
|
||||||
|
if (defined $ringTone)
|
||||||
|
{
|
||||||
|
my $temp = $ringTone;
|
||||||
|
$ringTone = $ringToneNumber{lc $ringTone};
|
||||||
|
return $name."|0|Error: Ring tone '$temp' not valid"
|
||||||
|
unless defined $ringTone;
|
||||||
|
}
|
||||||
|
|
||||||
my $msg = $hash->{Message};
|
my $msg = $hash->{Message};
|
||||||
$msg = "FHEM"
|
$msg = "FHEM"
|
||||||
unless defined $msg;
|
unless defined $msg;
|
||||||
@ -450,12 +525,35 @@ FRITZFON_Ring_Aborted($$)
|
|||||||
FRITZFON_Log $hash, 1, "Timeout when ringing";
|
FRITZFON_Log $hash, 1, "Timeout when ringing";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub ############################################
|
||||||
|
FRITZFON_ConvertRingTone ($@)
|
||||||
|
{
|
||||||
|
my ($hash, @val) = @_;
|
||||||
|
my $inFile = join " ", @val;
|
||||||
|
my $returnStr;
|
||||||
|
my $outFile = $inFile;
|
||||||
|
$outFile = substr($inFile,0,-4)
|
||||||
|
if (lc substr($inFile,-4) =~ /\.(mp3|wav)/);
|
||||||
|
$returnStr = FRITZFON_Exec ($hash,
|
||||||
|
"ffmpegconv -i '$inFile' -o '$outFile.g722' --limit 240 --type 1");
|
||||||
|
return $returnStr;
|
||||||
|
#pbd --set-image-url --book=255 --id=612 --url=/var/InternerSpeicher/FRITZ/fonring/1416431162.g722 --type=1
|
||||||
|
#pbd --set-image-url --book=255 --id=612 --url=file://var/InternerSpeicher/fritzfontest.g722 --type=1
|
||||||
|
#ctlmgr_ctl r user settings/user0/bpjm_filter_enable
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Executed the command on the FritzBox Shell
|
# Executed the command on the FritzBox Shell
|
||||||
sub ############################################
|
sub ############################################
|
||||||
FRITZFON_Exec($$)
|
FRITZFON_Exec($$)
|
||||||
{
|
{
|
||||||
my ($hash, $cmd) = @_;
|
my ($hash, $cmd) = @_;
|
||||||
return qx($cmd);
|
FRITZFON_Log $hash, 5, "Execute '".$cmd."'";
|
||||||
|
my $result = qx($cmd);
|
||||||
|
chomp ($result);
|
||||||
|
FRITZFON_Log $hash, 5, "Result '".$result."'";
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
@ -469,9 +567,9 @@ FRITZFON_Exec($$)
|
|||||||
<h3>FRITZFON</h3>
|
<h3>FRITZFON</h3>
|
||||||
<div style="width:800px">
|
<div style="width:800px">
|
||||||
<ul>
|
<ul>
|
||||||
The module allows Fritz!Box owners to use a phone as a signaling device. It supports also some special features of the Fritz!Fons, e.g. MT-F.
|
The module implements the Fritz!Fon's (MT-F, MT-D, C3, C4) as a signaling device.
|
||||||
<br>
|
<br>
|
||||||
It has to run in an FHEM process <b>on</b> the box.
|
It has to run in an FHEM process <b>on</b> a Fritz!Box.
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
<a name="FRITZFONdefine"></a>
|
<a name="FRITZFONdefine"></a>
|
||||||
<b>Define</b>
|
<b>Define</b>
|
||||||
@ -501,7 +599,7 @@ FRITZFON_Exec($$)
|
|||||||
</li><br>
|
</li><br>
|
||||||
<li><code>set <name> ring <internalNumber> [duration] [ringTone]</code>
|
<li><code>set <name> ring <internalNumber> [duration] [ringTone]</code>
|
||||||
<br>
|
<br>
|
||||||
Rings the internal number for duration (seconds) and (if possible) with the given ring tone.
|
Rings the internal number for duration (seconds) and (if possible) with the given ring tone name.
|
||||||
<br>
|
<br>
|
||||||
</li><br>
|
</li><br>
|
||||||
<li><code>set <name> startradio <internalNumber> [name]</code>
|
<li><code>set <name> startradio <internalNumber> [name]</code>
|
||||||
@ -514,7 +612,10 @@ FRITZFON_Exec($$)
|
|||||||
<a name="FRITZFONget"></a>
|
<a name="FRITZFONget"></a>
|
||||||
<b>Get</b>
|
<b>Get</b>
|
||||||
<ul>
|
<ul>
|
||||||
not implemented yet
|
<li><code>get <name> ringTones</code>
|
||||||
|
<br>
|
||||||
|
Shows a list of ring tones that can be used.
|
||||||
|
</li><br>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<a name="FRITZFONattr"></a>
|
<a name="FRITZFONattr"></a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user