I’m using a D1 mini with an OLED display as part of an air quality sensor, I’ll deploy several of these sensors and I want the first line on the display to be the device name (friendly_name), however I’m completely stumped on how to pass the friendly_name value to a printf command.
This is my sample code:
esphome:
name: air-monitor-2
friendly_name: Air Monitor 2
esp8266:
board: d1_mini
i2c:
sda: D2
scl: D1
frequency: 50kHz
font:
- file:
type: gfonts
family: Roboto Mono
weight: 400
id: my_font1
size: 12
display:
- platform: ssd1306_i2c
model: "SH1106 128x64"
id: oled
address: 0x3c
update_interval: 10s
pages:
- id: page1
lambda: |-
it.printf(0, 0, id(my_font1),"%s", friendly_name.state.c_str());
This gives the error
error: 'friendly_name' was not declared in this scope
Is there any way this can be done?