diff --git a/fhem/CHANGED b/fhem/CHANGED
index b9ed962cb..68e01496e 100644
--- a/fhem/CHANGED
+++ b/fhem/CHANGED
@@ -1,5 +1,7 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
+ - feature: FB_CALLLIST: new attribute icon-mapping for customizing the icons for all
+ call states. For details see commandref
- bugfix: 73_km200: Removal of Static polling and new sounding after attribute change
- bugfix: Dashboard: text alignment issue for ios7 style.
- bugfix: Dashboard: fixed some perl warnings.
diff --git a/fhem/FHEM/72_FB_CALLLIST.pm b/fhem/FHEM/72_FB_CALLLIST.pm
index 9247d74e4..dbdfd0537 100755
--- a/fhem/FHEM/72_FB_CALLLIST.pm
+++ b/fhem/FHEM/72_FB_CALLLIST.pm
@@ -44,6 +44,7 @@ FB_CALLLIST_Initialize($)
$hash->{AttrFn} = "FB_CALLLIST_Attr";
$hash->{AttrList} = "number-of-calls:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 ".
"internal-number-filter ".
+ "icon-mapping ".
"connection-mapping ".
"external-mapping ".
"create-readings:0,1 ".
@@ -150,11 +151,11 @@ sub FB_CALLLIST_Attr($@)
}
elsif($attrib eq "connection-mapping")
{
- if( $value =~ m/^{.*}$/ )
+ if($value and $value =~ m/^{.*}$/ )
{
my $table = eval $value;
- if( $table &&(ref($table) eq 'HASH'))
+ if($table and ref($table) eq 'HASH')
{
$hash->{helper}{CONNECTION_MAP} = $table;
Log3 $name, 4, "FB_CALLLIST ($name) - connection map stored as hash: $value";
@@ -172,13 +173,40 @@ sub FB_CALLLIST_Attr($@)
return "invalid connection mapping table: $value";
}
}
+ elsif($attrib eq "icon-mapping")
+ {
+ if($value and $value =~ m/^{.*}$/ )
+ {
+ $value =~ s/@/\\\@/g;
+ $value =~ s/\$/\\\$/g;
+ $value =~ s/%/\\\%/g;
+ my $table = eval $value;
+
+ if($table and ref($table) eq 'HASH')
+ {
+ $hash->{helper}{ICON_MAP} = $table;
+ Log3 $name, 4, "FB_CALLLIST ($name) - icon map stored as hash: $value";
+
+ # Inform all FHEMWEB clients
+ FB_CALLLIST_updateFhemWebClients($hash) if($init_done);
+ }
+ else
+ {
+ return "invalid icon mapping table: $value";
+ }
+ }
+ else
+ {
+ return "invalid icon mapping table: $value";
+ }
+ }
elsif($attrib eq "external-mapping")
{
- if( $value =~ m/^{.*}$/ )
+ if($value and $value =~ m/^{.*}$/ )
{
my $table = eval $value;
- if( $table &&(ref($table) eq 'HASH'))
+ if($table and ref($table) eq 'HASH')
{
$hash->{helper}{EXTERNAL_MAP} = $table;
Log3 $name, 4, "FB_CALLLIST ($name) - external map stored as hash: $value";
@@ -198,7 +226,7 @@ sub FB_CALLLIST_Attr($@)
}
elsif($attrib eq "list-type")
{
- if($value =~ /^incoming|outgoing|missed-call|completed|active$/)
+ if($value and $value =~ /^incoming|outgoing|missed-call|completed|active$/)
{
$attr{$name}{$attrib} = $value;
@@ -225,6 +253,11 @@ sub FB_CALLLIST_Attr($@)
delete($hash->{helper}{CONNECTION_MAP}) if(exists($hash->{helper}{CONNECTION_MAP}));
return undef;
}
+ elsif($attrib eq "icon-mapping")
+ {
+ delete($hash->{helper}{ICON_MAP}) if(exists($hash->{helper}{ICON_MAP}));
+ return undef;
+ }
elsif($attrib eq "external-mapping")
{
delete($hash->{helper}{EXTERNAL_MAP}) if(exists($hash->{helper}{EXTERNAL_MAP}));
@@ -443,6 +476,42 @@ sub FB_CALLLIST_cleanupList($)
}
}
+#####################################
+# returns the icon depending on icon mapping
+sub FB_CALLLIST_returnIcon($$$)
+{
+ my ($hash, $icon, $text) = @_;
+
+ my $icon_name;
+
+ my $standard = {
+
+ "incoming.connected" => "phone_ring_in\@blue",
+ "outgoing.connected" => "phone_ring_out\@green",
+
+ "incoming.ring" => "phone_ring\@blue",
+ "outgoing.ring" => "phone_ring\@green",
+
+ "incoming.missed" => "phone_missed_in\@red",
+ "outgoing.missed" => "phone_missed_out\@green",
+
+ "incoming.done" => "phone_call_end_in\@blue",
+ "outgoing.done" => "phone_call_end_out\@green",
+
+ "incoming.tam" => "phone_answering\@blue"
+ };
+
+ $icon_name = $standard->{$icon} if(exists($standard->{$icon}));
+ $icon_name = $hash->{helper}{ICON_MAP}{$icon} if(exists($hash->{helper}{ICON_MAP}{$icon}));
+
+ my $result = FW_makeImage($icon_name);
+
+
+ return $result if($result ne $icon_name);
+ return $text;
+}
+
+
#####################################
# returns the call state of a specific call as icon or text
sub FB_CALLLIST_returnCallState($$;$)
@@ -461,43 +530,42 @@ sub FB_CALLLIST_returnCallState($$;$)
if($data->{direction} eq "incoming" and $data->{last_event} eq "connect" )
{
$state = "=> [=]";
- $state = FW_makeImage("phone_ring_in\@blue",$state) if($icons);
+ $state = FB_CALLLIST_returnIcon($hash,"incoming.connected", $state) if($icons);
}
elsif($data->{direction} eq "incoming" and $data->{last_event} eq "ring")
{
$state = "=> ((o))";
- $state = FW_makeImage("phone_ring\@blue",$state) if($icons);
+ $state = FB_CALLLIST_returnIcon($hash,"incoming.ring", $state) if($icons);
}
elsif($data->{direction} eq "outgoing" and $data->{last_event} eq "connect" )
{
$state = "<= [=]";
- $state = FW_makeImage("phone_ring_out\@green",$state) if($icons);
+ $state = FB_CALLLIST_returnIcon($hash,"outgoing.connected", $state) if($icons);
}
elsif($data->{direction} eq "outgoing" and $data->{last_event} eq "call")
{
$state = "<= ((o))";
- $state = FW_makeImage("phone_ring\@green",$state) if($icons);
+ $state = FB_CALLLIST_returnIcon($hash,"outgoing.ring", $state) if($icons);
}
}
else
{
- if($data->{direction} eq "incoming")
+ if($data->{direction} eq "incoming" and ((not exists($data->{internal_connection}) ) or (exists($data->{internal_connection}) and not $data->{internal_connection} =~ /Answering_Machine/)))
{
$state = "=>".($data->{missed_call} ? " X" : "");
- $state = FW_makeImage("phone_missed_in\@red",$state) if($icons and $data->{missed_call});
- $state = FW_makeImage("phone_call_end_in\@blue",$state) if($icons and !$data->{missed_call});
-
- if(exists($data->{internal_connection}) and $data->{internal_connection} =~ /Answering_Machine/)
- {
- $state = "=> O_O";
- $state = FW_makeImage("phone_answersing\@blue",$state) if($icons);;
- }
+ $state = FB_CALLLIST_returnIcon($hash, "incoming.done", $state) if($icons and not $data->{missed_call});
+ $state = FB_CALLLIST_returnIcon($hash, "incoming.missed", $state) if($icons and $data->{missed_call});
+ }
+ elsif($data->{direction} eq "incoming" and exists($data->{internal_connection}) and $data->{internal_connection} =~ /Answering_Machine/)
+ {
+ $state = "=> O_O";
+ $state = FB_CALLLIST_returnIcon($hash,"incoming.tam", $state) if($icons);
}
elsif($data->{direction} eq "outgoing")
{
$state = "<=".($data->{missed_call} ? " X" : "");
- $state = FW_makeImage("phone_missed_out\@green",$state) if($icons and $data->{missed_call});
- $state = FW_makeImage("phone_call_end_out\@green",$state) if($icons and !$data->{missed_call});
+ $state = FB_CALLLIST_returnIcon($hash, "outgoing.done", $state) if($icons and not $data->{missed_call});
+ $state = FB_CALLLIST_returnIcon($hash, "outgoing.missed", $state) if($icons and $data->{missed_call});
}
}
@@ -960,7 +1028,7 @@ sub FB_CALLLIST_returnTableHeader($)
It logs all calls and displays them in a historic table.
You need a defined FB_CALLMONITOR instance where you can attach FB_CALLLIST to process the call events.
- Depending on your configuration the status will be shown as icons or as text. You need to have the fhemSVG icon set configured in your corresponding FHEMWEB instance (see FHEMWEB attribute iconPath).
+ Depending on your configuration the status will be shown as icons or as text. You need to have the openautomation icon set configured in your corresponding FHEMWEB instance (see FHEMWEB attribute iconPath).
The icons have different colors.
<= ((o)) | - outgoing call (ringing) |
=> ((o)) | - incoming call (ringing) |
<= [=] | - outgoing call (currently active) |
=> [=] | - incoming call (currently active) |
<= X | - outgoing unsuccessful call (nobody picked up) |
=> X | - incoming unsuccessful call (missed call) |
=> O_O | - incoming finished call recorded on answering machine |
<= | - outgoing finished call |
=> | - incoming finished call |
<= ((o)) | - outgoing call (ringing) - icon: outgoing.ring |
=> ((o)) | - incoming call (ringing) - icon: incoming.ring |
<= [=] | - outgoing call (currently active) - icon: outgoing.connected |
=> [=] | - incoming call (currently active) - icon: incoming.connected |
<= X | - outgoing unsuccessful call (nobody picked up) - icon: outgoing.missed |
=> X | - incoming unsuccessful call (missed call) - icon: incoming.missed |
=> O_O | - incoming finished call recorded on answering machine - icon: incoming.tam |
<= | - outgoing finished call - icon: outgoing.done |
=> | - incoming finished call - icon: incoming.done |
attr <name> external-mapping {'ISDN' => 'Fixed Network', 'SIP0' => 'Operator A', 'SIP1' => 'Operator B'}
attr <name> icon-mapping {'incoming.connected' => 'phone_ring_in@yellow', 'outgoing.missed' => 'phone_missed_out@red'}
+ .*
zu stellen um die hohe Anzahl an Events in bestimmten Fällen zu minimieren.attr <name> icon-mapping {'incoming.connected' => 'phone_ring_in@yellow', 'outgoing.missed' => 'phone_missed_out@red'}
+