Sensor MQTT Subscribe Topic value from text component

Hello ESPHome Forum,

I’m currently working on a project in which I want to react to some MQTT text sensors (display on a display) and install this project in multiple instances. I thought to myself that it would be great if you could easily set the MQTT topic name via the web interface of the installed devices. I’ve now tried that, with the text component I manage to enter a topic name in the web interface and save it in a global variable, but I can’t set or change the topic in the sensor. All attempts fail because a set_topic command is not available, which I e.g. could use in a lambda. But maybe I’m just being stupid :frowning:
Since there are over 10 topics in my project that I need to adjust in some devices, it would be really great if I could find a solution for this. I hope I was able to explain well enough what I’m trying to do :slight_smile:

Thank you for your help!

Çreate an mqtt text sensor, then display it

Hello,

I think my problem was not properly understood.
I want to use the text component
https://esphome.io/components/text/index.html

Create an input option to make the topic configurable in the Sensor MQTT Subscribe module.
https://esphome.io/components/sensor/mqtt_subscribe.html

Thank you for your help!

Not sure you can do that.

Hello,

That’s my problem, that it doesn’t work and I would like a solution for it. Since I couldn’t find a solution to this on my own, I asked the question here in the forum with the hope that someone could help me.

Sascha

Well it’s a pretty out of scope and odd request. But topic is not templatable. So there is no way to do it in yaml.

There may be a way to do it in a custom component.

I’m not sure what’s so strange about my request. It’s a shame that it’s dismissed as nonsense here.

I didn’t say it was nonsense. I said it couldn’t be done in yaml and suggested a custom component.