User Tools

Site Tools


technical:cyd

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

technical:cyd [2024/10/12 21:59] – created wikiadmintechnical:cyd [2026/08/03 16:48] (current) – removed - external edit (Unknown date) 127.0.0.1
Line 1: Line 1:
-====== CYD Configuration ====== 
  
-<code> 
-# 
-# Basic yaml code to get the ESP32-2432S028R display to work in ESPHome. 
-# 
-# This yaml displays two rectangles acting as binary touch sensors inside of Home Assistant. 
-# 
-# Written by Jonny Bergdahl 
-# - [GitHub](https://github.com/jonnybergdahl) 
-# - [Twitter](https://twitter.com/jonnybergdahl) 
-# - [YouTube](https://www.youtube.com/jonnybergdahl) 
-# 
-# ============================================================  
-# NOTE: 
-# In order for this to work you need to add the following settings in your secrets.yaml file: 
-# - api_key 
-# - ota_password 
-# - wifi_ssid 
-# - wifi_password 
-# - ap_password 
-# 
-# Create a folder named fonts in your ESPHome folder, and copy the file fonts/Arimo-Regular.ttf there. 
-# 
-# ============================================================  
-# Example file setup 
-# Change the naming below, they will be the names used in Home Assistant 
-# 
-# ============================================================  
-# Standard ESPHome setup 
-# 
-# ESPHome naming 
-esphome: 
-  name: cyd 
-  friendly_name: CYD 
-  
-# The ESP32-2432S028R uses a standard ESP32-WROVER, so we use the esp32dev defintion 
-esp32: 
-  board: esp32dev 
-  framework: 
-    type: arduino 
- 
-# Enable logging 
-logger: 
- 
-api: 
-  encryption: 
-    key: "liTEJ0FCvCcLx2koSxcFyV8sBcrQL1B0vrXXUyV2Kxo=" 
- 
-ota: 
-  - platform: esphome 
-    password: "4c4067c4ac00225338762d3aab3be7dc" 
- 
-# Setup WiFi credentials 
-wifi: 
-  ssid: !secret wifi_ssid 
-  password: !secret wifi_password 
-  fast_connect: true 
-  domain: .scottworld.net 
- 
-  # Enable fallback hotspot (captive portal) in case wifi connection fails 
-  ap: 
-    ssid: "CYD" 
-    password: "12345678" 
- 
-captive_portal: 
- 
-# ============================================================  
-# ESPHome Display related setup 
-# 
-# Create a font to use, add and remove glyphs as needed.  
-font: 
-  - file: 'fonts/Arimo-Regular.ttf' 
-    id: arimo24 
-    size: 24 
-    glyphs: "!\"%()+=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ abcdefghijklmnopqrstuvwxyzåäö" 
-  - file: 'fonts/Arimo-Regular.ttf' 
-    id: arimo96 
-    size: 96 
-    glyphs: "0123456789.p-:Misedw" 
- 
-# Create a Home Assistant blue color 
-color: 
-  - id: ha_black 
-    red_int: 0 
-    green_int: 0 
-    blue_int: 0 
-    white_int: 0 
- 
-# Create an ESPHome logo image 
-#image: 
-#  - file: "images/esphome.png" 
-#    id: esphome_image 
-#    type: RGB24 
- 
-# ============================================================  
-# Home Assistant related setup 
-# 
-light: 
-  - platform: monochromatic 
-    output: backlight_pwm 
-    name: Display Backlight 
-    id: backlight 
-    restore_mode: ALWAYS_ON 
- 
-# Set up LED on the back and turn it off by default 
-  - platform: rgb 
-    name: RGB 
-    id: led 
-    red: led_red 
-    green: led_green 
-    blue: led_blue 
-    restore_mode: ALWAYS_OFF 
- 
-# get entity  
-sensor: 
-  - platform: homeassistant 
-    id: current_rate_E 
-    entity_id: sensor.octopus_energy_electricity_17p7123488_2000016180455_current_rate 
-  - platform: homeassistant 
-    id: next_rate_E 
-    entity_id: sensor.octopus_energy_electricity_17p7123488_2000016180455_next_rate 
-  - platform: homeassistant 
-    id: cheapest_electricity_cost 
-    entity_id: binary_sensor.octopus_energy_target_cheapest_electricity 
-    attribute: next_average_cost 
-  - platform: homeassistant 
-    id: current_electric_usage 
-    entity_id: sensor.envoy_122041077530_current_power_consumption 
- 
-text_sensor: 
-  - platform: homeassistant 
-    id: cheapest_electricity_time 
-    entity_id: sensor.cheapest_elect_time 
- 
-# ============================================================  
-# Hardware related setup 
-# 
-# Setup SPI for the display. The ESP32-2432S028R uses separate SPI buses for display and touch 
-spi: 
-  - id: tft 
-    clk_pin: GPIO14 
-    mosi_pin: GPIO13 
-    miso_pin: GPIO12 
-#  - id: touch 
-#    clk_pin: GPIO25 
-#    mosi_pin: GPIO32 
-#    miso_pin: GPIO39 
- 
-# Setup a pin to control the backlight 
-output: 
-  - platform: ledc 
-    pin: GPIO21 
-    id: backlight_pwm 
- 
-# Setup channels for the red/green/blue of the LED on the back 
-  - platform: ledc 
-    pin: GPIO4 
-    id: led_red 
-    inverted: true 
-  - platform: ledc 
-    pin: GPIO16 
-    id: led_green 
-    inverted: true 
-  - platform: ledc 
-    pin: GPIO17 
-    id: led_blue 
-    inverted: true 
- 
-# Setup the ili9xxx platform 
-# 
-# Display is used as 240x320 by default so we rotate it to 90° 
-# 
-# We print date and time wth the strftime() function, see the ESPHome documentation to  
-# format date and atime to your locale. 
-# 
-display: 
-  - platform: ili9xxx 
-    model: ILI9341 
-    id: cyd 
-    invert_colors: false 
-    update_interval: 30s 
-    spi_id: tft 
-    cs_pin: GPIO15 
-    dc_pin: GPIO2 
-    dimensions: 
-      height: 240 
-      width: 320 
-    color_order: rgb 
-    #rotation: 90 
- 
- 
-    pages: 
-      - id: page1 
-        lambda: |- 
-          float cre = id(current_rate_E).state * 100; 
-          int rate_color = 65280; 
-          if (cre > 20) { 
-            rate_color = 16711680; 
-          }  
-          else if (cre > 10) { 
-            rate_color = 16753920; 
-          } 
-          it.fill(id(ha_black)); 
-          it.print(160, 20, id(arimo24), COLOR_ON, TextAlign::CENTER, "Current Electric Price", COLOR_OFF);       
-          it.printf(160,120, id(arimo96), Color(rate_color), COLOR_OFF, display::TextAlign::CENTER, "%.1fp", id(current_rate_E).state * 100); 
-      - id: page2 
-        lambda: |- 
-          float nre = id(next_rate_E).state * 100; 
-          int rate_color = 65280; 
-          if (nre > 20) { 
-            rate_color = 16711680; 
-          }  
-          else if (nre > 10) { 
-            rate_color = 16753920; 
-          } 
-          it.fill(id(ha_black)); 
-          it.print(160, 20, id(arimo24), Color(255,255,0), TextAlign::CENTER, "Next Electric Price", COLOR_OFF);       
-          it.printf(160,120, id(arimo96), Color(rate_color), COLOR_OFF, display::TextAlign::CENTER, "%.1fp", id(next_rate_E).state * 100); 
-      - id: page3 
-        lambda: |- 
-          it.fill(id(ha_black)); 
-          it.print(160, 20, id(arimo24), Color(255,0,255), TextAlign::CENTER, "Cheapest Electric Price", COLOR_OFF); 
-          if (id(cheapest_electricity_time).state == "unavailable"){ 
-            it.print(160, 120, id(arimo96), Color(255,0,0), TextAlign::CENTER, "Missed", COLOR_OFF); 
-          } 
-          else { 
-            it.printf(160,90, id(arimo96), COLOR_ON, COLOR_OFF, display::TextAlign::CENTER, "%s", id(cheapest_electricity_time).state.c_str()); 
-            it.printf(160,190, id(arimo96), COLOR_ON, COLOR_OFF, display::TextAlign::CENTER, "%.1fp", id(cheapest_electricity_cost).state * 100);   
-          }          
-      - id: page4 
-        lambda: |- 
-          it.fill(id(ha_black)); 
-          it.print(160, 20, id(arimo24), Color(0,0,255), TextAlign::CENTER, "Current Electric Usage", COLOR_OFF); 
-          float ceu = id(current_electric_usage).state; 
-          int rate_color = 65280; 
-          if (ceu > 5000) { 
-            rate_color = 16711680; 
-          }  
-          else if (ceu > 1500) { 
-            rate_color = 16753920; 
-          } 
-          it.printf(160,120, id(arimo96), Color(rate_color), COLOR_OFF, display::TextAlign::CENTER, "%.0fw", id(current_electric_usage).state); 
- 
- 
-interval: 
-  - interval: 5s 
-    then: 
-      - display.page.show_next: cyd 
-      - component.update: cyd 
-</code> 

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki