2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00

98_Text2Speech: writing stats for checking outdated files fixed

Attr TTS_noStatisticsLog now working properly


git-svn-id: https://svn.fhem.de/fhem/trunk@13351 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Tobias.Faust 2017-02-07 09:46:11 +00:00
parent 6392e40ccb
commit 2afcc7f5f1
2 changed files with 13 additions and 6 deletions

View File

@ -1,5 +1,7 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # 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. # Do not insert empty lines here, update check depends on it.
- bugfix: 98_Text2Speech: writing stats for checking outdated files fixed
Attr TTS_noStatisticsLog now working properly
- bugfix: 74_XiaomiFlowerSens: 0.6.4 rewrite Errorhandling - bugfix: 74_XiaomiFlowerSens: 0.6.4 rewrite Errorhandling
- bugfix: 70_BRAVIA: utf-8 character handling - bugfix: 70_BRAVIA: utf-8 character handling
use WOL only if device is absent (exception 2013 model) use WOL only if device is absent (exception 2013 model)

View File

@ -805,7 +805,6 @@ sub Text2Speech_DoIt($) {
if(-e $file) { if(-e $file) {
push(@Mp3WrapFiles, $file); push(@Mp3WrapFiles, $file);
push(@Mp3WrapText, $t); push(@Mp3WrapText, $t);
#Text2Speech_WriteStats($hash, 0, $file, $t);
} else {last;} } else {last;}
} }
@ -830,7 +829,6 @@ sub Text2Speech_DoIt($) {
Log3 $hash->{NAME}, 4, "Text2Speech:" .$cmd; Log3 $hash->{NAME}, 4, "Text2Speech:" .$cmd;
system($cmd); system($cmd);
#Text2Speech_WriteStats($hash, 1, $Mp3WrapFile, join(" ", @Mp3WrapText));
} else { } else {
Log3 $hash->{NAME}, 2, "Text2Speech: Mp3Wrap Datei konnte nicht angelegt werden."; Log3 $hash->{NAME}, 2, "Text2Speech: Mp3Wrap Datei konnte nicht angelegt werden.";
} }
@ -900,7 +898,7 @@ sub Text2Speech_Done($) {
for(my $i=0; $i<$tts_done; $i++) { for(my $i=0; $i<$tts_done; $i++) {
push(@text, $hash->{helper}{Text2Speech}[$i]); push(@text, $hash->{helper}{Text2Speech}[$i]);
} }
Text2Speech_WriteStats($hash, 1, $filename, join(" ", @text)) if (AttrVal($hash->{NAME},"TTS_noStatisticsLog", "1")); Text2Speech_WriteStats($hash, 1, $filename, join(" ", @text)) if (AttrVal($hash->{NAME},"TTS_noStatisticsLog", "0")==0);
} }
delete($hash->{helper}{RUNNING_PID}); delete($hash->{helper}{RUNNING_PID});
@ -947,13 +945,20 @@ sub Text2Speech_WriteStats($$$$){
} }
return undef if($defs{$DbLogDev}{STATE} !~ m/(active|connected)/); # muss active sein! return undef if($defs{$DbLogDev}{STATE} !~ m/(active|connected)/); # muss active sein!
my $logdevice = $hash->{NAME} ."|". $file;
# den letzten Value von "Usage" ermitteln um dann die Statistik um 1 zu erhoehen. # den letzten Value von "Usage" ermitteln um dann die Statistik um 1 zu erhoehen.
my @LastValue = DbLog_Get($defs{$DbLogDev}, "", "current", "array", "-", "-", $hash->{NAME} ."|". $file.":Usage"); my @LastValue = DbLog_Get($defs{$DbLogDev}, "", "current", "array", "-", "-", $logdevice.":Usage");
my $NewValue = 1; my $NewValue = 1;
$NewValue = $LastValue[0]{value} + 1 if($LastValue[0]); $NewValue = $LastValue[0]{value} + 1 if($LastValue[0]);
# DbLogHash, DbLogTable, TIMESTAMP, DEVICE, TYPE, EVENT, READING, VALUE, UNIT my $cmd;
DbLog_Push($defs{$DbLogDev}, "Current", TimeNow(), $hash->{NAME} ."|". $file, $hash->{TYPE}, $text, "Usage", $NewValue, ""); if ($NewValue == 1) {
$cmd = "INSERT INTO current (TIMESTAMP, DEVICE, TYPE, EVENT, READING, VALUE, UNIT) VALUES (\
'".TimeNow()."','".$logdevice."','".$hash->{TYPE}."','".$text."','Usage','".$NewValue."','')";
} else {
$cmd = "UPDATE current SET VALUE = '".$NewValue."', TIMESTAMP = '".TimeNow()."' WHERE DEVICE ='".$logdevice."'";
}
DbLog_ExecSQL($defs{$DbLogDev}, $cmd);
} }
1; 1;