From 761b22e9a6c9efa37e6a674fa6d3b56ef4af0e51 Mon Sep 17 00:00:00 2001 From: Beta-User <> Date: Sat, 21 May 2022 15:33:44 +0000 Subject: [PATCH] 10_RHASSPY: add replaceDecimalPoint function for text inputs git-svn-id: https://svn.fhem.de/fhem/trunk@26077 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/RHASSPY/10_RHASSPY.pm | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/fhem/contrib/RHASSPY/10_RHASSPY.pm b/fhem/contrib/RHASSPY/10_RHASSPY.pm index 22e9851df..f71b103ac 100644 --- a/fhem/contrib/RHASSPY/10_RHASSPY.pm +++ b/fhem/contrib/RHASSPY/10_RHASSPY.pm @@ -3030,6 +3030,7 @@ sub testmode_next { if ( $hash->{testline} < @{$hash->{helper}->{test}->{content}} ) { my @ca_strings = split m{,}x, ReadingsVal($hash->{NAME},'intents',''); + $line = _replaceDecimalPoint($hash,$line); my $sendData = { input => $line, sessionId => "$hash->{siteId}_$hash->{testline}_testmode", @@ -3240,6 +3241,7 @@ sub msgDialog_progress { #Log3($hash, 5, 'msgDialog_progress called without DATA') if !defined $data; return if !defined $data; + $msgtext = _replaceDecimalPoint($hash,$msgtext); my $sendData = { input => $msgtext, @@ -3389,7 +3391,7 @@ sub SpeechDialog_progress { Log3($hash, 5, 'SpeechDialog_progress called without DATA') if !defined $data; return if !defined $data; - + $msgtext = _replaceDecimalPoint($hash,$msgtext); my $sendData = { input => $msgtext, sessionId => $data->{sessionId}, @@ -3720,6 +3722,8 @@ sub sendTextCommand { my $hash = shift // return; my $text = shift // return; + $text = _replaceDecimalPoint($hash,$text); + my $data = { input => $text, sessionId => "$hash->{fhemId}.textCommand" #, @@ -5993,6 +5997,20 @@ sub _array2andString { 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; __END__