Using mqtt.to() in Tasks

Yes, putting the import on the first line fixed the issue.

If I may use this thread for the next issue. When I execute the query from Data Explorer, it returns the generated data, but the MQTT message is never sent. I don’t see any errors, there is nothing on the MQTT broker side.

This is how my mqtt.to line from the query looks like:

    |> mqtt.to(
        broker: "tcp://192.168.1.80:8883",
        topic: "growatt/balance",
        clientid: "cpu-flux",
        name: "balance",
        username: "xxx",
        password: "xxx",
        valueColumns: ["balance"],
        tagColumns: ["type"]
    )

Due to the calculation in the flux query the data which is returned in not a table stream, just a single table. I am not sure if that is the issue why nothing is sent: