Advertisement
GozuMezu

retrotv full yaml

Aug 30th, 2021
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 8.48 KB | None | 0 0
  1. esphome:
  2.   name: retro-tv
  3.   platform: ESP8266
  4.   board: d1_mini_pro
  5.  
  6. # Enable logging
  7. logger:
  8. # Enable Home Assistant API
  9. api:
  10. ota:
  11.   password: "12345"
  12.  
  13. wifi:
  14.   ssid: "TheVeryBestssid"
  15.   password: "thisisnottheactualpasswordofcourse"
  16.   fast_connect: true
  17.   power_save_mode: none
  18.  
  19.  
  20.   # Enable fallback hotspot (captive portal) in case wifi connection fails
  21.   ap:
  22.     ssid: "Tft Fallback Hotspot"
  23.     password: "4321"
  24.  
  25. captive_portal:
  26. font:
  27.   - file: 'Moonrising.ttf'
  28.     id: myfont1
  29.     size: 15
  30.   - file: 'Moonrising.ttf'
  31.     id: myfont2
  32.     size: 50
  33.   - file: 'roboto.ttf'
  34.     id: roboto_reg
  35.     size: 15
  36.   - file: '/config/esphome/fonts/materialdesignicons-webfont.ttf'
  37.     id: icon_font_80
  38.     size: 80
  39.     glyphs: [
  40.       "󰖐", # cloudy
  41.       "󰖑", # fog
  42.       "󰖒", # hail
  43.       "󰖓", # lightning
  44.       "󰖕", # partly cloudy
  45.       "󰖖", # pouring
  46.       "󰖗", # rainy
  47.       "󰖘", # snowy
  48.       "󰖝", # windy
  49.       "󰙾", # lighning rainy
  50.       "󰙿", # snowy rain
  51.       "󱋋", # snowflake melt
  52.       "󰜗", # snowflake
  53.       "󰼶", # snowy heavy
  54.       "󰼵", # partly snowy rainy
  55.       "󰼴", # partly snowy
  56.       "󰼳", # partly rainy
  57.       "󰼲", # partly lightning
  58.       "󰼯", # cloudy alert
  59.       "󰼷", # sunny alert
  60.       "󰼩", # snowflake alert
  61.       "󰖙", # sunny
  62.       "󰖚" # sunset
  63.       ]
  64.    
  65. color:
  66.   - id: my_red
  67.     red: 100%
  68.     green: 0%
  69.     blue: 0%
  70.   - id: my_green
  71.     red: 0%
  72.     green: 100%
  73.     blue: 0%
  74.   - id: my_blue
  75.     red: 0%
  76.     green: 0%
  77.     blue: 100%
  78.   - id: my_white
  79.     red: 100%
  80.     green: 100%
  81.     blue: 100%
  82.   - id: my_yellow
  83.     red: 0%
  84.     green: 100%
  85.     blue: 100%
  86.   - id: my_grey
  87.     red: 30%
  88.     green: 30%
  89.     blue: 30%
  90.   - id: my_light_grey
  91.     red: 70%
  92.     green: 70%
  93.     blue: 70%
  94.   - id: my_orange
  95.     red: 100%
  96.     green: 65%
  97.     blue: 0%
  98.   - id: bar_color_down
  99.   - id: bar_color_up
  100.   - id: bar_color_out
  101.    
  102. image:
  103. #  - file: "/config/esphome/images/Boot_Grey.png"
  104. #    id: boot_image
  105. #    type: RGB24
  106. #    resize: 128x128
  107.   - file: "/config/esphome/images/face.png"
  108.     id: face
  109.     type: BINARY
  110.     resize: 128x128
  111.    
  112. spi:
  113.   clk_pin: D5
  114.   mosi_pin: D7
  115.    
  116. sensor:
  117.   - platform: wifi_signal
  118.     id: wifi_dbm
  119.     update_interval: 60s
  120.     internal: true
  121.   - platform: homeassistant
  122.     entity_id: sensor.measured_temperature_1
  123.     id: temp_outside
  124.     internal: true
  125.   - platform: homeassistant
  126.     entity_id: sensor.measured_temperature_3
  127.     id: temp_down
  128.     internal: true
  129.   - platform: homeassistant
  130.     entity_id: sensor.measured_temperature_2
  131.     id: temp_up
  132.     internal: true
  133.  
  134. text_sensor:  
  135.   - platform: homeassistant
  136.     id: weather_icon
  137.     entity_id: sensor.buienradar_symbol
  138.    
  139. time:
  140.   - platform: homeassistant
  141.     id: esptime
  142.    
  143. binary_sensor:
  144.   - platform: gpio
  145.     pin:
  146.       number: D3
  147.       mode: INPUT_PULLUP
  148.       inverted: True
  149.     internal: true
  150.     name: thebutton
  151.     on_press:
  152.       - display.page.show_next: the_tft
  153.   - platform: status
  154.     name: "Retro TV"
  155.  
  156. display:
  157.   - platform: st7735
  158.     model: "INITR_BLACKTAB" # INITR_GREENTAB - _REDTAB - _BLACKTAB - _MINI160X80 - _18BLACKTAB - _18REDTAB (default:INITR_18BLACKTAB )
  159.     id: the_tft
  160.     reset_pin: D2
  161.     cs_pin: D8
  162.     dc_pin: D1
  163.     rotation: 90
  164.     device_width: 128
  165.     device_height: 160
  166.     col_start: 0
  167.     row_start: 0
  168.     eight_bit_color: true
  169.     update_interval: 5s
  170.     use_bgr: false
  171.  
  172.     pages:
  173.       - id: page1
  174.         lambda: |-
  175.           if (id(wifi_dbm).has_state()) {
  176.  
  177.              it.line(70,0,70,128);
  178.              it.line(70,40,137,40);
  179.              it.line(70,88,137,88);
  180.              
  181.          
  182.              it.strftime(33, 4, id(myfont2), my_white, TextAlign::TOP_CENTER, "%H", id(esptime).now());
  183.              it.strftime(33, 58, id(myfont2), my_yellow, TextAlign::TOP_CENTER, "%M", id(esptime).now());
  184.          
  185.              if (id(temp_down).has_state()) {
  186.                it.printf(76, 8, id(myfont1), my_white, TextAlign::TOP_LEFT, "IN: %.0f°",id(temp_down).state);
  187.              }
  188.              if (id(temp_up).has_state()) {
  189.                it.printf(76, 53, id(myfont1), my_white, TextAlign::TOP_LEFT, "UP: %.0f°",id(temp_up).state);
  190.              }
  191.              if (id(temp_outside).has_state()) {
  192.                it.printf(76, 98, id(myfont1), my_green, TextAlign::TOP_LEFT, "OUT: %.0f°",id(temp_outside).state);
  193.              }
  194.      
  195.           }else {
  196.             //it.image(0, 0, id(boot_image));
  197.             it.image(0, 0, id(face), id(my_light_grey));
  198.           }
  199.          
  200.       - id: page2
  201.         lambda: |-
  202.           if (id(weather_icon).has_state()) {
  203.               std::map<std::string, std::string> weather_state {
  204.                   { "Zwaar bewolkt", "󰖐" },
  205.                   { "Vrijwel onbewolkt (zonnig/helder)", "󰖙" },
  206.                   { "Mix van opklaringen en middelbare of lage bewolking", "󰖕" },
  207.                   { "Zwaar bewolkt en regen", "󰖗" },
  208.                   { "Vrijwel onbewolkt (zonnig/helder)", "󰖙" }
  209.               };
  210.               it.printf(64, 24, id(icon_font_80), my_white, TextAlign::TOP_CENTER, weather_state[id(weather_icon).state.c_str()].c_str());
  211.           }
  212.  
  213.       - id: page3
  214.         lambda: |-
  215.          
  216.           //color temp bar DOWN
  217.           if ((id(temp_down).state) < 12) {
  218.             bar_color_down = id(my_grey);
  219.           } else if ((id(temp_down).state) < 16) {
  220.             bar_color_down = id(my_blue);
  221.           } else if ((id(temp_down).state) < 24) {
  222.             bar_color_down = id(my_green);
  223.           } else if ((id(temp_down).state) < 26) {
  224.             bar_color_down = id(my_orange);
  225.           } else {
  226.             bar_color_down = id(my_red);
  227.           }
  228.          
  229.           if ((id(temp_up).state) < 12) {
  230.             bar_color_up = id(my_grey);
  231.           } else if ((id(temp_up).state) < 16) {
  232.             bar_color_up = id(my_blue);
  233.           } else if ((id(temp_up).state) < 24) {
  234.             bar_color_up = id(my_green);
  235.           } else if ((id(temp_up).state) < 26) {
  236.             bar_color_up = id(my_orange);
  237.           } else {
  238.             bar_color_up = id(my_red);
  239.           }
  240.          
  241.           if ((id(temp_outside).state) < 12) {
  242.             bar_color_out = id(my_grey);
  243.           } else if ((id(temp_outside).state) < 16) {
  244.             bar_color_out = id(my_blue);
  245.           } else if ((id(temp_outside).state) < 24) {
  246.             bar_color_out = id(my_green);
  247.           } else if ((id(temp_outside).state) < 26) {
  248.             bar_color_out = id(my_orange);
  249.           } else {
  250.             bar_color_out = id(my_red);
  251.           }
  252.          
  253.           //grid
  254.           it.rectangle(0, 0, 132, 128, my_grey);
  255.           // bottom line = 0°
  256.           it.line(5, 120, 127, 120, my_grey);
  257.           // first line = 5°
  258.           it.line(5, 105 ,127 , 105, my_grey);
  259.           // 10°
  260.           it.line(5, 90 ,127 , 90, my_grey);
  261.           // 15°
  262.           it.line(5, 75 ,127 , 75, my_grey);
  263.           // 20°
  264.           it.line(5, 60 ,127 , 60, my_grey);
  265.           // 25°
  266.           it.line(5, 45 ,127 , 45, my_grey);
  267.           // 30°
  268.           it.line(5, 30 ,127 , 30, my_grey);
  269.           // 35°
  270.           it.line(5, 15 ,127 , 15, my_grey);
  271.           // 40°
  272.           it.line(5, 0 ,127 , 0, my_grey);
  273.          
  274.           //outside temp bar graph
  275.           int height = roundf(3 * (id(temp_outside).state));
  276.           it.filled_rectangle(10, 128 - height, 30, height, bar_color_out);
  277.           it.print(25, 108, id(roboto_reg), my_white, TextAlign::TOP_CENTER, "OUT");
  278.           it.printf(25, 128 - height - 16, id(roboto_reg), my_white, TextAlign::TOP_CENTER, "%.0f°",id(temp_outside).state);
  279.          
  280.           //inside temp bar graph
  281.           int heightIN = roundf(3 * (id(temp_down).state));
  282.           it.filled_rectangle(50, 128 - heightIN, 30, heightIN, bar_color_down);
  283.           it.print(65, 108, id(roboto_reg), my_white, TextAlign::TOP_CENTER, "IN");
  284.           it.printf(65, 128 - heightIN - 16, id(roboto_reg), my_white, TextAlign::TOP_CENTER, "%.0f°",id(temp_down).state);
  285.  
  286.           //upstairs temp bar graph
  287.           int heightUP = roundf(3 * (id(temp_up).state));
  288.           it.filled_rectangle(90, 128 - heightUP, 30, heightUP, bar_color_up);
  289.           it.print(105, 108, id(roboto_reg), my_white, TextAlign::TOP_CENTER, "UP");
  290.           it.printf(105, 128 - heightUP - 16, id(roboto_reg), my_white, TextAlign::TOP_CENTER, "%.0f°",id(temp_up).state);
  291.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement