Ok, I tried the code for me, but I don’t get it working…
display:
- platform: ssd1306_i2c
model: "SSD1306 128x32"
reset_pin: D0
address: 0x3C
lambda: |-
if (id(icon_ow).has_state()) {
std::map<std::string, std::string> weather_state {
{ "rainy", ""}, // mdi-weather-rainy
{ "cloudy", ""}, // mdi-weather-cloudy
};
it.printf(5, 5, id(font_icon), weather_state[id(icon_ow).state.c_str()].c_str());
}
font:
- file: "materialdesignicons-webfont.ttf"
id: font_icon
size: 12
glyphs: [
"", # mdi-weather-rainy
"", # mdi-weather-cloudy
]
sensor:
- platform: homeassistant
id: icon_ow
entity_id: weather.openweathermap
error:
src/main.cpp: In lambda function:
src/main.cpp:405:68: error: request for member 'c_str' in 'icon_ow->esphome::homeassistant::HomeassistantSensor::<anonymous>.esphome::sensor::Sensor::state', which is of non-class type 'float'
it.printf(5, 5, font_icon, weather_state[icon_ow->state.c_str()].c_str());
^
Thanks for the help!