You can’t pass a string to id. The preprocessor uses it to convert it to C++ format sht_dewpoint->update().
Components do not have a string name representation. So, if you want to execute a function on a component based on a string name: don’t see a way how this can be done.
But… components can have 1 or more sensors, each sensor has a name. If you want to execute a function on specific sensors: you can get the list of sensors through App. Below sample code to print all sensor names. You can modify it to get the sensor based on a string name.
auto sensors = App.get_sensors();
for(unsigned int i = 0; i < sensors.size(); i++)
ESP_LOGD("app", "Sensor: %s", sensors[i]->get_name().c_str());
Do note that there is a getter for each type of sensor. For binary sensors, need to use get_binary_sensors(). For text sensors, use get_text_sensors()
I have followed your code and I can get the name of the sensors, but I don’t know how can we acces to the state of each sensor with the recovered names instead of the id() method.