ESP8266/NodeMCU Sensors: MQTT or HTTP?

I’ve been setting up some NodeMCUs with various sensors and it’s working great. I want to avoid the step of configuring HA for every new sensor/nodemcu that gets created. I seem to have two options:

MQTT Discovery

I was able to get this working however, I found two issues. HA will duplicate the sensor every time you pub the config topic. If you don’t submit the config topic, you can’t post data. So getting the sensor defined once and only once appears to take more than just MQTT discovery.

HTTP Post

This works great, even better than MQTT discovery. One post with the value and name and HA creates and/or updates the value. All I do is set the unique name in the code, upload the firmware and I’m done. Data shows up in HA.

However I notice that most everyone is going the MQ direction. If I don’t intend to send this data to another broker, what am I giving up by going http post only? Will mqtt on the esp be any more reliable than http?

1 Like

Yes, it does because MQTT discovery is pretty new and not fully done.

Nothing. HTTP and MQTT are just two different ways to do it.

I prefer MQTT. I don’t have any issues with a duplicate sensor. I’m using ESPEasy.

With http-post, only HA will be able to do anything with it. If you post to an mqtt broker, other clients, such as an android app, will be able to receive messages and act upon them.

Also, it will be far simpler to switch to another controller, such as Openhan or Domitz, if you use mqtt. Just about every one of them can receive mqtt, but you would have to rewrite your sensor if you use http.