How to setup ESPEasy+BME280+HA with MQTT?

Hello everyone. I am very new to HA and MQTT but I have done a lot of searching for answers. I have successfully setup HA on Rpi and ESPEASY on a NodeMCU with a BME280 sensor attached to it. I can’t find anywhere how I could get the values from ESPEASY to HA. I have come across many threads where someone is using OpenHAB on ESPEasy side and something else in HA’s side for MQTT broker, I am very confused. Here are some info that might be useful

*ESPEASY- In devices, the BME280 is named BME280, the *I2C is 0x76 *Values- 1. Temperature 2. Humidity 3. Pressure

Under Controllers 1. Protocol: OpenHAB MQTT Locate controller: Use IP address (Controller IP 192.168.1.400 Port: 8123- that is how I connect to HA)

I really don’t know what to use in Controller Subscribe and Publish.

I would also appreciate if someone could give me the code that I can insert in Configuration.yaml.

Have a look here http://xbmcnut.blogspot.co.nz/2016/08/using-espeasy-with-home-assistant.html.

If you’re playing around with MQTT, download and install MQTT.fx as it will allow you to ‘subscribe’ to topics coming from your ESPEasy instance so you can ‘see’ what is going on. You can also ‘publish’ back to activate GPIO pins as per my blog post.

Here is code from my ‘sensors.yaml’ file showing three instances of temperature coming from various ESPEasy instances.

# sensor 2:
- platform: mqtt
  state_topic: "/solar/exit/temperature"
  name: "Solar Temperature"
  qos: 0
  unit_of_measurement: "C"

# sensor 2:
- platform: mqtt
  state_topic: "/solar/Tin/temperature"
  name: "Solar Input Temperature"
  qos: 0
  unit_of_measurement: "C"

# sensor 2:
- platform: mqtt
  state_topic: "/solar/pwm/12"
  name: "Solar Motor Value"
  qos: 0

Hi, I actually went through your post many times before even signing up. Unfortunately the more I read about MQTT the more confusing it gets. I downloaded MQTT.fx and couldn’t do much, I typed in the ESPEasy ip but couldn’t connect. The ESPEasy’s ip is 192.168.1.40 and the RPi with HA on it is 192.168.1.246, here are couple screenshots

Hi there,

Yep, see a few errors there.

  1. You need to tick ‘send to controller’ for the BME280 data to be sent to your MQTT broker.
  2. MQTT.fx is a client just like an App or even the ESPEasy device itself. It can subscribe and publish to topics just like all clients however, it needs to connect to your broker (server), not another client. Connect it to 192.168.1.246 if that is the address of your MQTT broker.

MQTT.fx will tell you when it connects to the broker showing this green dot on the right.

Once connected, click the scan button bottom left to see all topics coming into the broker from all clients

You should see temperature, humidity and pressure data coming in if all configured properly. Just get to that point and we’ll go from there.


At the bottom of the page there is info about how to setup.
  • Controller Subscribe: home/%sysname%/# (instead of /%sysname%/#)
  • Controller Publish: home/%sysname%/%tskname%/%valname% (instead of /%sysname%/%tskname%/%valname%)

You also need to check “send to controller” on the device BME280 screen at ESPEasy.

Did you check if your home assistant MQTT broker is working properly?

Thanks for your reply. I checked that page earlier but I just couldn’t understand the context. I did try adding home to both but couldn’t go far. I also read somewhere in another thread, someone was successful doing the switch as he posted his screenshots. He did not add “home” but he was still successful. Is that “home” the name of the HA as it shows in front page?

I tried scanning after seeing your screenshot but MQTT.fx didn’t find anything. Is there anything I should be adding to the configuration.yaml file to enable MQTT on HA’s side? I came across this: https://www.home-assistant.io/docs/mqtt/broker#run-your-own. So I added with the appropriate spacing (not showing here),

mqtt:
broker: 192.168.1.246
Then I scanned again but couldn’t find anything.

@consig1iere Did you confirm the green dot on the right of MQTT.fx? If you are using Hass.io, have you installed the MQTT add-on from the store? That is the first step. Once you can confirm the green dot with MQTT.fx, you know you’re broker is up and running. Without that confirmation, you’re going round in circles.

@xbmcnut Hi,
If I put just “mqtt:” or “mqtt: discovery: true” (next line) in configuration.yaml file, then I can connect (green dot) and get “$SYS/broker/version” in MQTT.fx but not with
“mqtt:
broker: 192.168.1.246”

I know just “mqtt:” is default/basic and not really that good. How do I get the correct version of mqtt that will play nice with ESPEasy’s OpenHAB mqtt? I installed HA through DietPi, I don’t think that is the Hass.io version, therefore I don’t have the addon store. Any suggestion? Thanks.

A broker is a broker so it does not really matter which one you use. Have a look here and here for help with MQTT.

Basically, once connected to your broker, you should be able to publish something on one topic and subscribe to the same topic to get a reply. Trying publishing to the topic called ‘test’ with a payload of ‘hello’ (without the quotes). Subscribe to the topic ‘test’ and every time you publish to ‘test’, you should see hello come back in the subscribe window. If that works, your broker is good. N.B Turn on notifications shown below to receive pop-ups.

image

image

Using just mqtt: gets the embedded broker, which works perfectly fine for basic connections. It lacks some more advanced features (at least it did the last time I tried it), but you are not using those here.

You can worry about installing mosquitto (or some other MQTT broker) at a later stage when you need those features.

i dont use hassio, but your screenshot of espeasy doesnt show username and password for the broker, without this it wont connect. Also in advanced on espeasy it will show system logs and tell you if its connected to the broker succesfully

You don’t need a username and password in ESPEasy if you did not configure your broker to use one.

wasnt sure if that was the case with hassio, using mosquitto on hassbian seems to default to the pi user.

good to know, if i ever move over to hassio.

Hi @xbmcnut,
Thanks for the information. I made some progress. I was successful at connecting ESPEasy to the HA via MQTT. Since I am using a BME sensor, I get 3 readings- Temp, Humidity and Pressure. I am successful in getting either one to HA. How can I get all 3 readings? This is what my attempt on getting all 3 readings looks like:3Sensors

Here is what my configuration.yaml looks like:

  sensor:
     - platform: mqtt
       name: "BME280 Temperature"
       state_topic: "home/D1/BME280/Temperature"
       unit_of_measurement: "°C"
       device_class: temperature
 
     - platform: mqtt
       name: "BME280 Humidity"
       state_topic: "home/D1/BME280/Humidity"
       unit_of_measurement: "%"
       device_class: humidity
 
     - platform: mqtt
       name: "BME280 Pressure"
       state_topic: "home/D1/BME280/Pressure"
       unit_of_measurement: "mb"

Change the “D1” with your unit name. Is the on the Config tab on the espeasy.
Espeasy outputs the temperature in Celsius, leave it in Celsius, home assistant will convert for you.

1 Like

You need to make sure of your topic as it is case sensitive and with ESPEasy, starts with a forward slash by default. If you spark up MQTT.fx, connect to your broker and then try subscribing to either /home/# or home/#, that will show you your full and exact topic paths for each sensor that you can copy into Home Assistant.