Using MQTT to get data

Been reading through this post and trying to do something similar ( i have flashed a few energy plugs to Tasmota and also have Home Assistant up and running)…

Where are you running NodeRed? Have you any instructions on the NodeRed piece?

Assume on the EMONCMS Host or on something like home assistant?

I run it on my emonPI, installed using the instructions here.

I use the flow which I enclosed here.

As stated regularly, this is a recipe for disaster. The advice is to run NR on a separate device.

I agree - it’s extra wear on the card, but I don’t have a spare machine to run it on.

1 Like

I have been trying for a few hours tonight to get some basic data off a Shelly device or even a Tasmota into the MQTT broker already installed via my existing emoncms install… I have node-red installed but still unsure of what way the flow from the device (shelly or tasmota) should work…

I assume it is device → MQTT Queue (in my instance the one on emoncms) → node red → another mqtt queue (on my emoncms device) → read in my EMONCMS…

Am I right? I appreciate any clarity, insight or help you can provide

Yes, they all feed into the same MQTT broker, first under their own topic (e.g. Smartplug/Smartplug1/SENSOR/#) , then into the NodeRed flow, which parses it correctly for Emon, and then post it back to the MQTT broker under the emon topic (emon/Smartplug1).

If you put debuggers on the relevant parts of the flow, it helps to see whats going on:

Thanks for the reply Tom - thought that was it

I am struggling to get a topic and connection currently to the MQTT queue running on my EMONCMS PI up and running… How do I set that up to enable a shelly or tasmota device to connect and onto the queue?

I’m not sure you are understanding how MQTT works - I suggest a bit of googling.

To connect to the MQTT Broker on the emonpi, you need to tell the Shelly or Tasmota flashed device to send their data to that Broker. On tasmota, you need (from the console);

backlog mqtthost 192.168..x.xx; mqttport 1883; mqttuser emonpi; mqttpassword emonpimqtt2016;

where the mqtthost is the IP address of the EmonPi. Unless you fix this in someway (again google) it might be changed if the router reboots.

Once you have that, connect to that Broker from Node-Red and subscribe to all topics and see what data is flowing.

Personally I use an MQTT tool to view all the data flowing such as MQTT.fx on Windows.

Thnx Brian, I was playing more today, I was struggling to understand the AUTH Details for the MQTT Server running via the EMONCMS install, so used the MQTT server for testing setup on my HOMEASSISTANT pi.

Have been using the mosquitto_sub client to view a topic… Will try the tool (MQTT.fx) you recommend, would love to be able to view/query what are all the topics which the MQTT server has and then subscribe to the appropriate ones etc…

Why and (possibly answering the first too) where is it stated regularly? I’ve not seen this advice before.

How much do I really need to buy, care for and feed another RPi just to run NR? Why would running it on another RPi not be a recipe for disaster as much as running on an emonPi? Would it be any less disasterous running NR alongside emonCMS on a RPi using emonSD?