mschlenstedt / Loxberry

Current stable Branch is: *** Please see Releases *** Current developer Branch is: *** master ***
Apache License 2.0
76 stars 27 forks source link

'True' wird falsch interpretiert #1406

Closed christianTF closed 1 year ago

christianTF commented 1 year ago
09:34:56.079 <OK> MQTT IN: WP/test: true
09:34:56.080   Expanding json message
09:34:56.080 <ERROR> Error on JSON expansion: Inappropriate ioctl for device
09:34:56.080 All data filtered - skipping further processing of this message

https://github.com/mschlenstedt/Loxberry/blob/b4f222e0a6b3535ffbdb6bbc9d2c4b644e10d8ff/sbin/mqttgateway.pl#L428

Problem ist: Das eingehende, blanke true wird als valides JSON erkannt (erst seit ca. 1-2 Jahren, als Perl den Parser dem Standard entsprechend erweitert hat) und das Gateway behandelt das Json dann als Objekt- bzw. Property-Liste, und der Flat-Code schlägt damit auf.

Es muss deswegen an der Code-Stelle in einem Elseif noch ein if is_enabled || if_disabled hinein (evt. geht auch eine Prüfung auf einen Hash oder dgl.), und nur wenn das nicht zutrifft, darf der flatten-Code starten.

chudini93 commented 1 year ago

Is there any potential date that issue might be resolved? So basically passing any flat data from topic with values true/false is not possible.

Most data is passed this way. So this is a big big issue for anyone who is using MQTT doesnt it?

Even passing data from simple healthchecks is not possible: image

Proposed solution: Line 458: if there is exception and its exactly: Error on JSON expansion: Inappropriate ioctl for device we could just simply put everything in topic without any json conversion as such: $sendhash{$topic} = $message; - it's good eenough I believe and it should work. In the worst case someone's message will be put into the topic without splitting that, it's a lot better than throwing exception and not doing anything really.

christianTF commented 1 year ago

I‘m currently on holiday and will address this as soon as I am at home.