1
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-05-07 22:29:19 +00:00

70_LaMetric2: allow to set either message or icon to null

git-svn-id: https://svn.fhem.de/fhem/trunk@17941 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
jpawlowski 2018-12-09 18:45:44 +00:00
parent e75be366c0
commit ccddc5f936

View File

@ -267,7 +267,7 @@ sub LaMetric2_Define($$) {
$hash->{HOST} = $host; $hash->{HOST} = $host;
$hash->{".API_KEY"} = $apikey; $hash->{".API_KEY"} = $apikey;
$hash->{VERSION} = "2.2.0"; $hash->{VERSION} = "2.2.1";
$hash->{INTERVAL} = $hash->{INTERVAL} =
$interval && looks_like_number($interval) ? $interval : 60; $interval && looks_like_number($interval) ? $interval : 60;
$hash->{PORT} = $port && looks_like_number($port) ? $port : 4343; $hash->{PORT} = $port && looks_like_number($port) ? $port : 4343;
@ -1582,8 +1582,7 @@ sub LaMetric2_SetNotification {
$h->{msg} ? $h->{msg} $h->{msg} ? $h->{msg}
: ( $h->{text} ? $h->{text} : join ' ', @$a ) : ( $h->{text} ? $h->{text} : join ' ', @$a )
); );
$values{message} = "" if ( $values{message} eq "none" );
Debug "2: " . Dumper . @$a;
# chart frame # chart frame
if ( $h->{chart} ) { if ( $h->{chart} ) {
@ -1876,8 +1875,9 @@ sub LaMetric2_SetNotification {
return return
"Usage: $name msg <text> [ option1=<value> option2='<value with space>' ... ]" "Usage: $name msg <text> [ option1=<value> option2='<value with space>' ... ]"
unless ( ( defined( $values{message} ) && $values{message} ne "" ) unless ( $values{title} ne ""
|| $values{title} ne "" || ( defined( $values{message} ) && $values{message} ne "" )
|| ( defined( $values{icon} ) && $values{icon} ne "" )
|| defined( $values{chart} ) || defined( $values{chart} )
|| defined( $values{goal} ) || defined( $values{goal} )
|| defined( $values{metric} ) ); || defined( $values{metric} ) );
@ -1960,29 +1960,45 @@ sub LaMetric2_SetNotification {
readingsBulkUpdate( $hash, "lastNotificationTitle", "" ); readingsBulkUpdate( $hash, "lastNotificationTitle", "" );
} }
if ( defined( $values{message} ) && $values{message} ne "" ) { if ( defined( $values{message} ) ) {
foreach my $line ( split /\\n/, $values{message} ) {
$line = trim($line);
next if ( !$line || $line eq "" );
my $ico = $values{icon};
if ( $notification{model}{frames} ) {
$ico = "" unless ( $h->{forceicon} );
#TODO define icon inline per frame.
# Must be compatible with FHEM-msg command
}
# empty frame
if ( $values{message} eq "" ) {
push @{ $notification{model}{frames} }, push @{ $notification{model}{frames} },
( (
{ {
icon => $ico, icon => $values{icon},
text => $line, text => "",
index => $index++, index => $index++,
} }
); );
} }
# regular frames
else {
foreach my $line ( split /\\n/, $values{message} ) {
$line = trim($line);
next if ( !$line || $line eq "" );
my $ico = $values{icon};
if ( $notification{model}{frames} ) {
$ico = "" unless ( $h->{forceicon} || $line eq "" );
#TODO define icon inline per frame.
# Must be compatible with FHEM-msg command
}
push @{ $notification{model}{frames} },
(
{
icon => $ico,
text => $line,
index => $index++,
}
);
}
}
readingsBulkUpdate( $hash, "lastMessage", $values{message} ); readingsBulkUpdate( $hash, "lastMessage", $values{message} );
} }