Button to send command, best if able to support "grafana server" sending - Asking for hints

Hi all I’m gently asking for hints for this use case:
I need to send command to sensors/actuators from some dashboards.
The devices support mqtt (they are tasmota based and not exposed on internet).

Currently I’m using the “canvas button” sending an http/post to a script that will convert it in the mqtt publish needed. It’s quite ok, but it has some drawbacks:

  • The canvas needs a query to be showed (i’ve designed a light query but it costs computational effort anyway)
  • The button needs a full url that will be embedded in every dashboard (maintenance effort in the time)

The configuration:

So I’m gently asking:

  • Is there some other (cleaner) way to implement the button ? (I’ve already tested the old button plugin but I was not able to configure the url/payload)
  • Is there a way to set at higher level (organization or system) some data such as the command url and then use them in the dashboard in order to have a single copy of the data to be maintained ?

Last: this way use this communication path:
browser (grafana) → http/post → server script (not grafana server) → mqtt publish

that have the drawback that you have to open the service script to be callable from pages (grafana dashboard) that comes from other domain: you have to “allow-origin” weakening the security.

Is there a solution that can be embedded in grafana, that means implement the path:
browser (grafana) → http/post → grafana (embedded server script) → mqtt publish

Any hints are welcome
Thanks a lot

how about using business text plugin and import the following type of library, add a button and ypur js script to do what you need

const mqtt = require("mqtt");
const client = mqtt.connect("mqtt://test.mosquitto.org");

client.on("connect", () => {
  client.subscribe("presence", (err) => {
    if (!err) {
      client.publish("presence", "Hello mqtt");
    }
  });
});

client.on("message", (topic, message) => {
  // message is Buffer
  console.log(message.toString());
  client.end();
});

It will be a solution implementing the simplified path:
browser (grafana) → mqtt publish

spreading in every dashboard mqtt connection information and assuming that it is exposed on internet.

I take note of the hint (thanks) but if is possibile i prefer to go deep in analyzing the solution with path like:
browser (grafana) → http/post → grafana (embedded server script) → mqtt publish

Thanks again

so which path do you exactly want again? straight browser to mqqt if at possible sounds like a huge security hole esp when exposed to the internet, you might be looking for a new job

the second approach should be possible with my previous post, read the docu

I’m sorry but I’m not able to figure out how to implement the path (i avoid tools just node):
browser → grafana → mqtt (just like a influxdb datasource with influx access server supported)

Can you kindly post few more info ?
Thanks

check the docu out

Have you considered using Grafana’s built-in HTTP API with webhooks to simplify the process? It might reduce the maintenance effort and grinchcostume eliminate the need for queries just to display the button.