Tasmota: Make discovery topic configurable via UI

Dear HA Tasmota devs

At the moment, the discovery topic for Tasmota devices can only be set manually if no devices have been detected and the user manually adds Tasmota integration.

image

I would like to request the option to manually define (and at any time change) the discovery topic via UI (or via configuration.yaml, but that is no longer wanted by HA).

The background for my request:
I am working on a Node-RED project that allows data processing as a step between Tasmota devices and Home Assistant. The user can then process any sensor data before it is published to Home Assistant.

For this to work, the Tasmota integration needs to subscribe (and remain subscribed) to a non-default discovery topic, otherwise Tasmota changes the sensor topic (according to the config topic’s tp[2] aka Prefix3) and receives the raw data instead of the processed data.

I am happy to act as beta tester. Just comment here or send me a PM.

Thank you
Alex

EDIT:
I checked the code and it seems that the topic is defined in three places:
config_flow.py

        # "tasmota/discovery/#" is hardcoded in Tasmota's manifest
        assert discovery_info.subscribed_topic == "tasmota/discovery/#"
        self._prefix = "tasmota/discovery"

The discovery topic is hardcoded in Tasmota (but can be changed with custom builds).
The discovery topicis also referenced in
const.py

DEFAULT_PREFIX = "tasmota/discovery"

and
manifest.json

  "mqtt": ["tasmota/discovery/#"],

I think these lines would need to be overridden by a user input value.

I am not sure if
homeassistant/generated/mqtt.py would also need adjusting or if the tasmota integration can handle it internally.

    "tasmota": [
        "tasmota/discovery/#",

I have not yet been able to find out how to even create a user input, so I am stuck in creating a PR.

If anybody can help me, that would be great :slight_smile:

Basically I think those three Tasmota integration files would require tasmota/discovery/ to be a user input. If those three use the same user input string, it should work.