diff --git a/fhem/FHEM/95_PostMe.pm b/fhem/FHEM/95_PostMe.pm index 0e0fed717..aba3b0d84 100644 --- a/fhem/FHEM/95_PostMe.pm +++ b/fhem/FHEM/95_PostMe.pm @@ -43,7 +43,7 @@ use Time::Local; ######################### # Global variables -my $postmeversion = "2.01"; +my $postmeversion = "2.03"; my $FW_encoding = "UTF-8"; ######################################################################################### @@ -65,7 +65,7 @@ sub PostMe_Initialize ($) { $hash->{UndefFn} = "PostMe_Undef"; $hash->{InitFn} = "PostMe_Init"; $hash->{AttrFn} = "PostMe_Attr"; - $hash->{AttrList} = "postmeTTSFun postmeMsgFun postme[0-9]+MsgRec postmeMailFun postme[0-9]+MailRec ". + $hash->{AttrList} = "postmeTTSFun postmeTTSDev postmeMsgFun postme[0-9]+MsgRec postmeMailFun postme[0-9]+MailRec ". "postmeStd postmeIcon postmeStyle:test,jQuery,HTML,SVG postmeClick:0,1 listseparator ".$readingFnAttributes; $hash->{FW_detailFn} = "PostMe_detailFn"; @@ -342,11 +342,20 @@ sub PostMe_Add($$@) { return "$mga"; } my $raw = join(' ',@args); + #-- remove meta data my $item = $raw; $item =~ s/\[.*\]//g; $item =~ s/\]//g; $item =~ s/\[//g; + + #-- safety catch: No action when item empty + if( $item eq "" ){ + my $mga = "Error, empty item given"; + Log 1,"[PostMe_Add] $mga"; + return "$mga"; + } + #-- check old content my $old = ReadingsVal($devname, sprintf("postme%02dCont",$pmn),""); my $ind = index($old,$item); @@ -390,6 +399,13 @@ sub PostMe_Remove($$@) { my $item = $raw; $item =~ s/\[.*\]//g; + #-- safety catch: No action when item empty + if( $item eq "" ){ + my $mga = "Error, empty item given"; + Log 1,"[PostMe_Remove] $mga"; + return "$mga"; + } + #-- get old content my $new = ""; my $old = ReadingsVal($devname, sprintf("postme%02dCont",$pmn),""); @@ -499,6 +515,13 @@ sub PostMe_Modify($$@) { splice(@args,0,2); my $val = join(' ',@args); + #-- safety catch: No action when item empty + if( $item eq "" ){ + my $mga = "Error, empty item given"; + Log 1,"[PostMe_Modify] $mga"; + return "$mga"; + } + #-- check old content my $old = ReadingsVal($devname, sprintf("postme%02dCont",$pmn),""); my $ind = index($old,$item); @@ -1121,12 +1144,13 @@ sub PostMe_Get($$$@) { ##-- speak as TTS }elsif( $key eq "TTS" ){ + my $dev = AttrVal($devname,"postmeTTSDev",undef); my $text = $listname.": ".PostMe_LineOut($hash,$listname,ReadingsVal($devname, sprintf("postme%02dCont",$pmn),undef),10); my $fun = AttrVal($devname,"postmeTTSFun",undef); if( $text && $fun ){ my $ref = \&$fun; - &$ref($text); + &$ref($dev,$text); } my $mga = "$listname spoken by TTS"; readingsSingleUpdate($hash,"state",$mga,1 ); @@ -1593,7 +1617,7 @@ sub PostMe_widget($) {
attr <postit> postmeClick 1|0 (default)
attr <postit> postmeicon <string>
+ attr <postit> postmeIcon <string>
attr <postit> postmeStyle SVG|HTML|jQuery (default)
attr <postit> postmeMailRec(01|02|...) <string>
+ recipient addresses for the above eMail function (per PostMe).attr <postit> postmeMsgFun <string>
attr <postit> postmeMsgRec(01|02|...) <string>
+ recipient addresses for the above instant messenger function (per PostMe).attr <postit> postmeTTSFun <string>
attr <postit> postmeTTSDev(01|02|...) <string>
+ device name for the above TTS function.