The comments in your lambdas need to use // (as it’s C++ code):
text_sensor:
- platform: template
name: "LCD Nachricht"
id: display_text
update_interval: never
lambda: |-
return {id(display_text_global)}; // Umwandlung in optional<T>
display:
- platform: lcd_pcf8574
dimensions: 16x2
lambda: |-
it.printf(0, 0, "%s", id(display_text_global).c_str()); // Text korrekt auf dem Display ausgeben
After fixing these (and filling in the SSID and password), your configuration compiles for me.
It’s worth noting that the template text component might be an easier way to implement this, as it allows sending text directly from Home Assistant: Template Text — ESPHome