I can’t for the life of me figure out the syntax, how do you printf the device name? I feel like there’s a simple answer that I’ve missed somehow. Here’s my code - what do you put in there to output the esphome device name?
// Print device name in top center.
it.printf(64, 0, id(font1), TextAlign::TOP_CENTER, "%s", WHATGOESHERE);
Compiling /data/seeed-xiao-esp32c3/.pioenvs/seeed-xiao-esp32c3/src/main.cpp.o
/config/esphome/seeed-xiao-esp32c3.yaml: In lambda function:
/config/esphome/seeed-xiao-esp32c3.yaml:138:73: error: 'name' was not declared in this scope
it.printf(64, 0, id(font1), TextAlign::TOP_CENTER, "Device name: %s", name.c_str());
^~~~
Anyone know the proper syntax to print the esphome device name? I can’t seem to find any references in the docs…
Do not listen to uncapped_shady. He’s posting information from what seems to be a bot, or he is a bot. Either way, the information he’s posting is 100% made up.
@orange-assistant makes a very good point here. App.get_name().c_str() will give you the hostname, limited to lowercase, numbers, hyphen & underscore. This might not be quite what you are looking for. For the substitution route, just use print():
Yes, I should have been more clear, what I wanted was the hostname. I have some devices with little OLED screens attached and thought it would be nice to display a small status page with the network info.