2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-07 12:58:13 +00:00

10_RHASSPY: add replaceDecimalPoint function for text inputs

git-svn-id: https://svn.fhem.de/fhem/trunk@26077 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
Beta-User 2022-05-21 15:33:44 +00:00
parent ce43c4a073
commit 761b22e9a6

View File

@ -3030,6 +3030,7 @@ sub testmode_next {
if ( $hash->{testline} < @{$hash->{helper}->{test}->{content}} ) { if ( $hash->{testline} < @{$hash->{helper}->{test}->{content}} ) {
my @ca_strings = split m{,}x, ReadingsVal($hash->{NAME},'intents',''); my @ca_strings = split m{,}x, ReadingsVal($hash->{NAME},'intents','');
$line = _replaceDecimalPoint($hash,$line);
my $sendData = { my $sendData = {
input => $line, input => $line,
sessionId => "$hash->{siteId}_$hash->{testline}_testmode", sessionId => "$hash->{siteId}_$hash->{testline}_testmode",
@ -3240,6 +3241,7 @@ sub msgDialog_progress {
#Log3($hash, 5, 'msgDialog_progress called without DATA') if !defined $data; #Log3($hash, 5, 'msgDialog_progress called without DATA') if !defined $data;
return if !defined $data; return if !defined $data;
$msgtext = _replaceDecimalPoint($hash,$msgtext);
my $sendData = { my $sendData = {
input => $msgtext, input => $msgtext,
@ -3389,7 +3391,7 @@ sub SpeechDialog_progress {
Log3($hash, 5, 'SpeechDialog_progress called without DATA') if !defined $data; Log3($hash, 5, 'SpeechDialog_progress called without DATA') if !defined $data;
return if !defined $data; return if !defined $data;
$msgtext = _replaceDecimalPoint($hash,$msgtext);
my $sendData = { my $sendData = {
input => $msgtext, input => $msgtext,
sessionId => $data->{sessionId}, sessionId => $data->{sessionId},
@ -3720,6 +3722,8 @@ sub sendTextCommand {
my $hash = shift // return; my $hash = shift // return;
my $text = shift // return; my $text = shift // return;
$text = _replaceDecimalPoint($hash,$text);
my $data = { my $data = {
input => $text, input => $text,
sessionId => "$hash->{fhemId}.textCommand" #, sessionId => "$hash->{fhemId}.textCommand" #,
@ -5993,6 +5997,20 @@ sub _array2andString {
return $text; return $text;
} }
sub _replaceDecimalPoint {
my $hash = shift // return;
my $line = shift // return;
my $point = 'point';
if ( $hash->{helper}{lng}->{commaconversion} ) {
$point = $hash->{helper}{lng}{words}->{comma} // 'komma';
$line =~ s{(\d+)[,](\d+)}{$1 $point $2};
} else {
$point = $hash->{helper}{lng}{words}->{point} // $point;
$line =~ s{(\d+)[.](\d+)}{$1 $point $2};
}
return $line;
}
1; 1;
__END__ __END__