Hi
If I use wildcards in a subscribe can I somehow get a topic?
mqtt:
id: my_mqtt
on_json_message:
- topic: ble2mqtt/#
then:
- lambda: |-
if (x.containsKey("temperature")){
ESP_LOGD("DEBUG", "Topic %s : Temperature %.1f" , "how_to_a_get_topic?" ,(float)x["temperature"]);
}
Jojo-A
2
Hi,
I am also stumbling across that and I am wondering why there is so less information about that usecase out there!
This is my config:
mqtt:
id: mqtt_client
on_message:
- topic: any/cool/topic/+
then:
- lambda: id(my_mqtt_topic) = **"how do I get the topic?!?"**
globals:
- id: my_mqtt_topic
type: std::string
restore_value: no # Strings cannot be saved/restored
initial_value: '"123"'
Even without wildcards (afaik they have not been supported for long time anyway) I can not find a way to access the topic at all!
Thanks a lot in advance!
Jojo-A
3
Hi,
I just wanted to bring up this question again. It has been around for some time now without any reaction…
Greetings