<!-- Thanks for suggesting an idea for this project. READ THIS FIRST:
Please …take a few minutes to complete the requested information below. Our ability to provide assistance is greatly hampered without it. The details requested potentially affect which options to pursue. The small amount of time you spend completing the template will also help the volunteers providing the assistance to you to reduce the time required to help you.
DO NOT DELETE ANY TEXT from this template! Otherwise the issue will be auto-closed.
-->
**Have you looked for this feature in other issues and in the docs?**
Yes
**Is your feature request related to a problem? Please describe.**
Home Assistant's MQTT discovery protocol includes a lot of redundant information which increases Tasmota's code size, and has some crucial limitations e.g. RGBxx lights flickering when turning on from HA.
Also, Home Assistant's MQTT discovery protocol is not easy to add new features or make breaking changes to.
**Describe the solution you'd like**
Acceptance of a custom MQTT discovery protocol for Tasmota. Work has started, but some feedback is needed.
An estimate is that 2-3kB code can be saved.
Short term, this will have to co-exist with Home Assistant's MQTT discovery format:
Maybe:
- When SetOption19 = 0, send Tasmota's custom MQTT discovery format
- When SetOption19 = 1, send Home Assistant's MQTT discovery format
Longer term, support for Home Assistant's MQTT discovery format can be removed from Tasmota or included as a non default compile-time option if needed by other SW, e.g. for OpenHab support.
**Describe alternatives you've considered**
1. Build a native HA integration but keep using HA's MQTT discovery protocol.
Drawback: It will still not be possible to keep compliant to HA's MQTT discovery protocol and also add new features.
2. Don't use any discovery format at all, send MQTT messages to query the Tasmota device about its configuration.
Drawback: Not all necessary information can (easily) be read by MQTT messages.
**Additional context**
Work on a Home Assistant native integration is started, with an MVP PR https://github.com/home-assistant/core/pull/39624 which supports:
- Discovery, update and removal of Tasmota devices
- Discovery, update and removal of relays (switch entities in HA)
The planned next steps are:
- Discovery, update and removal of lights
- Discovery, update and removal of switches
- Discovery, update and removal of buttons
- Discovery, update and removal of sensors
- Add support to manage the Tasmota from HA
- Add Tasmota console in HA
- Ideas??
**Preliminary discovery message format example**
Topic: `tasmota/discovery/49A3BC`
Payload:
```
{
"ip":"192.168.15.10", // IP address
"dn":"Living Room", // Device name
"fn":["Ceiling Lamp", "Floor Lamp"], // List of friendly names
"hn":"tasmota_49A3BC-0956", // Hostname
"id":"49A3BC", // ChipID
"md":"Sonoff Dual", // Module
"of":"Offline", // D_OFFLINE
"on":"Online", // D_ONLINE
"st":["OFF","ON","TOGGLE","HOLD"], // StateText[0..3]
"bd":"8.4.0.2", // Tasmota SW build version
"t":"tasmota_49A3BC", // Topic
"ft":"%prefix%/%topic%/", // Fulltopic
"tp":["cmnd","stat","tele"], // [SUB_PREFIX, PUB_PREFIX, PUB_PREFIX2]
"li":[0,0,0,0,0,0,0,0], // Lights, 0: disabled, 1: Enabled
"rl":[0,0,0,0,0,0,0,0], // Relays, 0: disabled, 1: relay, 2.. future extension (fan, shutter?)
"sw":[0,0,0,0,0,0,0,0], // Switches, 0: disabled: 1: enabled
"bt":[0,0,0,0], // Buttons, 0: disabled: 1: enabled
"so":{"13":0,"17":1,"30":0,"37":1,"68":0,"73":1}, // SetOption needed by HA to map Tasmota devices to HA entities and triggers
"lt_st":0, // Light subtype
"se":[0], // Sensors, 0: disabled, 0..xx index in kHAssJsonSensorTypes (??)
"ver":1 // Discovery protocol version, must be 1
}
```
**Screenshots**
Add Tasmota integration to HA:
![image](https://user-images.githubusercontent.com/14281572/92499803-97db3680-f1fc-11ea-83bb-2e9977205241.png)
Discovery message received by HA:
![image](https://user-images.githubusercontent.com/14281572/92500139-015b4500-f1fd-11ea-95c1-d07ea79373ee.png)
![image](https://user-images.githubusercontent.com/14281572/92500097-f43e5600-f1fc-11ea-9c35-e83e69179a11.png)
**(Please, remember to close the issue when the problem has been addressed)**