#MQTT Config Topic
1 messages · Page 1 of 1 (latest)
It's beena few hours. Did you get it going yet or still need advice?
MQTT Config Topic
Nope, still no replies that I'm aware of
Here's am MQTT config file I use from a python program for raspi. https://github.com/SirGoodenough/ThermoPI/blob/main/ThermoPI.py
payloadTconfig = {
"name": NAMET,
"stat_t": STATE,
"avty_t": LWT,
"pl_avail": "Online",
"pl_not_avail": "Offline",
"uniq_id": T_ID,
"dev": {
"ids": [
D_ID,
DEVICE_ID
],
"name": "ThermoPI",
'sa': AREA,
"mf": "SirGoodenough",
"mdl": "HomeAssistant Discovery for ThermoPI",
"sw": "https://github.com/SirGoodenough/ThermoPI"
},
"unit_of_meas":"°F",
"dev_cla":"temperature",
"frc_upd": True,
"val_tpl": "{{ value_json.temperature }}"
}
how many of those params are required?
My battery config msg:
String discoveryTopic = "homeassistant/sensor/" + chip_name + "/battery/config";
DynamicJsonDocument doc(1024);
char buffer[512];
StaticJsonDocument<256> device;
device["identifiers"] = JsonArray();
device["identifiers"].add(chip_name);
device["name"] = "Feather Huzzah Wifi";
device["manufacturer"] = "Ken";
device["model"] = "Feather Huzzah ESP8266";
doc["device"] = device;
doc["name"] = chip_name + "_battery";
doc["device_class"] = "battery";
doc["state_class"] = "measurement";
doc["unit_of_measurement"] = "%";
doc["state_topic"] = stateTopic;
doc["platform"] = "mqtt";
doc["value_template"] = "{{ value_json.battery }}";
size_t n = serializeJson(doc, buffer);
auto res = client.publish(discoveryTopic.c_str(), buffer, n);
Serial.println("");
Serial.print("sendMQTTBatteryDiscoveryMsg = [size="); Serial.print(n); Serial.print("] "); Serial.println(discoveryTopic); Serial.println(buffer);
Serial.print("Publish Result="); Serial.println(res);
I know you have yours in a different format but this is easier to see problem so I look at it this way. Also I use the shorted version of the keys, that's in the MATT HA docs somewhere for the list.
right, i found the abbreviations file
i've started looking at the code because the docs are lacking
I don't have these, at least:
"avty_t": LWT,
"pl_avail": "Online",
"pl_not_avail": "Offline",
You don't have availability or the unique_id, I HIGHLY recommend those be added. Otjherwise if things go well, HA is fine but miss a broker because things happen, and HA gets confused. Vert little of the devide section is 'Needed',but it shown up nice in the device panel in HA.
It wasn't until I added the device section that it created a device object. I still haven't been able to get it to create an entity for any of the sensor values though
I was attempting battery/temp/humidity with a little battery powered esp8266 with a shell sensor
i've been able to make the mqtt device, but yeah, no entities
and you need "uniq_id": T_ID,
I had tried that as well, with no result before. I assume the unique id is unique per sensor, and not per device
i had made unique id's that were "feather_huzzah_01_bat" and such, but i don't believe that had any meaningful results
unique per sensor
i'll try adding some of these and see what happens, sec
"avty_t": LWT,
what is LWT here?
nvm
LWT = TOPIC + D_ID + '/lwt'
lwt last will testament. If the sensor is offline, this tells ha it os offline.
gotcha, i was just coming to that conclusion myself, i hadn't seen one implemented till now
So if the esp is off, it will grey out the values in HA
how do you actually get mqtt logs from mosquito? I've only been able to listen on # for everything, but it'd be neat to be able to see why it makes determinations
i'm assuming that's what you mean by mqtt-explorer
I was going to say if you look at the broker in mqtt explorer, you see what the topic actually is. If it shows up in color, the jsom is correcr. If b/w, json needs fixin. You can also dend the topic data to test sdtuff without the esp.
After adding the online/offline/unique id, it just created another device
Troubleshooting MQTT? MQTT-Explorer can help you be successful!
If you have Addons available, try adding this Addon repository to your Addon list. https://github.com/GollumDom/addon-repository.
no sensor entity
That program
i hadn't heard of this yet, thanks
Absolutely required so you can troubleshoot and see what the broker sees
I think with that you will likely figure it out. Ping me this thread if you have more questions, but to get as far as you did without a good sample and that program, you will nail this in short order.
Thank you!
I'm pretty sure it'