-
Notifications
You must be signed in to change notification settings - Fork 784
Unable to use JSON structured mqtt message payload in the lwt property of MQTTService #5197
Comments
AFAIK also the topic is allowed to contain What about this one:
|
Thank you for the response @maggu2810 ! Having a look in the MqttWillAndTestament I see that this Sorry my ignorace if I don't understand something properly but at the moment it is impossible for me to use the |
But there is also a constructor that could be used: public MqttWillAndTestament(String topic, byte[] payload, int qos, boolean retain) I have just a very short look at the code, but IMHO it should be possible to change the "addBrokerConnection" method in the MqttService class to implement the above logic. |
Yes, valid point @maggu2810 ! As I described in #5162 I tried to use this constructor at first but then it requires some connection handling and my thoughts are in the direction of using already implemented logic of ESH with configuring the MqttService and then getting the broker connection where I need it since it is working as required for almost everything I am doing till now. Just to clear out, I opened this issue to concern only the lwt property parsing mechanism and propose a change to extend its use cases. |
I am fine with a change similar to the above described one. At least if it is backward compatible and allows to use all allowed characters for topic and message. |
* MQTT transport: use a broker connection config class * MQTT transport: improve "MQTT will and testament" class * MQTT transport: add support to configure lwt parts Fixes: #5197 Signed-off-by: Markus Rathgeb <maggu2810@gmail.com>
As Last Will Testament is configured with the
lwt
property of the MqttService it has a specific formatting that uses which doesn't allow JSON structured messages since the separation between parametters is done using:
. I see it as a valid use case to use JSON structure in my LWT message but the property is split by:
which makes it impossible. Does it make sense to change the:
to something else or it is against some ESH guidelines that I don't know yet?example usage of lwt property:
org.eclipse.smarthome.mqtt:mosquitto.lwt=mqttTopic:mqttMessagePayload:QoS:retainFlag
wanted usage of lwt property:
org.eclipse.smarthome.mqtt:mosquitto.lwt=mqtt/clients/client1:{"clientID":"client1","status":"online"}:2:1
It takes "client1" as Quality Of Service and throws Exception because it is not a number at all.
Any thoughts on this one?
The text was updated successfully, but these errors were encountered: