Hey,
I have a working config that i’m struggling to expand.
An oled screen is showing various img’s and mqtt values, rotating between pages.
The final page i’m adding has been stumped, im pulling in sensor data from home assistant (temp / hum) and looking to display it but im hitting issues, i believe with the data type.
I’ve tried chaning %s, %d and removing the .state.c_str() at the end of the line - all with varying levels of fail, none just pass the value which is currently 26.1.
Can anyone shed any light on how i should be pulling in this sensor data?
sensor:
- platform: homeassistant
id: officetemp
name: "Office Temp"
entity_id: sensor.4_in_1_multisensor_air_temperature
internal: true
attribute: state
- platform: homeassistant
id: officehumid
name: "Office Humidity"
entity_id: sensor.4_in_1_multisensor_humidity
internal: true
attribute: state
text_sensor:
- platform: mqtt_subscribe
name: "OLED1_Text"
id: oled1_text
topic: oled1/notify
- platform: mqtt_subscribe
name: "OLED1_Text2"
id: oled1_text2
topic: oled1/notify2
- platform: mqtt_subscribe
name: "OLED1_Icon"
id: oled1_icon
topic: oled1/icon
font:
- file: 'arial.ttf'
id: font1
size: 15
- file: 'FontAwesome.ttf'
id: font2
size: 24
i2c:
sda: D2
scl: D1
scan: True
time:
- platform: homeassistant
id: homeassistant_time
image:
- file: "bell-regular.png"
id: bell
resize: 32x32
type: TRANSPARENT_BINARY
- file: "down-cloud.jpg"
id: downcloud
resize: 32x32
type: TRANSPARENT_BINARY
- file: "plex.png"
id: plex
resize: 32x32
- file: "down-cloud2.jpg"
id: downcloud2
resize: 32x32
display:
- platform: ssd1306_i2c
model: "SSD1306 128x32"
id: oled1
pages:
- id: page1 # Plex currently viewing
lambda: |-
it.image(0, 0, id(plex));
it.printf(38, 8, id(font1), "%s", id(oled1_text).state.c_str());
- id: page2 # Home Assistant time / date
lambda: |-
it.strftime(0, 0, id(font1), "%H:%M", id(homeassistant_time).now());
it.strftime(0, 16, id(font1), "%d.%m.%Y", id(homeassistant_time).now());
- id: page3 # SabNZBd download rate
lambda: |-
it.image(0, 0, id(downcloud2));
it.printf(38, 8, id(font1), "%s", id(oled1_text2).state.c_str());
- id: page4 # Office Temp / Hum
lambda: |-
it.printf(0, 0, id(font1), "%s", id(officetemp).state.c_str());
it.printf(0, 16, id(font1), "%s", id(officehumid).state.c_str());
interval:
- interval: 15s
then:
- display.page.show_next: oled1
- component.update: oled1
Build error:
/config/oled1.yaml: In lambda function:
/config/oled1.yaml:114:54: error: request for member 'c_str' in 'officetemp->esphome::homeassistant::HomeassistantSensor::<anonymous>.esphome::sensor::Sensor::state', which is of non-class type 'float'
114 | it.printf(0, 0, id(font1), "%s", id(officetemp).state.c_str());
| ^~~~~
/config/oled1.yaml:115:56: error: request for member 'c_str' in 'officehumid->esphome::homeassistant::HomeassistantSensor::<anonymous>.esphome::sensor::Sensor::state', which is of non-class type 'float'
115 | it.printf(0, 16, id(font1), "%s", id(officehumid).state.c_str());
| ^~~~~
*** [.pioenvs/oled1/src/main.cpp.o] Error 1