- 积分
- 631
- 金钱
- 554
- 威望
- 0
- 贡献
- 0
- HASS币
- 0
高级会员
- 积分
- 631
- 金钱
- 554
- HASS币
- 0
|
我想在esp32上的显示器可以显示homeassistant里其他信息 用esphome
目前配置是这样的
sensor:
- platform: homeassistant
entity_id: sensor.bedroom_humidity
id : id_bedroom_humidity
internal: true
- platform: homeassistant
entity_id: sensor.bedroom_temperature
id : id_bedroom_temperature
internal: true
binary_sensor:
- platform: homeassistant
entity_id: light.bedroom_light_1
id : id_bedroom_light_1
internal: true
- platform: status
name: "Node Status"
id: system_status
switch:
- platform: gpio
pin: GPIO4
name: "Backlight"
id: backlight
spi:
clk_pin: GPIO18
mosi_pin: GPIO19
display:
- platform: st7789v
backlight_pin: GPIO4
cs_pin: GPIO5
dc_pin: GPIO16
reset_pin: GPIO23
rotation: 270
id: ttdisplay
pages:
- id: page1
lambda: |-
it.printf(50, 75, id(helvetica_24), id(my_yellow), TextAlign::CENTER, "%.1f%%", id(id_bedroom_humidity).state);
it.printf(50, 95, id(helvetica_24), id(my_yellow), TextAlign::CENTER, "%.1f°" , id(id_bedroom_temperature).state);
if (id(id_bedroom_light_1).state){
it.printf(100, 115, id(helvetica_24), id(my_yellow), TextAlign::CENTER,"Light State: ON");
}
else {
it.printf(100, 115, id(helvetica_24), id(my_yellow), TextAlign::CENTER,"Light State: OFF");
}
if (id(system_status).state) {
it.print(235, 5, id(helvetica_12), id(my_green), TextAlign::TOP_RIGHT, "Online");
}
else {
it.print(235, 5, id(helvetica_12), id(my_red), TextAlign::TOP_RIGHT, "Offline");
}
- id: page2
lambda: |-
it.image(0, 0, id(my_image));
关键是这两行
it.printf(50, 75, id(helvetica_24), id(my_yellow), TextAlign::CENTER, "%.1f%%", id(id_bedroom_humidity).state);
it.printf(50, 95, id(helvetica_24), id(my_yellow), TextAlign::CENTER, "%.1f°" , id(id_bedroom_temperature).state);
我只需要整数 然后我写成%d 屏幕上就显示很长一串数字 %.1f 是可以正常显示 但是总有个零
顺便问下有没有现成的显示各种数据的例子 因为我以后可能还要显示其他的数据
比如 温度湿度啊 监控的情况啊 报警啊之类的
|
|