Files
hassos_config/esphome/cfg_experimental/wekker.yaml
2024-04-10 14:49:07 +02:00

200 lines
4.9 KiB
YAML

substitutions:
device_name: "wekker"
friendly_name: "wekker"
comment: "esp32, lcd wt32-sc01"
location: "slaaplamer"
api_password: !secret wekker_api
ota_password: !secret ota_password
wifi_ssid: !secret wifi_ssid
wifi_password: !secret wifi_password
ip: !secret wekker_ip
gateway: !secret ip_gateway
subnet: !secret ip_subnet
id_prefix: wekker
pin_lcd_bl: GPIO23
pin_clk: GPIO14
pin_mosi: GPIO13
pin_miso: GPIO12
pin_cs: GPIO15
pin_dc: GPIO21
pin_lcdrst: GPIO22
pin_sda: GPIO18
pin_scl: GPIO19
pin_rotsw: GPIO33
pin_rotA: GPIO32
pin_rotB: GPIO27
#datasheet: https://files.seeedstudio.com/products/102991455/WT32-SC01-datasheet.pdf
packages:
board: !include boards/esp32_wrover.yaml
i2c: !include interfaces/i2c_a.yaml
spi: !include interfaces/spi.yaml
connection: !include common/wifi.yaml
device_base: !include common/common.yaml
time: !include templates/time.yaml
logger: !include templates/logger.yaml
backlight: !include templates/backlight.yaml
color: !include templates/color.yaml
touch: !include templates/touchscreen_ft63x6.yaml
sensor:
- platform: rotary_encoder
name: "Rotary Encoder"
id: rotary
pin_a: ${pin_rotA}
pin_b: ${pin_rotB}
on_anticlockwise:
- if:
condition:
display.is_displaying_page: menu
then:
- display_menu.down: menu_disp
else:
- number.increment:
id: num_bright
cycle: false
on_clockwise:
- if:
condition:
display.is_displaying_page: menu
then:
- display_menu.up: menu_disp
else:
- number.decrement:
id: num_bright
cycle: false
image:
- file: "include/4dir.jpg"
id: multidir
resize: 150x150
number:
- platform: template
id: num_bright
optimistic: true
min_value: 0.05
max_value: 1
step: 0.05
on_value:
then:
# lambda: |-
# ESP_LOGI("number", "new brightness value: %f", x);
- light.control:
id: backlight
brightness: !lambda "return x;"
transition_length: 0.1s
binary_sensor:
- platform: gpio
pin:
number: ${pin_rotsw}
inverted: true
name: "rotary select"
id: rotary_button
filters:
- delayed_on: 10ms
- delayed_off: 30ms
on_press:
- if:
condition:
display.is_displaying_page: menu
then:
- if:
condition:
display_menu.is_active: menu_disp
then:
- display_menu.enter: menu_disp
else:
- display_menu.show: menu_disp
on_double_click:
then:
- display.page.show: flipclock
- platform: touchscreen
name: menu
x_min: 380
x_max: 480
y_min: 280
y_max: 320
page_id: flipclock
on_click:
then:
- display.page.show: menu
- display_menu.show:
font:
- file: 'fonts/Solari.ttf'
id: flipper
size: 160
glyphs: ['-',' ', '°', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'C',':']
- file:
type: gfonts
family: Roboto
size: 40
id: menu_font
# - file:
# type: gfonts
# family: Roboto
# size: 30
# id: dir_font
# glyphs: ['U','p', 'D', 'o', 'w', 'n', 'L', 'e', 'f', 't', 'R', 'i', 'g', 'h']
display:
- platform: ili9xxx
id: ${id_prefix}_display
model: ST7796
cs_pin: ${pin_cs}
dc_pin: ${pin_dc}
reset_pin: ${pin_lcdrst}
rotation: 270
pages:
- id: flipclock
lambda: |-
it.strftime(0, 80, id(flipper), TextAlign::TOP_LEFT, "%H:%M", id(homeassistant_time).now());
// it.filled_rectangle(360, 250, 470, 310, id(green));
// it.printf(365,255, id(menu_font), id(black), TextAlign::TOP_LEFT, "Menu");
// it.image(210,370, id(multidir));
- id: menu
lambda: |-
const auto display_width = it.get_width();
const auto display_height = it.get_height();
//it.filled_rectangle(360, 250, 470, 310, id(green));
//it.printf(365,255, id(menu_font), id(black), TextAlign::TOP_LEFT, "Exit");
// Arguments: it.menu(x, y, menu, width, height);
it.menu(0, 60, id(menu_disp), display_width/2, 150);
#https://www.esphome.io/components/display_menu/graphical_display_menu.html?highlight=graphical_display_menu
graphical_display_menu:
id: menu_disp
font: menu_font
display: ${id_prefix}_display
on_redraw:
then:
component.update: ${id_prefix}_display
on_leave:
then:
- display.page.show: flipclock
- lambda: 'ESP_LOGI("display_menu", "switch leave: %s, %s", it->get_text().c_str(), it->get_value_text().c_str());'
active: false
mode: rotary
items:
- type: number
text: Brightness
number: num_bright
- type: Label
text: Alarm
- type: back
text: Back