smalltv ultra를 추가 구입해 esphome으로 교체하고 날짜, 요일, 실외 온습도를 디스플레이에 출력.
기존 펌 web ui의 업로드 기능을 이용해 esphome으로 컴파일한 펌을 업로드해 교체.
** 재구매한 기기는 냉장고에 붙이는 마그네틱 화이트보드 캘린더를 위한 날짜확인 디스플레이
** 처음 구매한 기기도 ESPhome으로 펌 교체하고 HA 상태확인용 디스플레이로 고려중
esphome smalltv.yaml
substitutions:name: smalltv
esphome:
name: ${name}
area: Livingroom
esp8266:
board: esp12e
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: "${name} hotspot"
password: !secret wifi_password
captive_portal:
logger:
api:
ota:
- platform: esphome
password: !secret ota_password
external_components:
- source:
type: git
url: https://github.com/rletendu/esphome.git
ref: st7789_nobuffer_202312
components: [st7789v]
spi:
clk_pin: GPIO14
mosi_pin: GPIO13
interface: hardware
id: spihwd
time:
- platform: homeassistant
id: ha_time
on_time:
- seconds: 0
minutes: 0
hours: 0
then:
- component.update: disp
output:
- platform: esp8266_pwm
pin: GPIO05
frequency: 40 Hz
id: pwm_output
inverted: true
light:
- platform: monochromatic
output: pwm_output
name: "Backlight"
restore_mode: RESTORE_AND_ON
switch:
- platform: restart
name: "Restart"
sensor:
- platform: homeassistant
id: temp
entity_id: sensor.outdoor_thmeter_temperature
internal: true
on_value:
then:
- component.update: disp
- platform: homeassistant
id: humi
entity_id: sensor.outdoor_thmeter_humidity
internal: true
on_value:
then:
- component.update: disp
font:
- file: "gfonts://Monoton"
id: monoton
size: 40
glyphs: "! ./0123456789:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
- file: "gfonts://Monomaniac+One"
id: mono
size: 35
glyphs: "! %./0123456789:C°"
color:
- id: darkviolet
hex: 9400D3
- id: red
hex: FF0000
- id: orange
hex: FFA500
- id: yellow
hex: FFFF00
- id: green
hex: 008000
- id: blue
hex: 0000FF
- id: navy
hex: 000080
- id: purple
hex: 800080
display:
- platform: st7789v
model: "Custom"
spi_id: spihwd
height: 240
width: 240
offset_height: 0
offset_width: 0
dc_pin: GPIO00
reset_pin: GPIO02
eightbitcolor: True
update_interval: never
id: disp
spi_mode: mode3
lambda: |-
int center_x = it.get_width() / 2;
int center_y = it.get_height() / 2;
auto time = id(ha_time).now();
time_t time_t_value = time.timestamp;
struct tm *tm_info = localtime(&time_t_value);
int weekday = tm_info->tm_wday;
Color weekday_color;
switch (weekday) {
case 1:
weekday_color = id(red);
break;
case 2:
weekday_color = id(orange);
break;
case 3:
weekday_color = id(yellow);
break;
case 4:
weekday_color = id(green);
break;
case 5:
weekday_color = id(blue);
break;
case 6:
weekday_color = id(navy);
break;
case 0:
default:
weekday_color = id(purple);
break;
}
char buf_date[16];
strftime(buf_date, sizeof(buf_date), "%y/%m/%d", localtime(&time_t_value));
it.printf(center_x, 10, id(monoton), TextAlign::TOP_CENTER, buf_date);
char buf_wday[4];
strftime(buf_wday, sizeof(buf_wday), "%a", localtime(&time_t_value));
it.printf(center_x, 55, id(monoton), weekday_color, TextAlign::TOP_CENTER, buf_wday);
it.printf(center_x, center_y + 80, id(mono), id(darkviolet), TextAlign::CENTER, "%.1f°C / %.1f%%", id(temp).state, id(humi).state);