Why MQTT cover doesn't show under Integrations/Entities/Devices

I did a custom DIY cover that works with mosquito MQTT broker.
It works pretty well, I added the entity (cover.rho1) to Lovelace and I even did an automation that works well.

But the cover doesn’t show anywhere under the Integrations, entities nor devices section under HA configuration. Why it’s that ??

Configuration.Yaml

cover:
  - platform: mqtt
    name: "Rho1"
    command_topic: "/raw/esp8266/9867974/in"
    set_position_topic: "/raw/esp8266/9867974/in"
    position_topic: "/raw/esp8266/9867974/out"
    value_template: "{{ value_json.position }}"
    json_attributes_topic: "/raw/esp8266/9867974/out"
    json_attributes_template: "{{ value_json.position | tojson }}"
    retain: false
    payload_open: "0"
    payload_close: "100"
    position_open: 100
    position_closed: 0

If, like you did, configure a mqtt device in configuration.yaml, it will not show up under devices. But you should find a cover.rho1 under configuration -> entities.

well, that’s the thing, I can see the automations I did for the cover under configuration>Entities, but that’s it. I was expecting to find cover.Rho1 under Entities, but that’s not the case.

The best, I would like to see it under devices, but still it’s absent from integrations, devices and entities as well.

If you want to see it under devices, you need to send a mqtt discovery message.

1 Like

@francisp I put this on my configuration:

mqtt:
  broker: <<The ip of my mosquito broker>>
  port: 1883
  discovery: true
  discovery_prefix: ha

Then I published a topic(ha/binary_sensor/garden/config) on my broker with these contents

{
  "name": "garden",
  "device_class": "motion",
  "state_topic": "ha/binary_sensor/garden/state"
}

My HA is expected to react and show a garden motion sensor somewhere ??

First of all, I would not change the default discovery_prefix from homeassistant to ha. It is not supported if you configure mqtt through the UI, and all device software that supports home assistant mqtt discovery use homeassistant as discovery prefix (tasmota, zigbee2mqtt, openmqttgateway, etc…)

Second : the example you posted will not create a device, as there is no device information in the discovery message. Take a look at this example :

topic : homeassistant/sensor/xiron_3201/temperature/config
message :

'{"unit_of_measurement":"°C","device_class":"temperature","value_template":"{{ value_json.TEMP }}","state_topic":"rflink/Xiron-3201","name":"eetkamer_temperature","unique_id":"eetkamer_temperature","device":{"identifiers":["xiron_3201"],"name":"xiron_3201","model":"Digoo temp & humidity sensor","manufacturer":"Digoo"}}'

The important part in creating a device is after “device”:

If I publish manually the line it works :slight_smile: The ESP shows under the devices list. On the other hand, on my Arduino it fails to publish :frowning: By any luck you don’t know why the code below fails to publish ? If I comment the dev and json_attr_tpl lines, then it publish, but with any of those lines uncommented the publish fails… :frowning:

     String configString = "{\"dev_cla\":\"shade\", \"name\":\"" + configName + "\", ";
      configString += "\"uniq_id\":\"" + configName + "\", ";
      //configString += "\"dev\":{\"ids\":\"" + configName + "\",\"name\":\"" + configName + "\",\"mdl\":\"ESP8266 Wemos D1 Mini\",\"mf\":\"LOLIN\"}, ";
      configString += "\"~\":\"homeassistant/cover/" + configName + "\", ";
      configString += "\"cmd_t\":\"~/in\", ";
      configString += "\"set_pos_t\":\"~/in\", ";
      configString += "\"pos_t\":\"~/out\", ";
      configString += "\"json_attr_t\":\"~/out\", ";
      //configString += "\"json_attr_tpl\":\"{{ value_json.position | tojson }}\", ";
      configString += "\"val_tpl\":\"{{ value_json.position }}\"";
      configString += "}";

      this->mqtt_publish(psclient, "homeassistant/cover/" + configName + "/config", configString, true);



void NidayandHelper::mqtt_publish(PubSubClient& psclient, String topic, String payload, bool retained) {
  Serial.println("Trying to send msg..." + topic + ":" + payload);
  //Send status to MQTT bus if connected
  if (psclient.connected()) {
    Serial.println(psclient.publish(topic.c_str(), payload.c_str(), retained));
  } else {
    Serial.println(F("PubSub client is not connected..."));
  }
}

Thanks a lot for the help, I can see the light at the end of the tunnel :stuck_out_tongue:

EDIT: It seems maybe the message length is too much ? If I comment different lines then it works, all lines uncommented, the message it’s too long and it fails ???

EDIT: the trouble was the size of the payload. I just added psclient.setBufferSize(512); to the code and it works.