MQTT AutoDiscovery add registry configuration to switch

Hi,
On esp8266, i would like to push more data on MQTT discovery , my code work fine, but i am not able to add these key :

'cns':                 'connections',
'ids':                 'identifiers',
'name':                'name',
'mf':                  'manufacturer',
'mdl':                 'model',
'sw':                  'sw_version',

Do not work because of kind “switch” ?

Can i add more data like url ?

Thanks,
Best regards.

Can’t you put your misc things in the attributes?

'json_attr_t':         'json_attributes_topic',
json_attributes_topic

(string)(Optional)

The MQTT topic subscribed to receive a JSON dictionary payload and then set as sensor attributes. Usage example can be found in [MQTT sensor](https://www.home-assistant.io/integrations/sensor.mqtt/#json-attributes-topic-configuration) documentation.

So I’m guessing you can fill in the attributes topic, then publish all random attributes to said topic.

Hello,
I give up , because, as i understood, i needed to make a json template configuration file , and if this file does not exist, mqtt discovery failed with unknow attribut .
I wait for more understanding explanation about that.
Best regards.

I assume because you said ESP8266, you’re writing your own code.

You will have to create a json message for that state topic.

If you’re writing your own code, there are libraries to package data into json for you.

#include <ArduinoJson.h>
StaticJsonBuffer<500> jsonBuffer;
JsonObject& root = jsonBuffer.createObject();
root["cns"] = "connections";
root["ids"] = "identifiers";
root["name"] = "name";
root.printTo(mqtt_client);