MQTT Trigger should have an option to avoid listening to retained messages

It would help if there was a node for:

Listening to MQTT topics without retained messages

My use case:

I should listen to a topic continuously but something send continuously a retained message. I just edited the trigger to have a custom trigger which avoid retained message. There should be a boolean option in the MQTT Trigger to choose whether it should listen all messages or avoid retained.

Any resources to support this?

Actually, there’s a retained prop in every message from MQTT. So i just verified the retained prop and return if there’s one.

Are you willing to work on this?

Here’s my edited code :

        const manualTriggerFunction = async () => {
            await new Promise((resolve, reject) => {
                client.on('connect', () => {
                    client.subscribe(topicsQoS, (err, _granted) => {
                        if (err) {
                            reject(err);
                        }
                        client.on('message', (topic, message, packet) => {
                            // Ignore retained messages
                            if (packet.retain) {
                                return;
                            }

                            let result = {};
                            message = message.toString();

                            if (options.jsonParseBody) {
                                try {
                                    message = JSON.parse(message);
                                } catch (error) { }
                            }

                            result.message = message;
                            result.topic = topic;

                            if (options.onlyMessage) {
                                result = [message];
                            }

                            this.emit([this.helpers.returnJsonArray(result)]);
                            resolve(true);
                        });
                    });
                });

                client.on('error', (error) => {
                    reject(error);
                });
            });
        };