Hi I am struggling to send some MQTT from my EMONPI which will go to Home Assistant. I have followed several threads here but I am confused about getting MQTT to work and so far I have not succeeded.
I believe that MQTT is running on my EMONPI and I checked that from setup. I tried some of the topics (including some with wildcards) as mentioned in the testing section of the guide MQTT - Guide | OpenEnergyMonitor I tried to use the topics in HA but nothing seems to come through.
I have now installed MQTT explorer to try and see what MQTT is publishing but I cant work out how to enter the relevant info from my emonpi account into MQTT explorer.
Setting up the MQTT Explorer connection asks for the following, in brackets is what I think I should be entering but it does not work)
Host (IP address of my emonpi)
Port(1883)
Username (my emonpi login)
Password (my emonpi password)
After a few moments this says âDisconnected from serverâ
I would appreciate any tips on getting this working.
Thatâs not right. By default, an MQTT user is created called emonpi with a default password, but I would create a login for Home Assistant by connecting with ssh and using the command sudo mosquitto_passwd /etc/mosquitto/passwd homeassistant
and then sudo service mosquitto restart
to make sure it detects the new user (reload instead of restart may suffice but Iâm not completely sure). Then put those details into HA and it should connect.
I think youâll also want to add some âPublish to MQTTâ steps to your input processors but maybe there are other ways.
I have managed to look at what is coming out of the emonpi MQTT service with MQTT Explorer using the default userid and password.
However I still cant see the topic in Mosquito MQTT on my HA instance. I may be formatting the topic incorrectly. I have tried 192.168.1.29:8123/emon/emonpi/power1/ and similar but my HA MQQT just sits and does not seem to receive anything.
Can anyone help me with the correct format for subscribing to an emonpi topic in HA Mosquito MQTT?
In order to break the fault finding down you can publish from MQTTexplorer to HA. In that way you easily change your topic / payload string until you find what HA accepts. The address you show 192.168.1.29:8123 is the HA home page. The normal port for MQTT is 1883. I am not sure if you need the MQTT addin running on HA too, I have it enabled and have no problem publishing MQTT message to HA. On your topic you do not need the leading / on emon, it should be emon/emonpi/power, the trailing / isnât needed either. I hope that helps you sort out your issues.
Thanks Bob I have tried a lot of options but I just cant get it to work in Mosquito MQTT on my HA machine. Would you be able to post the exact format you use for topics on your HA? Thanks
Hi, Iâll have a look at how I post to HA tomorrow as its getting a bit late now. I usually post into Node-RED first and then into influxDb and Grafana for displaying my data. I am sure I have some stuff that posts direct to HA though. I donât have am emonPi but I do use an ESP8266 to post to emoncms and node-RED via MQTT and HTTP POST. I run Node-RED, InfluxDb and Grafana all under HA too.
This is what you need to place in your configuration.yaml. You will need to get your own api_key from Emoncms website screen under âSetup/My Accountâ. Copy the R/W API key and replace the one above. You will need to amend the IP address to the one that Emoncms is running on. (192.168.0.105) You will see the feeds turn up in HA. Note: Ensure to remove the âSâ from the https: if you use the original code as you will not have a security cert installed locally normally. This is what gets people, as they do have the âhttps:â on the original code. Make sure you are stating the IP of the EMON an not the HA by mistake. This has also happen quite a lot. Enjoy. Only the Feeds will turn up by default unless you start changing stuff. MQTT doesnât need to be the for this to work.
Yep. Call learn to walk before you run. If he can get this working then at least we know heâs talking the the right boxes. Then, any thing he need to be published in the Feeds would appear. The MQTT works fine as you can set it up in HA and use the default account & Password to login. Then /# in the query to get everything. this again would confirm coms. But, each to there own.
I disagree. If the question was âhow to get data from Emoncms to HAâ then you would be correct. But the OP asked about MQTT so that is the answer given.
You can publish data to MQTT that you do not pass into a Feed, so it is a different question.
I am trying to see emon data in my HA I donât really mind how I get it. I had assumed that the mechanism would be via MQTT but that may not be correct, I am very new to HA and I may have used the wrong terminology.
II have just managed to get some data into my HA using Davids method above, however I think previously I may have been editing the wrong configuarions.yaml file, this time I used the one in config/ and I can see data in my dashboard.
Although I can see some data it seems to be static and isnât updating but its a big step forward to know I can get the data into HA.
I hope you have made progress. I have a similar quest. I have asked the forum how the mechanism for posting data to emoncms.org works, since the entries in the Sync tab are empty in my local emoncms, but I have not received any response.
I have an experimental espwroom32 board reading the mqtt messages over wifi. I could extend this to relay the mqtt messages to adafruit and from there I can link to IFTTT and Google Assistant. This seems more straight forward than penetrating the mysteries of how data gets from the local emoncms to emoncms.org.
I wonder if there might be relevance here to your project.
My Ultimate Quest is to get the data out of the emoncms ecosystem and into a IFTTT system. I would then be able to control smart plugs etc with Google Assistant.
A route seems to be to publish the mqtt values to adafruit (which I can do with an espwroom32 board reading the mqtt messages over wifi) and from there to IFTTT and from there to Google Assistant.
However the emoncms system is quite sophisticated and capable of publishing to emoncms.org and so I would prefer to eliminate the need for a separate piece of hardware, the espwroom32, and have the local emoncms publish directly to adafruit (or similar, from which IFTTT can read).
However I donât understand the mechanism or settings by which the local emoncms publishes to emoncms.org
âYou could republish the data to a different MQTT topic as part of the Input Processing (that does presume you use MQTT for this).â
I already have everything I want to deliver to IFTTT as mqtt messages. I have the currents and voltage as measured by the emon system in the garage. This includes the excess Watts. I also have the temperature, wattage and cumulative Wh of the immersion heater tank. These are all mqtt messages eg
Message arrived on topic: emon/ardAC/wTempC. Message: 50.81
which is the debug message from the espwroom32 board.
It would be easy to send these data on to adafruit as they are received. My question is whether there is a more direct way of sending the data directly to adafruit directly from the emon system. That is what I assumed âSyncâ was all about.