randomsync / robotframework-mqttlibrary

MQTT Keyword Library for Robot Framework
Apache License 2.0
25 stars 30 forks source link

Cannot access the topic of a received message #4

Closed brummieb closed 4 years ago

brummieb commented 7 years ago

I've just started using robotframework-mqttlibrary, and I can set up a subscription as per the documentation, then successfully receive messages. If I subscribe to wildcards, e.g...

${message}= Subscribe topic=test/mqtt_test/+ qos=1 timeout=2

...I can successfully receive messages published to test/mqtt_test/apples, test/mqtt_test/oranges, test/mqtt_test/pears etc.

However, ${message} appears to only contain the content of the message payload, and I've been unable to work out if it's possible to determine the exact topic of the received message (e.g. was it test/mqtt_test/apples or test/mqtt_test/pears).

Is there any way to do this with robotframework-mqttlibrary?

brummieb commented 7 years ago

Note: I've added a potential solution here: https://stackoverflow.com/questions/44681586/with-mqttlibrary-for-robot-framework-is-it-possible-to-determine-the-exact-topi

It would break existing Robot Framework scripts, as Subscribe would now return a list of lists, but it works for my application.

randomsync commented 4 years ago

Yes, this is a breaking change, and honestly I'm not keen on adding this in near future. Hopefully the above solution works for you. If not, feel free to suggest a better solution and/or create a PR.