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
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.
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.
Mit
$string =~ s/Stra�e/Straße/;
bekomme ich immerhin das Replacement-Zeichen ersetzt.
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.
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.
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
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.
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.
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.
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
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
@Boris: mein Bauchgefühl (und Bauch habe ich viel) sagt mir, Du solltest vielleicht die " in der payload escapen.
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.
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
Zitat./bimmerconnected status -j 'user' 'pass' rest_of_world | xxd liefert \u00df fürs "ß"
Merkwuerdig, mein xxd zeigt nie \u00, sondern sowas:
% echo ß | recode utf-8..latin1 | xxd
00000000: df0a ..
% echo ß | recode utf-8..latin1 | recode latin1..utf-8 | xxd
00000000: c39f 0a ...
ZitatBtw: Anfängerfrage: wie bekomme ich die führende "1_" bei den Readings weg?
Mit jsonMap: https://fhem.de/commandref_modular.html#MQTT2_DEVICE-attr-jsonMap
Zitat von: rudolfkoenig am 01 September 2022, 12:37:09
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.
Das fehlende Anführungszeichen kommt von meiner manuellen Nachbearbeitung der Fahrgestellnummer. Im Original ist da eines.
Dein Beispiel funktioniert aber das komplette JSON aus bimmerconnected nicht. Andererseits liefert
./bmw.sh | mosquitto_pub -h has -i bmw -t bmw -l
komischerweise keine Fehlermeldung. In keinem Fall aber kommt beim MQTT-Broker im FHEM was an. Aber das muss ich erst noch untersuchen.
Achtung bei -l: da wird jede Zeile als eine separate MQTT-Nachricht versendet, und das verursacht fuer FHEM Kopfschmerzen, falls im JSON ein Newline vorkommt.
Zitat von: rudolfkoenig am 01 September 2022, 15:26:24
Achtung bei -l: da wird jede Zeile als eine separate MQTT-Nachricht versendet, und das verursacht fuer FHEM Kopfschmerzen, falls im JSON ein Newline vorkommt.
Danke für den Tipp! Gerade überprüft. Das gelieferte JSON ist ein fetter Einzeiler. Gut.
Zitat von: rudolfkoenig am 01 September 2022, 13:41:43
Merkwuerdig, mein xxd zeigt nie \u00, sondern sowas:
% echo ß | recode utf-8..latin1 | xxd
00000000: df0a ..
% echo ß | recode utf-8..latin1 | recode latin1..utf-8 | xxd
00000000: c39f 0a ...
Im Terminal bekomme ich das auch genau so hin. Das \u00 kommt direkt aus dem bimmerconnected Skript.
ZitatMit jsonMap: https://fhem.de/commandref_modular.html#MQTT2_DEVICE-attr-jsonMap
Das wird bei 233 Readings aber mühselig :o
Hallo,
so, ich hole mit bimmerconnected das JSON, pipe es nach
mosquitto_pub -h has -i bmw -t bmw -l
und sende es damit an den MQTT-Broker im FHEM und werte die Readings am entstandenen Device MQTT2_bmw per readingList
bmw:.* { json2nameValue($EVENT, '', $JSONMAP) }
aus. Im Reading 1_data_state_location_address_formatted
erfreut sich in der ...straße das scharfe S bester Gesundheit.
Ich benutze keine Encodings und meine fhem.cfg ist UTF-8 Unicode text.
Kann ich was zur Lösung des Problems des OP beitragen?
Grüße
Boris
Aaaah! Zwei Auffälligkeiten.
1. In der Raumliste, die im FHEMWEB aufpoppt, wenn ich das Attribut room ändern will, sind alle Umlaute kaputt. Und auch in der Navigationsleiste.
2. Ich habe den BMW ein stateformat 1_data_state_location_address_formatted verpasst. Das ß in ...straße ist in der Detailansicht des Device in Ordnung, in der Raumübersicht allerdings Tofu.
Zitat von: Dr. Boris Neubert am 01 September 2022, 17:17:09
Hallo,
so, ich hole mit bimmerconnected das JSON, pipe es nach
mosquitto_pub -h has -i bmw -t bmw -l
und sende es damit an den MQTT-Broker im FHEM und werte die Readings am entstandenen Device MQTT2_bmw per readingList
bmw:.* { json2nameValue($EVENT, '', $JSONMAP) }
aus. Im Reading 1_data_state_location_address_formatted
erfreut sich in der ...straße das scharfe S bester Gesundheit.
Ich benutze keine Encodings und meine fhem.cfg ist UTF-8 Unicode text.
Kann ich was zur Lösung des Problems des OP beitragen?
Grüße
Boris
Hallo Boris,
ich habs jetzt mal genauso nachgestellt. Bei mir nach wie vor auch in der Detailansicht das Placeholder "?"
1_data_state_location_address_formatted Muster Stra�e 20, 12345 Musterstadt 2022-09-01 17:28:25
fhem.cfg ist laut CotEditor + webmin ebenfalls utf8 codiert.
So, da ist was komisch.
War gerade mit dem BMW einkaufen und habe automatisiert alle 5 Minuten den Status abgefragt,
Nach einem Update der Readings stand auch in der Detailsicht statt des ß nur Tofu. Aktualisiere ich die Seite im Browser, steht da wieder ein ß.
Im Log wird mir im FHEMWEB im Browser auch Tofu angezeigt.
Das Log ist laut file MQTT2_bmw-2022.log wie folgt kodiert: Non-ISO extended-ASCII text
Darin ist ß hex df. Wenn ich den Output von bimmerconected in eine Datei pipe, ist das ß als \u00df JSON-kodiert. Das ist also zumindest konsistent.
Ich vermute, dass der Browser noch etwas mit Magie macht, um die Kodierung zu reparieren, wenn die Seite neu geladen wird. Das sehe ich daran, dass die Umlaute in der Navigationsleiste mit den Räumen genau dann kaputt sind, wenn das ß in der Detailsicht heil ist, und umgekehrt.
recode des Output von bimmerconnected hilft übrigens nicht, weil die Sonderzeichen im Output von bimmerconnected als \uxxxx kodiert sind. Das Problem tritt erst auf, wenn das JSON im MQTT-Broker verwurstet wird. Idealerweise schieben wir dort eine Umkodierung dazwischen.
Kann bitte jemand die Ausgabe von bimmerconnected mir zur Verfuegung stellen?
Zitat von: rudolfkoenig am 01 September 2022, 19:33:30
Kann bitte jemand die Ausgabe von bimmerconnected mir zur Verfuegung stellen?
[{
"data": {
...gaaaaanz viel JSON...
"address": {
"formatted": "Muster Stra\u00dfe 20, 12345 Musterstadt"
},
....noch mehr JSON...
}]
Wie gesagt insgesamt 233 Readings aber nur um das EINE gehts ja hier...
Und wie Boris geschrieben hat als Einzeiler.
Mit "Ausgabe" meinte ich unmodifizierte Daten, die keinen Editor gesehen haben, nicht per Copy&Paste sondern als Anhang, sonst geht das Wesentliche verloren. Ich brauche etwas, mit dem ich testen kann, und wo meine Verfollstaendigung der Daten das Ergebnis nicht verfaelschen.
Mit der "Wie gesagt..." Version sind wir ja nachweislich nicht weitergekommen.
Zitat von: rudolfkoenig am 01 September 2022, 20:54:27
Mit "Ausgabe" meinte ich unmodifizierte Daten, die keinen Editor gesehen haben, nicht per Copy&Paste sondern als Anhang, sonst geht das Wesentliche verloren. Ich brauche etwas, mit dem ich testen kann, und wo meine Verfollstaendigung der Daten das Ergebnis nicht verfaelschen.
Mit der "Wie gesagt..." Version sind wir ja nachweislich nicht weitergekommen.
Ohne Geodaten und VIN (per Editor) zu entfernen hänge ich hier aber nix an.
Maximal auf vertrauensvoller Basis per PN ;)
ZitatOhne Geodaten und VIN (per Editor) zu entfernen hänge ich hier aber nix an.
Das wollte ich auch nicht vorschlagen.
Zitat von: rudolfkoenig am 01 September 2022, 22:31:45
Das wollte ich auch nicht vorschlagen.
Und wie kommen wir nun zusammen? Ich würde dir ja einen Downloadlink schicken - aber PNs sind ja geblockt...
Meine Email Adresse zu finden duerfte nicht zu schwer sein, notfalls siehe Impressum.
@Rudi: hast Du, was Du brauchst? Sonst sende ich Dir meinen Output von bimmerconnected per PM.
Zitat von: Dr. Boris Neubert am 02 September 2022, 09:15:41
@Rudi: hast Du, was Du brauchst? Sonst sende ich Dir meinen Output von bimmerconnected per PM.
Ich hab heute morgen eine Mail verschickt mit einem Link zu meinen Daten.
Sollte also da sein ;)
Noch ein anderer Gedanke:
JSON muss UTF-8-Kodierung benutzen.
bimmerconnected schickt freundlicherweise \u00df für das ß. Das ist der Unicode-Codepoint für ß. Es spielt also keine Rolle, dass die UTF-8-Kodierung des ß zwei Byte umfasst oder wie sie überhaupt aussieht.
Im FHEM-Log steht das Byte 0xdf. Das wäre latin1 IMHO.
Und weiter weiß ich nicht, weil ich nicht weiß, in welcher Kodierung FHEM Zeichenketten standardmäßig verarbeitet und in welcher Kodierung FHEMWEB die Webseiten ausliefert und an welcher Stelle in diesem Zusammenspiel die Inkonsistenz sitzt.
Zitatbimmerconnected schickt freundlicherweise \u00df für das ß. Das ist der Unicode-Codepoint für ß.
Falls man "attr global encoding unicode" setzt (die Voreinstellung ist bytestream, aka UTF-8), dann gibt es auch keine Dastellungsprobleme.
Ich habe json2nameValue in fhem.pl jetzt angepasst, so das auch in der Voreinstellung ß angezeigt wird.
ZitatDas wird bei 233 Readings aber mühselig :o
Mit einem brauchbaren Editor ein paar Sekunden.
Mit etwas extra Muehe kann man sinnlose Readings entfernen, und die anderen besser benennen.
Und wenn man das Ergebnis spendiert, dann kann man das in einem attrTemplate verewigen, so dass auch Andere was davon haben.
Alternativ kann man das 1_ auch mit dem folgenden Einzeiler entfernen:
attr MQTT2_bmw readingList bmw:bmw:.* { my $h1 = json2nameValue($EVENT);; my %h2 = map { my $k=$_;; $k=~s/^1_//;; ($k,$h1->{$_}) } keys %{$h1};; \%h2 }
Zitat von: rudolfkoenig am 02 September 2022, 12:28:03
Falls man "attr global encoding unicode" setzt (die Voreinstellung ist bytestream, aka UTF-8), dann gibt es auch keine Dastellungsprobleme.
Meinem Verständnis nach bezeichnet Unicode, welche Zahl für welches Zeichen steht, also 223 für ß. Es gibt dann unterschiedliche Kodierungen (UTF-8, UTF-16LE, UTF-16BE, UTF-32, UCS-2, ...), wie diese Zahl in einem oder mehreren Bytes auf dem Rechner dargestellt wird. Meinem Verständnis nach genügt es nicht zu sagen, dass ein String Unicode sei. In Windows sind Unicode-Strings standardmäßig UTF-16.
Ich verstehe, dass die Voreinstellung bei FHEM (wohl bei Perl) UTF-8 ist. Welche Kodierung wird verwendet bei
attr global encoding unicode?
Zitat
Ich habe json2nameValue in fhem.pl jetzt angepasst, so das auch in der Voreinstellung ß angezeigt wird.
Danke. Ich lasse morgen das Update durchlaufen und sehe mir das Ergebnis an.
ZitatIch verstehe, dass die Voreinstellung bei FHEM (wohl bei Perl) UTF-8 ist. Welche Kodierung wird verwendet bei attr global encoding unicode?
In der Voreinstellung konvertiert FHEM nichts bei der Ein-/Ausgabe und hofft darauf, dass die ganze Welt fuer Datenaustausch UTF-8 verwendet, was fuer Daten in FHEM-Umfeld zu 98% stimmt. Alles was davon abweicht, muss fuer die interne Speicherung nach UTF-8 konvertiert werden.
Mit "attr global unicode" muessen alle (Framework und Module) darauf achten, dass die Daten bei der Eingabe von UTF-8 in das perl eigene Format (UTF32? habs nicht rausgekriegt) konvertiert werden, und bei der Ausgabe andersherum. Das Problem mit dieser Methode ist, dass alle Module, die Daten mit der Umwelt austauschen, explizit was machen muessen.
Konkret muss man entweder Encode::encode bzw. Encode::decode aufrufen, oder beim Filehandle binmode($fh, ":encoding(UTF-8)") setzen.
ZitatIch habe json2nameValue in fhem.pl jetzt angepasst, so das auch in der Voreinstellung ß angezeigt wird.
Passt! Vielen Dank Rudolf!
ZitatMit etwas extra Muehe kann man sinnlose Readings entfernen, und die anderen besser benennen.
Und wenn man das Ergebnis spendiert, dann kann man das in einem attrTemplate verewigen, so dass auch Andere was davon haben.
Das ist eine ausgezeichnete Idee - wenn ich mal wieder etwas mehr Freizeit habe! :)
VG Sebastian
Bestätige, dass es auch bei mir funktioniert.
Danke, Rudi!
Off-topic: Codespende: https://forum.fhem.de/index.php?topic=129067 (https://forum.fhem.de/index.php?topic=129067)