TuXaMaT

Untitled

Mar 27th, 2025
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.48 KB | None | 0 0
  1. wifi:
  2. ssid: !secret wifi_ssid
  3. password: !secret wifi_password
  4.  
  5. # Enable fallback hotspot (captive portal) in case wifi connection fails
  6. ap:
  7. ssid: "Ulanzi-Tram Fallback Hotspot"
  8. password: "ulanzi903"
  9.  
  10. captive_portal:
  11. esphome:
  12. name: ${device}
  13. project:
  14. name: "Ulanzi.EHMTXv2"
  15. # version: "2024.1.0"
  16. version: latest
  17.  
  18. on_boot:
  19. then:
  20. - ds1307.read_time:
  21. esp32:
  22. board: esp32dev
  23. framework:
  24. advanced:
  25. ignore_efuse_custom_mac: true
  26.  
  27.  
  28. # Enable Home Assistant API
  29. api:
  30. encryption:
  31. key: "w4+UWbnnRlJg4XIVr372b7jlYgwWrwc4ZmggXCwTc+c="
  32. reboot_timeout: ${reboot_timeout}
  33.  
  34.  
  35. ota:
  36. - platform: esphome
  37. password: "d92b7b427db7a24b3e387e0be7cb2464"
  38. on_error:
  39. then:
  40. - logger.log:
  41. format: "OTA Update error %d"
  42. args: ["x"]
  43. level: "ERROR"
  44. tag: "ota"
  45. on_end:
  46. then:
  47. - logger.log:
  48. format: "OTA Update has completed successfully"
  49. level: "WARN"
  50. tag: "ota"
  51. ### Firmware, Hardware, ESP
  52.  
  53. substitutions:
  54. device: ulanzi_tram
  55. name: Ulanzi_tram
  56. location: ${name}
  57. update_interval: 60s
  58. reboot_timeout: 0s
  59. project_name: "Ulanzi.EHMTXv2"
  60. project_version: "2023.9.1"
  61. comment: "Ulanzi Pixel Clock"
  62. board: esp32dev
  63.  
  64. # Pin definition from https://github.com/aptonline/PixelIt_Ulanzi
  65. battery_pin: GPIO34
  66. buzzer_pin: GPIO15
  67. ldr_pin: GPIO35
  68. matrix_pin: GPIO32
  69. left_button_pin: GPIO26
  70. mid_button_pin: GPIO27
  71. right_button_pin: GPIO14
  72. scl_pin: GPIO22
  73. sda_pin: GPIO21
  74.  
  75.  
  76. ehmtxv2:
  77. id: rgb8x32
  78. icons2html: true
  79. matrix_component: ehmtx_display
  80. time_component: ehmtx_time
  81. time_format: "%H:%M"
  82. time_format_big: "%H:%M"
  83. date_format: "%d/%m"
  84. show_seconds: true
  85. weekdays: "НДПНВТСРЧТПТСБ"
  86. advanced_clock: true
  87. default_font_id: default_font
  88. default_font_yoffset: 8 # the text is aligned BASELINE_LEFT, the baseline defaults to 6
  89. special_font_id: special_font
  90. special_font_yoffset: 8
  91. blend_steps: 0 #32
  92. scroll_count: 1 # scroll long text at least two times
  93. scroll_interval: 32 # milliseconds # the interval in ms to scroll the text (default=80), should be a multiple of the update_interval from the display (default: 16ms)
  94. rainbow_interval: 32 # milliseconds
  95. clock_interval: 60 # show the clock at least each x seconds
  96. show_dow: false # draw the day indicator on the bottom of the screen, defaults to true
  97. # show_date: false # show the date for show_screen - show_clock seconds otherwise only shows the clock for show_screen seconds, defaults to true
  98. week_start_monday: true # default monday is first day of week, false = sunday
  99. frame_interval: 192 # the interval in ms to display the next anim frame (default=192), should be a multiple of the update_interval from the display (default: 16ms)
  100.  
  101.  
  102. on_start_running:
  103. then:
  104. lambda: |-
  105. ESP_LOGD(TAG, "removing default clock screen and setting a new one with new screen time");
  106. id(rgb8x32)->del_screen("*", 2);
  107. id(rgb8x32)->clock_screen(1440, 25, true, 192, 192, 192);
  108. id(rgb8x32)->set_weekday_color(150, 150, 150);
  109. on_next_screen:
  110. - homeassistant.event:
  111. event: esphome.new_screen
  112. data_template:
  113. iconname: !lambda "return icon.c_str();"
  114. text: !lambda "return text.c_str();"
  115. - lambda: |-
  116. id(current_screen).publish_state(icon.c_str());
  117.  
  118. on_next_clock:
  119. lambda: |-
  120. id(current_screen).publish_state("Clock");
  121.  
  122. on_add_screen:
  123. - homeassistant.event:
  124. event: esphome.add_screen
  125. data_template:
  126. icon: !lambda "return icon.c_str();"
  127. mode: !lambda "return mode;"
  128.  
  129. # https://developer.lametric.com/icons
  130. icons:
  131. - id: ha
  132. lameid: 7956
  133. - id: tempc
  134. lameid: 2422
  135. - id: plug
  136. lameid: 403
  137. - id: humidity
  138. lameid: 51764
  139. - id: co2
  140. lameid: 30662
  141. - id: co2_bath
  142. lameid: 7109
  143. - id: co2_indoor
  144. lameid: 7113
  145. - id: co2_bed
  146. lameid: 7110
  147. - id: pm25
  148. lameid: 6641
  149. - id: alice
  150. lameid: 57047
  151. - id: alice_line
  152. lameid: 57048
  153. - id: printer_done
  154. lameid: 51884
  155. - id: printer
  156. lameid: 51841
  157. - id: printer_paused
  158. lameid: 56979
  159. - id: printer_error
  160. lameid: 56980
  161. - id: temperature
  162. lameid: 2056
  163. - id: temperature_down
  164. lameid: 19649
  165. - id: temperature_up
  166. lameid: 19650
  167. - id: temperature_hot
  168. lameid: 22293
  169. - id: temperature_cold
  170. lameid: 22296
  171. - id: umbrella
  172. lameid: 41619
  173. - id: snow
  174. lameid: 17140
  175. - id: weather_clear_night
  176. lameid: 18433
  177. - id: weather_cloudy
  178. lameid: 2283
  179. - id: weather_exceptional
  180. lameid: 16754
  181. - id: weather_fog
  182. lameid: 52167
  183. - id: weather_hail
  184. lameid: 53288
  185. - id: weather_lightning
  186. lameid: 23713
  187. - id: weather_lightning_rainy
  188. lameid: 49299
  189. - id: weather_partlycloudy
  190. lameid: 22160
  191. - id: weather_pouring
  192. lameid: 49300
  193. - id: weather_rainy
  194. lameid: 2284
  195. - id: weather_snowy
  196. lameid: 2289
  197. - id: weather_snowy_rainy
  198. lameid: 49301
  199. - id: weather_sunny
  200. lameid: 2282
  201. - id: weather_windy
  202. lameid: 21909
  203. - id: weather_windy_variant
  204. lameid: 21909
  205. - id: weather_cloudy_night
  206. lameid: 12195
  207. - id: battery_low
  208. lameid: 640
  209. - id: battery_charging
  210. lameid: 1095
  211. - id: humidifier
  212. lameid: 56401
  213. - id: video
  214. lameid: 1944
  215. - id: player_play
  216. lameid: 1548
  217. - id: player_pause
  218. lameid: 20945
  219. - id: attention
  220. lameid: 555
  221. - id: alert_light
  222. lameid: 34175
  223.  
  224. globals:
  225. # aab = auto-adjustable brightness
  226. - id: aab_enable
  227. type: "bool"
  228. restore_value: true
  229. initial_value: "true"
  230. - id: aab_add
  231. type: int
  232. initial_value: '10'
  233. - id: aab_max
  234. type: int
  235. initial_value: '220'
  236. - id: aab_min
  237. type: int
  238. initial_value: '20'
  239.  
  240. external_components:
  241. - source:
  242. type: git
  243. url: https://github.com/lubeda/EspHoMaTriXv2
  244. ref: 2025.2.0
  245. refresh: 60s
  246. components: [ ehmtxv2 ]
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253. font:
  254. # Matrix Clock Fonts
  255. # Grab these from hhttps://github.com/trip5/Matrix-Fonts
  256. # Store in a "fonts" subfolder of your ESPHome config folder or change paths below
  257. - file: fonts/MatrixChunky6.ttf
  258. size: 6
  259. id: default_font
  260. glyphs: >-
  261.  
  262. - file: fonts/MatrixChunky8.ttf
  263. size: 8
  264. id: special_font
  265. glyphs: >-
  266.  
  267. binary_sensor:
  268. - platform: status
  269. name: "$devicename Status"
  270. - platform: gpio
  271. pin:
  272. number: $left_button_pin
  273. inverted: true
  274. name: "$devicename Left button"
  275. on_press:
  276. lambda:
  277. id(rgb8x32)->hold_screen(120);
  278. - platform: gpio
  279. pin:
  280. inverted: true
  281. number: $mid_button_pin
  282. mode: INPUT_PULLUP
  283. name: "$devicename Middle button"
  284. - platform: gpio
  285. pin:
  286. number: $right_button_pin
  287. inverted: true
  288. name: "$devicename Right button"
  289. on_press:
  290. lambda:
  291. id(rgb8x32)->skip_screen();
  292.  
  293.  
  294. logger:
  295. level: info
  296.  
  297. output:
  298. - platform: gpio
  299. pin:
  300. number: GPIO15
  301. ignore_strapping_warning: true
  302. id: buzzer_pin
  303.  
  304. sensor:
  305. - platform: sht3xd
  306. temperature:
  307. name: "$devicename Temperature"
  308. humidity:
  309. name: "$devicename Relative Humidity"
  310. update_interval: 60s
  311. - platform: adc
  312. pin: $battery_pin
  313. name: "$devicename Battery"
  314. id: battery_voltage
  315. update_interval: 10s
  316. device_class: battery
  317. accuracy_decimals: 0
  318. attenuation: auto
  319. filters:
  320. - sliding_window_moving_average:
  321. window_size: 15
  322. send_every: 15
  323. send_first_at: 1
  324. - multiply: 1.6
  325. - lambda: |-
  326. auto r = ((x - 3) / 0.69 * 100.00);
  327. if (r >= 100) return 100;
  328. if (r > 0) return r;
  329. if (r <= 0) return 1;
  330. return 0;
  331. unit_of_measurement: '%'
  332. - platform: adc
  333. id: light_sensor
  334. name: "$devicename Illuminance"
  335. pin: $ldr_pin
  336. update_interval: 10s
  337. attenuation: auto
  338. unit_of_measurement: lx
  339. device_class: illuminance
  340. accuracy_decimals: 0
  341. filters:
  342. - lambda: |-
  343. return (x / 10000.0) * 2000000.0 - 15 ;
  344. on_value:
  345. then:
  346. - lambda: |-
  347. if ( id(aab_enable) ) {
  348. int n = x / 4 + id(aab_add); // new_value
  349. if (n > id(aab_max)) n = id(aab_max);
  350. if (n < id(aab_min)) n = id(aab_min);
  351. int c = id(rgb8x32)->get_brightness(); // current value
  352. c = c>0?c:1 ;
  353. int d = (n - c) * 100 / c; // diff in %
  354. if ( abs(d) > 2 ) id(rgb8x32)->set_brightness(n);
  355. }
  356.  
  357.  
  358.  
  359.  
  360. web_server:
  361.  
  362. i2c:
  363. sda: $sda_pin
  364. scl: $scl_pin
  365. scan: true
  366. id: i2cbus
  367.  
  368. light:
  369. - platform: neopixelbus
  370. id: ehmtx_light
  371. type: GRB
  372. internal: true
  373. variant: WS2812
  374. pin: $matrix_pin
  375. num_leds: 256
  376. color_correct: [30%, 30%, 30%]
  377. gamma_correct: 2.0
  378. name: "$devicename Light"
  379. restore_mode: ALWAYS_OFF
  380.  
  381. time:
  382. - platform: homeassistant
  383. on_time_sync:
  384. then:
  385. ds1307.write_time:
  386. - platform: ds1307
  387. update_interval: never
  388. id: ehmtx_time
  389. - platform: homeassistant
  390. on_time:
  391. - seconds: 0
  392. minutes: 0
  393. hours: /12
  394. days_of_week: MON-SUN
  395. then:
  396. - logger.log: "***************** time event ***"
  397. - switch.toggle: restart_ulanzi
  398.  
  399. display:
  400. - platform: addressable_light
  401. id: ehmtx_display
  402. addressable_light_id: ehmtx_light
  403. width: 32
  404. height: 8
  405. pixel_mapper: |-
  406. if (y % 2 == 0) {
  407. return (y * 32) + x;
  408. }
  409. return (y * 32) + (31 - x);
  410. rotation: 0°
  411. update_interval: 16ms
  412. auto_clear_enabled: true
  413. lambda: |-
  414. id(rgb8x32)->tick();
  415. id(rgb8x32)->draw();
  416.  
  417.  
  418. switch:
  419. - platform: restart
  420. name: "$devicename Restart"
  421. id: restart_ulanzi
  422. - platform: template
  423. name: "$devicename Auto-Adjust Brightness"
  424. id: switch_autobrightness
  425. icon: mdi:brightness-auto
  426. restore_mode: RESTORE_DEFAULT_ON
  427. lambda: |-
  428. if (id(aab_enable))
  429. {
  430. return true;
  431. }
  432. else
  433. {
  434. return false;
  435. }
  436. turn_on_action:
  437. lambda: |-
  438. id(aab_enable) = true;
  439. turn_off_action:
  440. lambda: |-
  441. id(aab_enable) = false;
  442.  
  443.  
  444. - platform: template
  445. name: "$devicename Display"
  446. icon: "mdi:clock-digital"
  447. restore_mode: ALWAYS_ON
  448. lambda: |-
  449. return id(rgb8x32)->show_display;
  450. turn_on_action:
  451. lambda: |-
  452. id(rgb8x32)->set_display_on();
  453. turn_off_action:
  454. lambda: |-
  455. id(rgb8x32)->set_display_off();
  456.  
  457. - platform: template
  458. name: "$devicename Night Mode"
  459. icon: "mdi:weather-night"
  460. restore_mode: ALWAYS_OFF
  461. lambda: |-
  462. return id(rgb8x32)->night_mode;
  463. turn_on_action:
  464. lambda: |-
  465. id(rgb8x32)->set_night_mode_on();
  466. turn_off_action:
  467. lambda: |-
  468. id(rgb8x32)->set_night_mode_off();
  469.  
  470. text_sensor:
  471. - platform: template
  472. name: "$devicename Current Screen"
  473. id: current_screen
  474. update_interval: never
  475. icon: "mdi:overscan"
  476. entity_category: diagnostic
  477.  
  478.  
Advertisement
Add Comment
Please, Sign In to add comment