Mqtt and command line

26 views
Skip to first unread message

piheat...@gmail.com

unread,
Dec 21, 2015, 11:47:06 AM12/21/15
to MQTT
Hi

I'm hoping someone can offer some help?

I'm running raspbian on a Pi 2 and my broker is mosquito.

To read my current household energy usage I type a command into command line which displays a numerical reply from my energy monitor connected by usb.

Is there a way to publish this reply over mqtt?

Sorry if this is a simple question. I've search the Internet before posting but finding it difficult to find the answer I need.

Jan-Piet Mens

unread,
Dec 21, 2015, 11:58:17 AM12/21/15
to mq...@googlegroups.com
> To read my current household energy usage I type a command into
> command line which displays a numerical reply from my energy monitor
> connected by usb.

assuming `energy' is the command you use:

mosquitto_pub -t your/topic -m "$(energy)"

that will republish the stdout produced by `energy' as a payload to the
topic "your/topic".

-JP

piheat...@gmail.com

unread,
Dec 21, 2015, 1:21:46 PM12/21/15
to MQTT
Hi JP

Works perfect. Thank you for your help.

Reply all
Reply to author
Forward
0 new messages