#MQTT Config Topic

1 messages · Page 1 of 1 (latest)

kind cargo
#

It's beena few hours. Did you get it going yet or still need advice?

#

MQTT Config Topic

lament sorrel
#

Nope, still no replies that I'm aware of

kind cargo
#

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 }}"
}
lament sorrel
#

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);
kind cargo
#

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.

lament sorrel
#

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",

kind cargo
#

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.

lament sorrel
#

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

kind cargo
kind cargo
lament sorrel
#

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

kind cargo
#

unique per sensor

lament sorrel
#

i'll try adding some of these and see what happens, sec

#

"avty_t": LWT,
what is LWT here?

kind cargo
#

Then, you have mqtt-explorer

#

?

lament sorrel
#

nvm
LWT = TOPIC + D_ID + '/lwt'

kind cargo
#

lwt last will testament. If the sensor is offline, this tells ha it os offline.

lament sorrel
#

gotcha, i was just coming to that conclusion myself, i hadn't seen one implemented till now

kind cargo
#

So if the esp is off, it will grey out the values in HA

lament sorrel
#

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

kind cargo
#

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.

lament sorrel
#

After adding the online/offline/unique id, it just created another device

kind cargo
lament sorrel
#

no sensor entity

kind cargo
#

That program

lament sorrel
#

i hadn't heard of this yet, thanks

kind cargo
#

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.

lament sorrel
#

Thank you!

lament sorrel
#

I'm pretty sure it'