Advertisement
Guest User

Lvgl esphome

a guest
Jul 18th, 2024
1,764
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.17 KB | None | 0 0
  1. esphome:
  2. name: bathroom_display
  3. friendly_name: Display
  4.  
  5. esp32:
  6. board: esp32dev
  7. framework:
  8. type: arduino
  9.  
  10.  
  11. # Enable logging
  12. logger:
  13.  
  14. external_components:
  15. - source: github://clydebarrow/esphome@lvgl
  16. refresh: 10min
  17. components: [lvgl]
  18.  
  19. # Enable Home Assistant API
  20. api:
  21. encryption:
  22. key: "xxxx"
  23. on_client_connected:
  24. - if:
  25. condition:
  26. lambda: 'return (0 == client_info.find("Home Assistant"));'
  27. then:
  28. - lvgl.widget.show: lbl_hastatus
  29. on_client_disconnected:
  30. - if:
  31. condition:
  32. lambda: 'return (0 == client_info.find("Home Assistant"));'
  33. then:
  34. - lvgl.widget.hide: lbl_hastatus
  35.  
  36. ota:
  37. - platform: esphome
  38.  
  39.  
  40. wifi:
  41. ssid: !secret wifi_ssid
  42. password: !secret wifi_password
  43. fast_connect: True
  44. manual_ip:
  45. static_ip: 192.xxx
  46. gateway: 192.xxx
  47. subnet: 255.255.255.0
  48.  
  49. # Enable fallback hotspot (captive portal) in case wifi connection fails
  50. ap:
  51. ssid: "Esphome-Web-9B75D8"
  52. password: "xxx"
  53.  
  54. captive_portal:
  55.  
  56. i2c:
  57. sda: GPIO21
  58. scl: GPIO22
  59. scan: true
  60. frequency: 10kHz
  61.  
  62.  
  63.  
  64. uart:
  65. - id: uart_1
  66. rx_pin: GPIO25
  67. tx_pin: GPIO27
  68. baud_rate: 115200
  69. parity: NONE
  70. stop_bits: 1
  71. spi:
  72. clk_pin: GPIO18
  73. mosi_pin: GPIO23
  74. miso_pin: GPIO19
  75.  
  76. # Define a PWM output on the ESP32
  77. output:
  78. - platform: ledc
  79. pin: GPIO0
  80. id: gpio_32_backlight_pwm
  81. frequency: 100Hz
  82.  
  83. # Define a monochromatic, dimmable light for the backlight
  84. light:
  85. - platform: monochromatic
  86. output: gpio_32_backlight_pwm
  87. name: "Bathroom Display Backlight"
  88. id: back_light
  89. restore_mode: ALWAYS_ON
  90.  
  91. ld2420:
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99. number:
  100. - platform: ld2420
  101. presence_timeout:
  102. name: Detection Presence Timeout
  103. min_gate_distance:
  104. name: Detection Gate Minimum
  105. max_gate_distance:
  106. name: Detection Gate Maximum
  107. # See "Number" section below for detail
  108. gate_select:
  109. name: Select Gate to Set
  110. still_threshold:
  111. name: Set Still Threshold Value
  112. move_threshold:
  113. name: Set Move Threshold Value
  114. gate_move_sensitivity:
  115. name: Move Calibration Sensitivity Factor
  116. gate_still_sensitivity:
  117. name: Still Calibration Sensitivity Factor
  118.  
  119. button:
  120. - platform: ld2420
  121. apply_config:
  122. name: Apply Config
  123. factory_reset:
  124. name: Factory Reset
  125. restart_module:
  126. name: Restart Module
  127. revert_config:
  128. name: Undo Edits
  129.  
  130. select:
  131. - platform: ld2420
  132. operating_mode:
  133. name: Operating Mode
  134.  
  135.  
  136.  
  137. touchscreen:
  138. platform: xpt2046
  139. id: my_touchscreen
  140. cs_pin: GPIO17
  141. #interrupt_pin: 16
  142. update_interval: 50ms
  143. threshold: 400
  144. calibration:
  145. x_min: 351
  146. x_max: 3762
  147. y_min: 215
  148. y_max: 3644
  149.  
  150. transform:
  151. swap_xy: true
  152. mirror_x: false
  153. mirror_y: false
  154.  
  155. on_touch:
  156. - lambda: |-
  157. ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
  158. touch.x,
  159. touch.y,
  160. touch.x_raw,
  161. touch.y_raw
  162. );
  163.  
  164. display:
  165.  
  166. - platform: ili9xxx
  167. id: my_display
  168. model: ST7789V
  169. #color_order: rgb
  170. cs_pin: GPIO26 #display CS
  171. update_interval: never
  172. auto_clear_enabled: false
  173. dc_pin: GPIO5 #display DC
  174. dimensions:
  175. width: 320
  176. height: 240
  177. reset_pin: GPIO15 #display RESET
  178. #rotation: 90
  179. data_rate: 40MHz
  180. show_test_card: false
  181. transform:
  182. swap_xy: true
  183. mirror_x: true
  184. mirror_y: false
  185.  
  186.  
  187.  
  188.  
  189. font:
  190. - file: "gfonts://Gabarito@700"
  191. id: gabarito50
  192. size: 50
  193. bpp: 4
  194. extras:
  195. - file: 'fonts/materialdesignicons-webfont.ttf' # http://materialdesignicons.com/cdn/7.4.47/
  196. glyphs: [
  197. "\U000F004B",
  198. "\U0000f0ed",
  199. "\U000F006E",
  200. "\U000F012C",
  201. "\U000F179B",
  202. "\U000F0748",
  203. "\U000F1A1B",
  204. "\U000F02DC",
  205. "\U000F0A02",
  206. "\U000F035F",
  207. "\U000F0156",
  208. "\U000F0C5F",
  209. "\U000f0084",
  210. "\U000f0091",
  211. ]
  212. - file: "gfonts://Gabarito@700"
  213. id: gabarito40
  214. size: 40
  215. bpp: 4
  216. - file: "gfonts://Gabarito@700"
  217. id: gabarito15
  218. size: 15
  219. bpp: 4
  220. - file: "gfonts://Gabarito@700"
  221. id: gabarito30
  222. size: 30
  223. bpp: 4
  224. - file: 'fonts/materialdesignicons-webfont.ttf' # http://materialdesignicons.com/cdn/7.4.47/
  225. id: weather70
  226. size: 70
  227. bpp: 4
  228. glyphs: &mdi-weather-glyphs
  229. - "\U000F0590" # mdi-weather-cloudy
  230. - "\U000F0F2F" # mdi-weather-cloudy-alert
  231. - "\U000F0E6E" # mdi-weather-cloudy-arrow-right
  232. - "\U000F0591" # mdi-weather-fog
  233. - "\U000F0592" # mdi-weather-hail
  234. - "\U000F0F30" # mdi-weather-hazy
  235. - "\U000F0898" # mdi-weather-hurricane
  236. - "\U000F0593" # mdi-weather-lightning
  237. - "\U000F067E" # mdi-weather-lightning-rainy
  238. - "\U000F0594" # mdi-weather-clear-night
  239. - "\U000F0F31" # mdi-weather-night-partly-cloudy
  240. - "\U000F0595" # mdi-weather-partly-cloudy
  241. - "\U000F0F32" # mdi-weather-partly-lightning
  242. - "\U000F0F33" # mdi-weather-partly-rainy
  243. - "\U000F0F34" # mdi-weather-partly-snowy
  244. - "\U000F0F35" # mdi-weather-partly-snowy-rainy
  245. - "\U000F0596" # mdi-weather-pouring
  246. - "\U000F0597" # mdi-weather-rainy
  247. - "\U000F0598" # mdi-weather-snowy
  248. - "\U000F0F36" # mdi-weather-snowy-heavy
  249. - "\U000F067F" # mdi-weather-snowy-rainy
  250. - "\U000F0599" # mdi-weather-sunny
  251. - "\U000F0F37" # mdi-weather-sunny-alert
  252. - "\U000F14E4" # mdi-weather-sunny-off
  253. - "\U000F059A" # mdi-weather-sunset
  254. - "\U000F059B" # mdi-weather-sunset-down
  255. - "\U000F059C" # mdi-weather-sunset-up
  256. - "\U000F0F38" # mdi-weather-tornado
  257. - "\U000F059D" # mdi-weather-windy
  258. - "\U000F059E" # mdi-weather-windy-variant
  259.  
  260. - file: 'fonts/materialdesignicons-webfont.ttf' # http://materialdesignicons.com/cdn/7.4.47/
  261. id: light32
  262. size: 50
  263. bpp: 4
  264. glyphs: [
  265. "\U000F0335", # mdi-lightbulb
  266. "\U000F0769", # mdi-ceiling-light
  267. "\U000F08DD", # mdi-floor-lamp
  268. "\U000F12BA", # mdi-string-lights
  269. "\U000F0210", # mdi-fan
  270. "\U000F0737", # mdi-up
  271. ]
  272.  
  273. - file: "gfonts://Roboto@400"
  274. id: roboto20
  275. size: 20
  276. bpp: 4
  277.  
  278. substitutions:
  279. lightbulb: "\U000F0335"
  280. ceiling_light: "\U000F0769"
  281. floor_lamp: "\U000F08DD"
  282. string_lights: "\U000F12BA"
  283. fan: "\U000F0210"
  284. up: "\U000F0737"
  285.  
  286. image:
  287. - file: "images/humidity.png"
  288. id: humidity
  289. resize: 28x28
  290. type: RGB565
  291. use_transparency: true
  292. - file: "images/temp.png"
  293. id: temp
  294. resize: 23x23
  295. type: RGB565
  296. use_transparency: true
  297. - file: "images/back.jpg"
  298. id: background
  299. resize: 340x260
  300. type: RGB565
  301.  
  302.  
  303. lvgl:
  304. displays:
  305. - display_id: my_display
  306. buffer_size: 0.25
  307. touchscreens:
  308. - touchscreen_id: my_touchscreen
  309. style_definitions:
  310. - id: header_footer
  311. #bg_color: 0x3d3533
  312.  
  313. #bg_grad_color: 0x005782
  314. #bg_grad_dir: VER
  315. bg_opa: TRANSP
  316. border_width: 1
  317. radius: 0
  318. pad_all: 0
  319. pad_row: 0
  320. pad_column: 0
  321. border_color: 0x3d3533
  322. text_color: 0xFFFFFF
  323. width: 100%
  324. height: 35
  325. disp_bg_image: background
  326. color_depth: 16
  327. bg_opa: TRANSP
  328. top_layer:
  329. widgets:
  330.  
  331.  
  332. - label:
  333. text: "\uF1EB"
  334. id: lbl_hastatus
  335. hidden: true
  336. align: top_right
  337. x: -2
  338. y: -2
  339. text_align: right
  340. text_color: 0x04cf19
  341. - btnmatrix:
  342. align: bottom_mid
  343. styles: header_footer
  344. pad_all: 0
  345. outline_width: 0
  346. id: top_layer
  347. items:
  348. styles: header_footer
  349. rows:
  350. - buttons:
  351. - id: page_prev
  352. text: "\uF053"
  353. on_press:
  354. then:
  355. - lvgl.page.previous:
  356.  
  357. - id: page_home
  358. text: "\uF015"
  359. on_press:
  360. then:
  361. lvgl.page.show: main_page
  362. - id: page_next
  363. text: "\uF054"
  364. on_press:
  365. then:
  366. lvgl.page.next:
  367.  
  368. pages:
  369. - id: main_page
  370. bg_color: 0x000000
  371.  
  372. widgets:
  373. - obj: # Bathroom Widget
  374. height: 85
  375. width: 210
  376. bg_opa: 0.35
  377. bg_color: 0x000000
  378. border_width: 0
  379. outline_width: 0
  380. shadow_width: 0
  381. pad_all: 4
  382. x: 2
  383. y: 20
  384. widgets:
  385. - img:
  386. id: hum_icon
  387. src: humidity
  388. x: 145
  389. y: 1
  390. - img:
  391. id: temp_icon
  392. src: temp
  393. x: 50
  394. y: 1
  395. - label:
  396. text: "°C"
  397. text_font: gabarito15
  398. text_color: 0xcccccc
  399. x: 96
  400. y: 50
  401. text_align: right
  402. - label:
  403. text: "%"
  404. text_font: gabarito15
  405. text_color: 0xcccccc
  406. x: 187
  407. y: 50
  408. - label:
  409. id: temperature_text
  410. text: "-.-°C"
  411. y: 17
  412. text_font: gabarito50
  413. text_align: right
  414. text_color: 0xFFFFFF
  415. #scrollbar_mode: "off"
  416. - label:
  417. id: hum_text
  418. text: "-.-%"
  419. x: 130
  420. y: 17
  421. text_font: gabarito50
  422. text_align: right
  423. text_color: 0xFFFFFF
  424. - obj: # Outside Weather
  425. height: 75
  426. width: 210
  427. bg_opa: 0.35
  428. bg_color: 0x000000
  429. border_width: 0
  430. outline_width: 0
  431. shadow_width: 0
  432. pad_all: 4
  433. x: 2
  434. y: 125
  435. widgets:
  436. - label:
  437. text: "OUTSIDE"
  438. align: top_mid
  439. text_align: center
  440. text_color: 0xFFFFFF
  441. text_font: gabarito15
  442. - label:
  443. id: outside_temp_disp
  444. text: "-.-°C"
  445. y: 17
  446. text_font: gabarito30
  447. text_align: right
  448. text_color: 0xFFFFFF
  449. - label:
  450.  
  451. text: "°C"
  452. y: 30
  453. x: 55
  454. text_font: gabarito15
  455. text_align: right
  456. text_color: 0xcccccc
  457. - label:
  458. id: outside_cond_disp
  459. text: "null"
  460. x: 80
  461. y: 17
  462. text_font: roboto20
  463. text_align: right
  464. text_color: 0xFFFFFF
  465.  
  466. - label:
  467. text: "BATHROOM"
  468. align: top_mid
  469. text_align: center
  470. text_color: 0xFFFFFF
  471. text_font: gabarito15
  472.  
  473. - btn:
  474. id: light_btn
  475. x: 230
  476. y: 22
  477. width: 80
  478. height: 80
  479. bg_color: 0x000000
  480.  
  481. border_width: 3
  482. border_color: 0xff8800
  483.  
  484. checkable: true
  485. widgets:
  486. - label:
  487. align: center
  488. text: $ceiling_light
  489. text_font: light32
  490. on_click:
  491. - homeassistant.service:
  492. service: light.toggle
  493. data:
  494. entity_id: light.main_light_bt
  495. - btn:
  496. id: fan_btn
  497. x: 230
  498. y: 114
  499. width: 80
  500. height: 80
  501. bg_color: 0x000000
  502.  
  503. border_width: 3
  504. border_color: 0xff8800
  505.  
  506. checkable: true
  507. widgets:
  508. - label:
  509. align: center
  510. text: $fan
  511. text_font: light32
  512. on_click:
  513. - homeassistant.service:
  514. service: fan.toggle
  515. data:
  516. entity_id: fan.bathroom_fan
  517.  
  518.  
  519. binary_sensor:
  520. - platform: ld2420
  521. has_target:
  522. name: Presence Bathroom
  523. - platform: homeassistant
  524. id: remote_light
  525. entity_id: light.main_light_bt
  526. publish_initial_state: true
  527. on_state:
  528. then:
  529. lvgl.widget.update:
  530. id: light_btn
  531. state:
  532. checked: !lambda return x;
  533. - platform: homeassistant
  534. id: bathroom_fan
  535. entity_id: fan.bathroom_fan
  536. publish_initial_state: true
  537. on_state:
  538. then:
  539. lvgl.widget.update:
  540. id: fan_btn
  541. state:
  542. checked: !lambda return x;
  543. - platform: homeassistant
  544. id: hygrostat
  545. entity_id: binary_sensor.bathroom_hygrostat
  546. publish_initial_state: True
  547. - platform: gpio
  548. pin: GPIO33
  549. name: Bathroom Motion
  550. device_class: motion
  551.  
  552. sensor:
  553. - platform: ld2420
  554. moving_distance:
  555. name : Moving Distance Bathroom
  556. - platform: shtcx
  557. temperature:
  558. name: "Bathroom Temperature"
  559. id: bathroom_temp
  560. filters:
  561. - offset: -2.5
  562. on_value:
  563.  
  564. - lvgl.label.update:
  565. id: temperature_text
  566. text:
  567. format: "%.1f"
  568. args: [ 'x' ]
  569. humidity:
  570. name: "Bathroom Humidity"
  571. id: bathroom_hum
  572. filters:
  573. - offset: -5
  574. on_value:
  575.  
  576. - lvgl.label.update:
  577. id: hum_text
  578. text:
  579. format: "%.0f"
  580. args: [ 'x' ]
  581. address: 0x70
  582. update_interval: 30s
  583.  
  584. - platform: homeassistant
  585. id: outside_temp
  586. entity_id: sensor.outside_sensor_temperature
  587. on_value:
  588. - lvgl.label.update:
  589. id: outside_temp_disp
  590. text:
  591. format: "%.1f"
  592. args: [ 'x' ]
  593.  
  594. text_sensor:
  595. - platform: ld2420
  596. fw_version:
  597. name: LD2420 Firmware
  598. - platform: homeassistant
  599. id: outside_condition
  600. entity_id: sensor.openweathermap_condition
  601. filters:
  602. - to_upper
  603.  
  604. on_value:
  605. - lvgl.label.update:
  606. id: outside_cond_disp
  607. text:
  608. format: "%s"
  609. args: [ 'id(outside_condition).state.c_str()' ]
  610.  
  611.  
  612.  
  613.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement