I have just started with Home Assistant and I am learning quite a bit.
My project is to send data from ESP32 to Home Assistant. I am using MQTT to send the data. I set up Mosquitto Broker and my ESP32 is sending data on the topic “esp32/BME280/temperature”, which I can listen to under the “Listen to a topic”. However, I cannot seem to add a sensor using these Values.
If you are using mqtt rather than api on esphome the device should show up on the integration screen under mqtt. You shouldn’t have to add lines to configuration.yaml. I’m assuming you’re using esphome. If not then show the whole json out put as it may just be a parsing problem.
I am not using ESPhome. I am just trying to post values received as this leads to another project of mine. Like I said, I can receive the data on esp32/BME280/temperature while I listen to it on the configuration page of MQTT but I am not sure how to take those values and post them in a chart.
Sorry, I had edited my post just before you replied.
mqtt:
sensor:
In your bottom example of YAML I think the ‘-’ before sensor isn’t needed. The s of sensor should be under the first t of mqtt. Doing this from phone so proving difficult to edit.
Your top one uses platform: mqtt which has been deprecated.
It looks like either of these formats works. Top one works for me in latest version of HA.
It may well be your templetating of the json. Show the json output of esp32/BME280/temperature mqtt message. The parsing of these can be tricky.
Is it a AM2301 or a bmp280 or both you’re using? These formatted texts i type are not showing correctly on my phone. Indentations all wrong.
Okay. Thank you for the info. i think I might have just cracked it. But to me safe I just reformated the HA OS and reinstalled it. Running on Raspberry Pi with the latest version.
At first, I was sending the values from Arduino as a String “char tempString[8]” and publishing it on a topic. So i guess the reason my sensor wasn’t working is because of the value template?
But after reading your message i retraced my steps and realised I should be sending in the message as a json. Which I did. and Extracting from MQTT Explorer my data is being shown as