Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- esphome:
- name: retro-tv
- platform: ESP8266
- board: d1_mini_pro
- # Enable logging
- logger:
- # Enable Home Assistant API
- api:
- ota:
- password: "12345"
- wifi:
- ssid: "TheVeryBestssid"
- password: "thisisnottheactualpasswordofcourse"
- fast_connect: true
- power_save_mode: none
- # Enable fallback hotspot (captive portal) in case wifi connection fails
- ap:
- ssid: "Tft Fallback Hotspot"
- password: "4321"
- captive_portal:
- font:
- - file: 'Moonrising.ttf'
- id: myfont1
- size: 15
- - file: 'Moonrising.ttf'
- id: myfont2
- size: 50
- - file: 'roboto.ttf'
- id: roboto_reg
- size: 15
- - file: '/config/esphome/fonts/materialdesignicons-webfont.ttf'
- id: icon_font_80
- size: 80
- glyphs: [
- "", # cloudy
- "", # fog
- "", # hail
- "", # lightning
- "", # partly cloudy
- "", # pouring
- "", # rainy
- "", # snowy
- "", # windy
- "", # lighning rainy
- "", # snowy rain
- "", # snowflake melt
- "", # snowflake
- "", # snowy heavy
- "", # partly snowy rainy
- "", # partly snowy
- "", # partly rainy
- "", # partly lightning
- "", # cloudy alert
- "", # sunny alert
- "", # snowflake alert
- "", # sunny
- "" # sunset
- ]
- color:
- - id: my_red
- red: 100%
- green: 0%
- blue: 0%
- - id: my_green
- red: 0%
- green: 100%
- blue: 0%
- - id: my_blue
- red: 0%
- green: 0%
- blue: 100%
- - id: my_white
- red: 100%
- green: 100%
- blue: 100%
- - id: my_yellow
- red: 0%
- green: 100%
- blue: 100%
- - id: my_grey
- red: 30%
- green: 30%
- blue: 30%
- - id: my_light_grey
- red: 70%
- green: 70%
- blue: 70%
- - id: my_orange
- red: 100%
- green: 65%
- blue: 0%
- - id: bar_color_down
- - id: bar_color_up
- - id: bar_color_out
- image:
- # - file: "/config/esphome/images/Boot_Grey.png"
- # id: boot_image
- # type: RGB24
- # resize: 128x128
- - file: "/config/esphome/images/face.png"
- id: face
- type: BINARY
- resize: 128x128
- spi:
- clk_pin: D5
- mosi_pin: D7
- sensor:
- - platform: wifi_signal
- id: wifi_dbm
- update_interval: 60s
- internal: true
- - platform: homeassistant
- entity_id: sensor.measured_temperature_1
- id: temp_outside
- internal: true
- - platform: homeassistant
- entity_id: sensor.measured_temperature_3
- id: temp_down
- internal: true
- - platform: homeassistant
- entity_id: sensor.measured_temperature_2
- id: temp_up
- internal: true
- text_sensor:
- - platform: homeassistant
- id: weather_icon
- entity_id: sensor.buienradar_symbol
- time:
- - platform: homeassistant
- id: esptime
- binary_sensor:
- - platform: gpio
- pin:
- number: D3
- mode: INPUT_PULLUP
- inverted: True
- internal: true
- name: thebutton
- on_press:
- - display.page.show_next: the_tft
- - platform: status
- name: "Retro TV"
- display:
- - platform: st7735
- model: "INITR_BLACKTAB" # INITR_GREENTAB - _REDTAB - _BLACKTAB - _MINI160X80 - _18BLACKTAB - _18REDTAB (default:INITR_18BLACKTAB )
- id: the_tft
- reset_pin: D2
- cs_pin: D8
- dc_pin: D1
- rotation: 90
- device_width: 128
- device_height: 160
- col_start: 0
- row_start: 0
- eight_bit_color: true
- update_interval: 5s
- use_bgr: false
- pages:
- - id: page1
- lambda: |-
- if (id(wifi_dbm).has_state()) {
- it.line(70,0,70,128);
- it.line(70,40,137,40);
- it.line(70,88,137,88);
- it.strftime(33, 4, id(myfont2), my_white, TextAlign::TOP_CENTER, "%H", id(esptime).now());
- it.strftime(33, 58, id(myfont2), my_yellow, TextAlign::TOP_CENTER, "%M", id(esptime).now());
- if (id(temp_down).has_state()) {
- it.printf(76, 8, id(myfont1), my_white, TextAlign::TOP_LEFT, "IN: %.0f°",id(temp_down).state);
- }
- if (id(temp_up).has_state()) {
- it.printf(76, 53, id(myfont1), my_white, TextAlign::TOP_LEFT, "UP: %.0f°",id(temp_up).state);
- }
- if (id(temp_outside).has_state()) {
- it.printf(76, 98, id(myfont1), my_green, TextAlign::TOP_LEFT, "OUT: %.0f°",id(temp_outside).state);
- }
- }else {
- //it.image(0, 0, id(boot_image));
- it.image(0, 0, id(face), id(my_light_grey));
- }
- - id: page2
- lambda: |-
- if (id(weather_icon).has_state()) {
- std::map<std::string, std::string> weather_state {
- { "Zwaar bewolkt", "" },
- { "Vrijwel onbewolkt (zonnig/helder)", "" },
- { "Mix van opklaringen en middelbare of lage bewolking", "" },
- { "Zwaar bewolkt en regen", "" },
- { "Vrijwel onbewolkt (zonnig/helder)", "" }
- };
- it.printf(64, 24, id(icon_font_80), my_white, TextAlign::TOP_CENTER, weather_state[id(weather_icon).state.c_str()].c_str());
- }
- - id: page3
- lambda: |-
- //color temp bar DOWN
- if ((id(temp_down).state) < 12) {
- bar_color_down = id(my_grey);
- } else if ((id(temp_down).state) < 16) {
- bar_color_down = id(my_blue);
- } else if ((id(temp_down).state) < 24) {
- bar_color_down = id(my_green);
- } else if ((id(temp_down).state) < 26) {
- bar_color_down = id(my_orange);
- } else {
- bar_color_down = id(my_red);
- }
- if ((id(temp_up).state) < 12) {
- bar_color_up = id(my_grey);
- } else if ((id(temp_up).state) < 16) {
- bar_color_up = id(my_blue);
- } else if ((id(temp_up).state) < 24) {
- bar_color_up = id(my_green);
- } else if ((id(temp_up).state) < 26) {
- bar_color_up = id(my_orange);
- } else {
- bar_color_up = id(my_red);
- }
- if ((id(temp_outside).state) < 12) {
- bar_color_out = id(my_grey);
- } else if ((id(temp_outside).state) < 16) {
- bar_color_out = id(my_blue);
- } else if ((id(temp_outside).state) < 24) {
- bar_color_out = id(my_green);
- } else if ((id(temp_outside).state) < 26) {
- bar_color_out = id(my_orange);
- } else {
- bar_color_out = id(my_red);
- }
- //grid
- it.rectangle(0, 0, 132, 128, my_grey);
- // bottom line = 0°
- it.line(5, 120, 127, 120, my_grey);
- // first line = 5°
- it.line(5, 105 ,127 , 105, my_grey);
- // 10°
- it.line(5, 90 ,127 , 90, my_grey);
- // 15°
- it.line(5, 75 ,127 , 75, my_grey);
- // 20°
- it.line(5, 60 ,127 , 60, my_grey);
- // 25°
- it.line(5, 45 ,127 , 45, my_grey);
- // 30°
- it.line(5, 30 ,127 , 30, my_grey);
- // 35°
- it.line(5, 15 ,127 , 15, my_grey);
- // 40°
- it.line(5, 0 ,127 , 0, my_grey);
- //outside temp bar graph
- int height = roundf(3 * (id(temp_outside).state));
- it.filled_rectangle(10, 128 - height, 30, height, bar_color_out);
- it.print(25, 108, id(roboto_reg), my_white, TextAlign::TOP_CENTER, "OUT");
- it.printf(25, 128 - height - 16, id(roboto_reg), my_white, TextAlign::TOP_CENTER, "%.0f°",id(temp_outside).state);
- //inside temp bar graph
- int heightIN = roundf(3 * (id(temp_down).state));
- it.filled_rectangle(50, 128 - heightIN, 30, heightIN, bar_color_down);
- it.print(65, 108, id(roboto_reg), my_white, TextAlign::TOP_CENTER, "IN");
- it.printf(65, 128 - heightIN - 16, id(roboto_reg), my_white, TextAlign::TOP_CENTER, "%.0f°",id(temp_down).state);
- //upstairs temp bar graph
- int heightUP = roundf(3 * (id(temp_up).state));
- it.filled_rectangle(90, 128 - heightUP, 30, heightUP, bar_color_up);
- it.print(105, 108, id(roboto_reg), my_white, TextAlign::TOP_CENTER, "UP");
- it.printf(105, 128 - heightUP - 16, id(roboto_reg), my_white, TextAlign::TOP_CENTER, "%.0f°",id(temp_up).state);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement