From fcf9bb0ad080ca5a48663c367b19244a9bdbc84d Mon Sep 17 00:00:00 2001 From: phenning <> Date: Sat, 28 Jan 2017 00:38:14 +0000 Subject: [PATCH] =?UTF-8?q?95=5FPostMe.pm:=20Neue=20Version=20f=C3=A4ngt?= =?UTF-8?q?=20leeren=20item=20ab?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.fhem.de/fhem/trunk@13255 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/95_PostMe.pm | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) 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)
    If 0, embedded sticky notes will pop up on mouseover-events and vanish on mouseout-events (default).
    If 1, embedded sticky notes will pop up on click events and vanish after closing the note
  • -
  • attr <postit> postmeicon <string> +
  • attr <postit> postmeIcon <string>
    Icon for display of a sticky note
  • attr <postit> postmeStyle SVG|HTML|jQuery (default)
    If jQuery, embedded sticky notes will produce jQuery code (default)
    @@ -1609,14 +1633,20 @@ sub PostMe_widget($) {
    Function name for the eMail function. This subroutine is called with three parameters for recipient, subject and text.
  • +
  • attr <postit> postmeMailRec(01|02|...) <string> + recipient addresses for the above eMail function (per PostMe).
  • attr <postit> postmeMsgFun <string>
    Function name for the instant messenger function. This subroutine is called with three parameters for recipient, subject and text.
  • +
  • attr <postit> postmeMsgRec(01|02|...) <string> + recipient addresses for the above instant messenger function (per PostMe).
  • attr <postit> postmeTTSFun <string>
    Function name for the text-to-speech function. This subroutine - is called with only one parameter, the composite text. + is called with two parameters, the device name and the composite text.
  • +
  • attr <postit> postmeTTSDev(01|02|...) <string> + device name for the above TTS function.
  • Standard attributes alias, comment, event-on-update-reading, event-on-change-reading,