Hi I am new and have a basic setup with HA working for awhile now…
Setup:
HAOS on VM
mosquito on VM
HA mqtt integration linked to Mosquito
several devices with e.g. tasmoto, esphome, and others
I have not got mqtt to work as it should. I have a tasmota integration that get the solar info from a tasmota sonoff device (ESP32). this works but I would like to set things up with generic mqtt sensors.
It seems that devices/sensors have to be added manually with yaml config.
note: this is my first attemp at yaml in HA. I was confused that no yaml configurations existed when i installed file editor.
OK, so I added
mqtt:
sensor:
- name: “Solar Meter Power 0”
state_topic: “tele/SonoffESP32/SENSOR”
unique_id: “ESPSolarMeterPower0”
This got me a new entity under settings.
Now I can’t seem to wrap my head around how subscribing to a topic and extracting a sensor value. In this case there are two switches and a list of sensor data for each switch. e.g. power, energy, VA, reactive power, etc.
I want to start out and retrieve the power data. From MQTTexplorer the sensor topic looks something like this /tele/sonoff/sensor/ENERGY.Power.1, but I recall long ago when i did this in openHAB that I have to use a json string like this: /tele/sonoff/sensor/power[1]
So in short my questions are:
-how to I subscribe to a topic correctly in HA, eg /sonoff/sensor
-how to extract one of many sensor values in the json packet
-how to I find and verify the correct syntax for mqtt sensor data for this example or basically any mqtt device/sensor? I have not found a good example or guide yet and I seem to be not understanding the HA documentation.
I have but I want to figure out mqtt as I have several devices not all tasmota but all use mqtt and it seems a nice idea to consolidate everything to one, standard integration protocol.
mainly I just want to learn it and figure it out
OK, while you can get the MQTT to work on an external server, I had it that way for a while, I recommend you put MQTT in an add-on instead. Things are set-up that way and tend to set themselves up using that. I switched to that after a couple of years because it was always a hassle setting something up that HA uses for MQTT, while if you use the tweaked MQTT add-on things just kinda work.
Sorry I took a break from this for a few days.
as you can see below I get a response from home assistant mqtt integration. as said the device has tasmota and this integration works.
should I add device in GUI or in YAML?
I have tried both but something is broken either way.
YAML attempt:
Update,
I just recognized that what seemed to be total failure might be partial success.
as you see below the logbook indicated received data. The entity always show unavailable status. also other entities do no show a log and I can’t seem to get data into a meaningful graph on the dashboard
OK just added the option “unit of measure” and I have a nice graph and option to add as card. I think I am getting my head around this now
I think i’ve mostly solved it;
besides figuring out the correct topics and syntax the undocumented part was the needed brackets in the json data, e.g. power[0] and power[1].