Send the contents of a file (data.txt), by reading from stdin and send the entire input as a message and publish it to sensors/temperature topic

mosquitto_pub

  • A simple MQTT version 3.1.1 client that will publish a single message on a topic and exit.
    More information: <https://mosquitto.org/man/mosquitto_pub-1.html>.
  • Trick copyright: tl;dr; <https://github.com/tldr-pages/tldr>

mosquitto_pub -t {{sensors/temperature}} -s < {{data.txt}}

click the source code to copy install mosquitto_pub on any operating system with command-not-found.com