[gelöst] expandJSON: Unicode-Zeichen für ß (\u00df) nicht korrekt verarbeitet

Begonnen von binford6000, 27 August 2022, 12:11:25

Vorheriges Thema - Nächstes Thema

binford6000

Hallo,
ich verwende ein Skript um mir die Daten meines Fahrzeugs (BMW) abzurufen:
./bimmerconnected status -j 'user' 'pass' rest_of_world

Die JSON-Daten enthalten auch eine formatierte Adresse:
"address": {"formatted": "Muster Stra\u00dfe 18B, 12345 Musterstadt"}

Über ein Shellskript pumpe ich die Daten in FHEM (dummy -> expandJSON). Dort erscheint dieses dann so:
data_state_location_address_formatted Muster Stra�e 18B, 12345 Musterstadt

Bei dem Versuch mit notify & Co. ein Vorkommen von /Stra.*e/ in "Straße" zu ändern bekomme ich folgenden Fehler:
2022.08.27 11:32:41 1: PERL WARNING: Use of uninitialized value in pattern match (m//) at (eval 354343) line 1.
2022.08.27 11:32:41 3: eval: {  if (ReadingsVal('bmw.d','data_state_location_address_formatted ',undef) =~ /.*Stra.e.*/) {  fhem("...");  } }


Es scheint so als ob das Unicode-Zeichen für ß (\u00df) nicht korrekt verarbeitet wird.
Über Tipps die diesen kleinen Schönheitsfehler ausbügeln könnten würde ich mich freuen!  8)

VG Sebastian

DetlefR

Nur eine Vermutung
if (ReadingsVal('bmw.d','data_state_location_address_formatted ',undef)
zu
if (ReadingsVal('bmw.d','data_state_location_address_formatted',undef)

Probier mal.

binford6000

Zitat von: DetlefR am 27 August 2022, 12:42:49
Nur eine Vermutung
if (ReadingsVal('bmw.d','data_state_location_address_formatted ',undef)
zu
if (ReadingsVal('bmw.d','data_state_location_address_formatted',undef)

Probier mal.

Jo das Leerzeichen hat sich irgendwie reingeschlichen... Danke!

Aber das eigentliche Problem ist ja nach wie vor vorhanden.
Werde jetzt erstmal schauen wie ich mit RegEx zu Rande komme.

binford6000

Mit

$string =~ s/Stra�e/Straße/;

bekomme ich immerhin das Replacement-Zeichen ersetzt.

DetlefR

Das "löst" aber nur das Problem mit Strasse. Jeder andere Umlaut bringt sicher wieder neue Probleme.
Kannst du nicht auf Shellebene dafür sorgen, dass dort richtig dekodiert wird.

rudolfkoenig

Ich wuerde ausprobieren, ob mit "attr global encoding unicode" das Problem sich loesen laesst.
Achtung: es kann unerwuenschte Nebeneffekte haben, da mW nicht alle Module darauf vorbereitet sind.

binford6000

Zitat von: DetlefR am 27 August 2022, 17:15:08
Das "löst" aber nur das Problem mit Strasse. Jeder andere Umlaut bringt sicher wieder neue Probleme.
Kannst du nicht auf Shellebene dafür sorgen, dass dort richtig dekodiert wird.

Das habe ich (erstmal nur für "ß" zum Test)probiert:
find="\u00df"
replace="ß"
result=${json//$find/$replace}


Dann kommt von expandJSON im Log:
expandJSON bmw.json: Bad JSON: bmw.d json:
Und den \ vor dem ß bekomme ich über die Shell nicht weg.
Stra\ße

ZitatIch wuerde ausprobieren, ob mit "attr global encoding unicode" das Problem sich loesen laesst.
Achtung: es kann unerwuenschte Nebeneffekte haben, da mW nicht alle Module darauf vorbereitet sind.

encode -> unicode war nicht gesetzt. Mit unicode bleibt FHEM beim Neustart mit massig Warnungen hängen:
2022.08.28 07:38:13 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:38:13 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:38:22 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:38:28 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:38:28 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:38:36 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:38:42 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:38:42 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:38:51 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:38:57 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:38:57 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:39:05 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:39:12 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:39:12 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:39:20 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:39:26 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:39:26 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:39:35 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:39:41 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:39:41 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:39:49 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:39:55 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:39:55 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:40:03 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:40:09 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:40:09 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:40:18 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:40:24 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:40:24 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:40:32 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:40:38 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:40:38 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:40:46 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:40:52 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:40:52 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:41:01 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:41:07 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:41:07 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:41:16 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:41:22 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:41:22 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:41:30 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:41:37 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:41:37 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:41:45 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:41:51 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:41:51 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:41:59 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:42:05 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:42:05 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:42:14 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:42:20 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:42:20 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:42:29 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:42:35 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:42:35 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:42:43 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:42:49 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:42:49 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:42:58 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:43:06 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:43:06 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:43:15 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:43:21 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:43:21 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:43:29 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:43:35 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:43:35 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:43:44 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:43:50 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:43:50 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:43:58 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:44:04 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:44:04 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:44:12 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:44:18 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:44:18 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:44:27 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:44:33 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:44:33 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:44:42 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:44:47 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:44:47 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:44:56 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:45:02 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:45:02 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:45:11 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:45:16 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:45:16 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:45:25 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:45:31 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:45:31 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:45:39 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:45:46 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:45:46 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:45:54 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:46:00 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:46:00 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:46:10 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:46:16 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:46:16 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:46:25 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:46:31 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:46:31 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:46:39 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:46:45 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:46:45 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:46:54 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:47:00 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:47:00 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:47:08 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:47:14 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:47:14 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:47:22 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:47:29 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:47:29 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:47:37 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:47:43 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:47:43 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:47:51 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:47:57 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:47:57 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:48:06 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:48:12 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:48:12 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:48:20 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:48:27 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:48:27 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:48:35 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:48:41 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:48:41 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:48:50 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:48:56 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:48:56 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:49:05 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:49:11 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:49:11 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:49:19 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:49:25 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:49:25 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:49:33 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:49:40 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:49:40 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:49:48 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:49:54 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:49:54 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:50:02 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:50:09 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:50:09 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:50:17 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:50:23 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:50:23 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:50:31 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:50:37 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:50:37 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:50:46 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:50:52 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:50:52 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.
2022.08.28 07:51:01 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 1405, <$fh> line 1641.
2022.08.28 07:51:07 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17430.
2022.08.28 07:51:07 1: PERL WARNING: UTF-8 "\xDF" does not map to Unicode at fhem.pl line 5721, <$FH> line 17494.


Vielen Dank erstmal für eure Tipps!
VG Sebastian

rudolfkoenig

Zitatencode -> unicode war nicht gesetzt. Mit unicode bleibt FHEM beim Neustart mit massig Warnungen hängen:
Haengen bleiben tut FHEM nicht, nur bestimmte define/attr/etc Anweisungen werden korrupt.
Es klingt so, als ob eine Datei (fhem.cfg?) viele ß mit latin1 encoding enthaelt.

Meine Hypothese: ein Modul hat Daten aus einer latin1 Quelle genommen, ohne sie nach UTF-8 zu konvertieren. Bei der Anzeige nimmt der Browser UTF-8 an, deswegen die Sonderzeichen. Mit "save" hat FHEM latin1 in fhem.cfg gespeichert, deswegen die Fehlermeldungen bei "attr global encoding unicode". Ohne dieses Attribut wird zwar auch UTF-8 angenommen, aber nicht geprueft.

Ich wuerde erst das Encoding der Datei aendern (z.Bsp. mit einem Editor oder "recode latin1..utf-8 /opt/fhem/fhem.cfg").
Danach dem Modul beibringen, dass latin1 nach utf-8 zu wandeln ist. Das kann(!) mit "attr global encoding unicode" automatisch passieren, wahrscheinlich ist es aber nicht.

binford6000

ZitatHaengen bleiben tut FHEM nicht, nur bestimmte define/attr/etc Anweisungen werden korrupt.
Nein, aber FHEM steckt in einer endlos-Neustart-Schleife...

ZitatEs klingt so, als ob eine Datei (fhem.cfg?) viele ß mit latin1 encoding enthaelt.
Korrekt, da sind einige "ß" drin.

ZitatIch wuerde erst das Encoding der Datei aendern (z.Bsp. mit einem Editor oder "recode latin1..utf-8 /opt/fhem/fhem.cfg").
Prüfung mit webmin-Editor und Download-> cotEditor: Beide melden fhem.cfg sei Unicode/UTF-8 codiert.

rudolfkoenig

ZitatPrüfung mit webmin-Editor und Download-> cotEditor: Beide melden fhem.cfg sei Unicode/UTF-8 codiert.
Die Zeilanabgabe bei der o.g Fehlermeldung mit "encoding unicode" zeigt, dass das Problem beim Einlesen einer Datei festgestellt wurde.
Der Inhalt der Fehlermeldung besagt, dass FHEM \xDF (das ist ß in der latin-1 Codierung) gelesen hat.
Nachdem ich den ersten Beitrag erneut gelesen habe, vermute ich dass log/fhem.save ß in der latin1 Codierung enthaelt.

Mir ist noch unklar,  ob das Problem in bimmerconnected oder bei "Schellskript pumpen" erzeugt wird.
Testen wuerde ich das mit
./bimmerconnected status -j 'user' 'pass' rest_of_world | xxd

Falls xxd fuers ß c39f anzeigt, dann ist bimmerconnected fein raus, bei df muss man den Output nachbehandeln, am einfachsten mit
./bimmerconnected status -j 'user' 'pass' rest_of_world | recode latin1..utf-8


Ich wuerde statt dummy einen MQTT2_SERVER definieren, und die Daten per
mosquitto_pub -i bmw -t bmw -m `./bimmerconnected status -j 'user' 'pass' rest_of_world`

nach FHEM schicken (je nach Ergebnis oben mit zusaetzlichen recode).
Dabei wird ohne weitere Benutzeraktion ein MQTT2_DEVICE angelegt, JSON erkannt und ausgepackt.

potash

Hallo,

ich hatte ein ähnliches Problem bei der Prostionsabfrage über bimmerconnected und hatte das über ein userReading im MQTT2_DEVICE gelöst.
position {encode_utf8(ReadingsVal($name,"1_status_properties_vehicleLocation_address_formatted",""))}
Die Abfrage selbst und Weiterleitung erfolgt über einen Shell-Script.
bimmerconnected status --json $USER $PASS rest_of_world|mosquitto_pub -h $MQTTHOST -p $MQTTPORT -d -t $MQTTTOPIC -l --quiet


Noch einen schönen Abend, Heiko
Raspberry Pi 3, FHEM-Server 5.7

Dr. Boris Neubert

Zitat von: rudolfkoenig am 28 August 2022, 11:24:06
Ich wuerde statt dummy einen MQTT2_SERVER definieren, und die Daten per
mosquitto_pub -i bmw -t bmw -m `./bimmerconnected status -j 'user' 'pass' rest_of_world`

nach FHEM schicken (je nach Ergebnis oben mit zusaetzlichen recode).
Dabei wird ohne weitere Benutzeraktion ein MQTT2_DEVICE angelegt, JSON erkannt und ausgepackt.

Ich schalte mich mal aktiv zu. Ich habe bimmerconnected am laufen und den Befehl in ein Shell-Script bmw.sh verpackt.

mosquitto_pub -i bmw -t bmw -m `./bmw.sh`

steigt leider mit einem Fehler aus:

Error: Unknown option '{"vin":'.

Kann Mosquitto's Command Line Publisher nicht mit strukturierten Daten umgehen? Der Anfang vom  JSON sieht so aus:

[{"data": {"vin": "redactedVIN, "mappingInfo": {"isAssociated": true, ...

Viele Grüße
Boris
Globaler Moderator, Developer, aktives Mitglied des FHEM e.V. (Marketing, Verwaltung)
Bitte keine unaufgeforderten privaten Nachrichten!

betateilchen

@Boris: mein Bauchgefühl (und Bauch habe ich viel) sagt mir, Du solltest vielleicht die " in der payload escapen.
-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

rudolfkoenig

Nach einem kurzen Test wuerde ich das Problem nicht auf mosquitto_pub schieben.
Folgendes laeuft bei mir ohne Fehler durch, und legt passende Readings an.
mosquitto_pub -i bmw -t bmw -m '[{"data": {"vin": "redactedVIN", "mappingInfo": {"isAssociated": true} } }]'


In deinem Beispiel wird redactedVIN nur an einer Seite von " begleitet.
mosquitto_pub hat damit auch kein Problem, nur json2nameValue.

binford6000

Hallo und sorry für die späte Rückmeldung...

Zitat./bimmerconnected status -j 'user' 'pass' rest_of_world | xxd

liefert \u00df fürs "ß"

Zitat./bimmerconnected status -j 'user' 'pass' rest_of_world | recode latin1..utf-8

liefert ebenfalls \u00df fürs "ß"

Im mqtt device stehts jetzt wieder so drin:

1_data_state_location_address_formatted Muster Stra�e 20, 12345 Musterstadt

Btw: Anfängerfrage: wie bekomme ich die führende "1_" bei den Readings weg?
VG Sebastian