Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MQTT Plugin] How to get the topic? #47

Open
mlazze opened this issue Jul 11, 2023 · 1 comment
Open

[MQTT Plugin] How to get the topic? #47

mlazze opened this issue Jul 11, 2023 · 1 comment

Comments

@mlazze
Copy link

mlazze commented Jul 11, 2023

Hello,

i have setup an Action which triggers by "MQTT Action-Trigger" and causes "MQTT Action-Type Store Data" to fire.

I'm using a debugging payload parser, to check what's being sent and the available globals:

console.log(payload);
console.log(this);

payload = [];

Here's what's being logged:

[22:10:34] Log from payload parser: 237.1
[22:10:34] Log from payload parser: {
    "payload": 237.1,
    "raw_payload": 237.1,
    "device": {
        "id": "6159fee2eeb93a8c0fa57097",
        "tags": [],
        "params": []
    },
    "console": {}
}

So, in "payload" i'm only getting the value, with no reference to the mqtt_topic.

I'm also using the cloud tago.io service, with a similar setup i always get metadata.mqtt_topic in the payload, but in tagocore mqtt plugin i only get the value.
I could add different devices for each topic, but there should be a better way.

@mlazze
Copy link
Author

mlazze commented Jul 12, 2023

The problem is in mqtt plugin, replacing

n&&(n.metadata=ae(se({},n.metadata),{mqtt_topic:r.topic}))

with

(n="object"==typeof n?n:{variable:"payload",value:n})&&(n.metadata=ae(se({},n.metadata),{mqtt_topic:r.topic}))

in /var/lib/tagocore/data/plugins/7c713c7aace7bda2583a1cb19e873d02/build/index.js solves the problem.
7c713c7aace7bda2583a1cb19e873d02 is the mqtt plugin id for my installation, please check it's the same for you when applying this.

Do you know if there's a repository for the mqtt plugin i can add a pr to?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant