TuXaMaT

Untitled

Mar 27th, 2025
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.20 KB | None | 0 0
  1. time:
  2. - platform: homeassistant
  3. id: esp_time
  4. update_interval: 1h
  5. on_time_sync:
  6. then:
  7. if:
  8. condition:
  9. time.has_time:
  10. then:
  11. - logger.log: Time has been set and is valid!
  12. - platform: homeassistant
  13. on_time_sync:
  14. then:
  15. ds1307.write_time:
  16.  
  17. - platform: ds1307
  18. update_interval: never
  19. id: ehmtx_time
  20.  
  21.  
  22. i2c:
  23. sda: $sda_pin
  24. scl: $scl_pin
  25. scan: true
  26. id: i2cbus
  27.  
  28. light:
  29. - platform: neopixelbus
  30. id: ehmtx_light
  31. type: GRB
  32. internal: true
  33. variant: WS2812
  34. pin: $matrix_pin
  35. num_leds: 256
  36. color_correct: [30%, 30%, 30%]
  37. gamma_correct: 2.0
  38. name: "${name} Light"
  39. restore_mode: ALWAYS_OFF
  40.  
  41. image:
  42. - file: img/1pixel.gif
  43. id: breaking20237
  44.  
  45. animation:
  46. - file: img/1pixel.gif
  47. id: breaking202371
  48.  
  49. display:
  50. - platform: addressable_light
  51. id: ehmtx_display
  52. addressable_light_id: ehmtx_light
  53. width: 32
  54. height: 8
  55. pixel_mapper: |-
  56. if (y % 2 == 0)
  57. {
  58. return (y * 32) + x;
  59. }
  60. return (y * 32) + (31 - x);
  61. rotation: 0°
  62. update_interval: 16ms
  63. # auto_clear_enabled: true
  64. auto_clear_enabled: false
  65. lambda: |-
  66. id(rgb8x32)->tick();
  67. id(rgb8x32)->draw();
  68.  
  69. output:
  70. - platform: ledc
  71. pin: $buzzer_pin
  72. id: rtttl_out
  73.  
  74. rtttl:
  75. output: rtttl_out
  76.  
  77. external_components:
  78. - source:
  79. type: git
  80. url: https://github.com/lubeda/EspHoMaTriXv2
  81. ref: latest
  82. components: [ ehmtxv2 ]
  83. refresh: 60s
  84.  
  85.  
  86.  
  87. ### User Settings
  88.  
  89. ehmtxv2:
  90. id: rgb8x32
  91. icons2html: true
  92. matrix_component: ehmtx_display
  93. time_component: ehmtx_time
  94. time_format: "%H:%M"
  95. date_format: "%d/%m"
  96. weekdays: "ВСПНВТСРЧТПТСБ"
  97. show_seconds: false
  98. default_font_id: default_font
  99. default_font_yoffset: 7
  100. special_font_id: special_font
  101. special_font_yoffset: 8
  102. blend_steps: 32
  103. scroll_count: 1 # scroll long text at least two times
  104. scroll_interval: 80 # milliseconds
  105. rainbow_interval: 32 # milliseconds
  106. vertical_scroll: false
  107. advanced_clock: true
  108. flip_flop_clock: true
  109.  
  110. night_mode_screens:
  111. - 2
  112. - 3
  113. - 16
  114.  
  115. on_start_running:
  116. then:
  117. lambda: |-
  118. if (id(ehmtx_time).now().day_of_week == 7) {
  119. id(rgb8x32)->icon_clock("calendar|day#2", 525600, 10, true);
  120. id(rgb8x32)->set_infotext_color(50, 50, 50, 50, 50, 50, true, 1);
  121. id(rgb8x32)->expand_icon_to_9(3);
  122. id(rgb8x32)->set_calendar_color(255,0,0);
  123. id(rgb8x32)->set_today_color(255,0,0);
  124. }
  125. else if (id(ehmtx_time).now().day_of_week == 1) {
  126. id(rgb8x32)->icon_clock("calendar|day#2", 525600, 10, true);
  127. id(rgb8x32)->set_infotext_color(50, 50, 50, 50, 50, 50, true, 1);
  128. id(rgb8x32)->expand_icon_to_9(3);
  129. id(rgb8x32)->set_calendar_color(255,0,0);
  130. id(rgb8x32)->set_today_color(255,0,0);
  131. }
  132. else {
  133. id(rgb8x32)->icon_clock("calendar|day#2", 525600, 10, true);
  134. id(rgb8x32)->set_infotext_color(50, 50, 50, 50, 50, 50, true, 1);
  135. id(rgb8x32)->expand_icon_to_9(3);
  136. id(rgb8x32)->set_calendar_color(255,0,0);
  137. id(rgb8x32)->set_today_color(0,255,255);
  138. }
  139.  
  140.  
  141.  
  142. on_empty_queue:
  143. then:
  144. lambda: |-
  145. if (id(ehmtx_time).now().day_of_week == 7) {
  146. id(rgb8x32)->icon_clock("calendar|day#2", 525600, 10, true);
  147. id(rgb8x32)->set_infotext_color(50, 50, 50, 50, 50, 50, true, 1);
  148. id(rgb8x32)->expand_icon_to_9(3);
  149. id(rgb8x32)->set_calendar_color(255,0,0);
  150. id(rgb8x32)->set_today_color(255,0,0);
  151. }
  152. else if (id(ehmtx_time).now().day_of_week == 1) {
  153. id(rgb8x32)->icon_clock("calendar_|day#2", 525600, 10, true);
  154. id(rgb8x32)->set_infotext_color(50, 50, 50, 50, 50, 50, true, 1);
  155. id(rgb8x32)->expand_icon_to_9(3);
  156. id(rgb8x32)->set_calendar_color(255,0,0);
  157. id(rgb8x32)->set_today_color(255,0,0);
  158. }
  159. else {
  160. id(rgb8x32)->icon_clock("calendar|day#2", 525600, 10, true);
  161. id(rgb8x32)->set_infotext_color(50, 50, 50, 50, 50, 50, true, 1);
  162. id(rgb8x32)->expand_icon_to_9(3);
  163. id(rgb8x32)->set_calendar_color(255,0,0);
  164. id(rgb8x32)->set_today_color(0,255,255);
  165. }
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172. on_next_screen:
  173. - homeassistant.event:
  174. event: esphome.new_screen
  175. data_template:
  176. iconname: !lambda "return icon.c_str();"
  177. text: !lambda "return text.c_str();"
  178. - lambda: |-
  179. id(current_screen).publish_state(icon.c_str());
  180.  
  181. on_next_clock:
  182. lambda: |-
  183. id(current_screen).publish_state("Clock");
  184.  
  185. on_add_screen:
  186. - homeassistant.event:
  187. event: esphome.add_screen
  188. data_template:
  189. icon: !lambda "return icon.c_str();"
  190. mode: !lambda "return mode;"
  191.  
  192.  
  193. # https://developer.lametric.com/icons
  194. icons:
  195. - id: home_assistant
  196. lameid: 56370
  197. - id: temperature_cold
  198. lameid: 6980
  199. - id: temperature_home
  200. lameid: 22295
  201. - id: temperature_hot
  202. lameid: 9275
  203. - id: temperature
  204. lameid: 13593
  205. - id: temperature_down
  206. lameid: 19649
  207. - id: temperature_up
  208. lameid: 19650
  209. - id: bell
  210. lameid: 55163
  211. - id: door_open
  212. lameid: 21376
  213. - id: umbrella
  214. lameid: 41619
  215. - id: snow
  216. lameid: 17140
  217. - id: weather_clear_night #чистая ночь
  218. lameid: 26086
  219. - id: weather_exceptional
  220. lameid: 16754
  221. - id: weather_fog #туман
  222. lameid: 56703
  223. - id: weather_lightning #гроза
  224. lameid: 60936
  225. - id: weather_lightning_rainy #дождь с грозой
  226. lameid: 49299
  227. - id: weather_partlycloudy #малооблачно
  228. lameid: 60931
  229. - id: weather_cloudy #облачно
  230. lameid: 22160
  231. - id: weather_overcast #пасмурно
  232. lameid: 2283
  233. - id: weather_pouring #ливень
  234. lameid: 49300
  235. - id: weather_rainy #сильный дождь
  236. lameid: 2284
  237. - id: weather_extreme_rain #длительный сильный дождь
  238. lameid: 60932
  239. - id: weather_small_rain #небольшой дождь
  240. lameid: 60930
  241. - id: weather_hail #град
  242. lameid: 60933
  243. - id: weather_drizzle #морось
  244. lameid: 60934
  245. - id: weather_lightning_hail #гроза с градом
  246. lameid: 60935
  247. - id: weather_snowy #снег
  248. lameid: 2289
  249. - id: weather_snowfall #снегопад
  250. lameid: 60937
  251. - id: weather_small_snow #небольшой снег
  252. lameid: 60938
  253. - id: weather_snowy_rainy #снег с дождем
  254. lameid: 49301
  255. - id: weather_sunny #солнечно
  256. lameid: 2282
  257. - id: weather_windy
  258. lameid: 21909
  259. - id: weather_windy_variant
  260. lameid: 21909
  261. - id: weather_cloudy_night # луна и облачно
  262. lameid: 60950
  263. - id: weather_moon_drizzle # луна и дождь
  264. lameid: 26091
  265. - id: weather_moon_rain # луна и сильный дождь
  266. lameid: 26092
  267. - id: weather_moon_lightning # луна и молния
  268. lameid: 60939
  269. - id: weather_moon_fog # луна и туман
  270. lameid: 26085
  271. - id: humidifier
  272. lameid: 53067
  273. - id: humidity_out
  274. lameid: 39042
  275. - id: humidity_home
  276. lameid: 39041
  277. - id: wind
  278. lameid: 17076
  279. - id: wind_direction
  280. lameid: 21909
  281. - id: co2_aqi
  282. lameid: 44182
  283. - id: co2_good
  284. lameid: 60913
  285. - id: co2_middle
  286. lameid: 60916
  287. - id: co2_high
  288. lameid: 60917
  289. - id: pm25
  290. lameid: 38873
  291. - id: teapot
  292. lameid: 35124
  293. - id: doorbell
  294. lameid: 42802
  295. - id: washing
  296. lameid: 37472
  297. - id: purifier
  298. lameid: 21368
  299. - id: battery_full
  300. lameid: 12126
  301. - id: heart
  302. lameid: 5859
  303. - id: alice_listen
  304. lameid: 57047
  305. - id: alice_talking
  306. lameid: 57048
  307. - id: cover
  308. lameid: 32098
  309. - id: tv_on
  310. lameid: 9754
  311. - id: tv_off
  312. lameid: 13582
  313. - id: light_on
  314. lameid: 57051
  315. - id: alice_playing
  316. lameid: 57065
  317. - id: prognose
  318. lameid: 41116
  319. - id: alarma
  320. lameid: 34175
  321. - id: ozone
  322. lameid: 21688
  323. - id: chtree
  324. lameid: 47754
  325. - id: home
  326. lameid: 22737
  327. - id: door
  328. lameid: 42480
  329. - id: wnet
  330. lameid: 40695
  331. # - id: calendar
  332. # lameid: 55812
  333. # - id: calendar_r
  334. # lameid: 3575
  335. - id: shower
  336. lameid: 39805
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343. globals:
  344. # aab = auto-adjustable brightness
  345. - id: aab_enable
  346. type: "bool"
  347. restore_value: true
  348. initial_value: "true"
  349.  
  350. - id: aab_add
  351. type: int
  352. initial_value: '5'
  353.  
  354. - id: aab_max
  355. type: int
  356. initial_value: '220'
  357.  
  358. - id: aab_min
  359. type: int
  360. initial_value: '20'
  361.  
  362. font:
  363. # Matrix Clock Fonts
  364. # Grab these from hhttps://github.com/trip5/Matrix-Fonts
  365. # Store in a "fonts" subfolder of your ESPHome config folder or change paths below
  366. - file: fonts/MatrixChunky6.ttf
  367. size: 6
  368. id: default_font
  369. glyphs: |
  370. ! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz°|АаБбВвГ㥴ДдЕеЄєЖжЗзИиІіЇїЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЬьЮюЯяЁёЪъЫыЭэ℃₴€일월화수목금토
  371.  
  372. - file: fonts/MatrixChunky8.ttf
  373. size: 8
  374. id: special_font
  375. glyphs: |
  376. ! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz°|АаБбВвГ㥴ДдЕеЄєЖжЗзИиІіЇїЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЬьЮюЯяЁёЪъЫыЭэ℃₴€일월화수목금토
  377.  
  378.  
  379. ### Home Assistant Entities
  380.  
  381. binary_sensor:
  382. - platform: status
  383. name: ${name} Status
  384. device_class: connectivity
  385.  
  386. - platform: gpio
  387. pin:
  388. number: $left_button_pin
  389. inverted: true
  390. name: "${name} Left button"
  391.  
  392. - platform: gpio
  393. pin:
  394. inverted: true
  395. number: $mid_button_pin
  396. mode: INPUT_PULLUP
  397. name: "${name} Middle button"
  398.  
  399. - platform: gpio
  400. pin:
  401. number: $right_button_pin
  402. inverted: true
  403. name: "${name} Right button"
  404.  
  405. sensor:
  406. # - platform: sht3xd
  407. # temperature:
  408. # name: "${name} Temperature"
  409. # humidity:
  410. # name: "${name} Relative Humidity"
  411. # update_interval: ${update_interval}
  412.  
  413. - platform: adc
  414. pin: $battery_pin
  415. name: "${name} Battery"
  416. id: battery_voltage
  417. update_interval: 10s
  418. device_class: battery
  419. accuracy_decimals: 0
  420. attenuation: auto
  421. filters:
  422. - sliding_window_moving_average:
  423. window_size: 15
  424. send_every: 15
  425. send_first_at: 1
  426. - multiply: 1.6
  427. - lambda: |-
  428. auto r = ((x - 3) / 0.69 * 100.00);
  429. if (r >= 100) return 100;
  430. if (r > 0) return r;
  431. if (r <= 0) return 1;
  432. return 0;
  433. unit_of_measurement: '%'
  434.  
  435. - platform: adc
  436. id: light_sensor
  437. name: "${name} Illuminance"
  438. pin: $ldr_pin
  439. update_interval: 10s
  440. attenuation: auto
  441. unit_of_measurement: lx
  442. device_class: illuminance
  443. accuracy_decimals: 0
  444. filters:
  445. - lambda: |-
  446. return (x / 10000.0) * 2000000.0 - 15 ;
  447. on_value:
  448. then:
  449. - lambda: |-
  450. if ( id(aab_enable) )
  451. {
  452. int n = x / 4 + id(aab_add); // new_value
  453. if (n > id(aab_max)) n = id(aab_max);
  454. if (n < id(aab_min)) n = id(aab_min);
  455. int c = id(rgb8x32)->get_brightness(); // current value
  456. c = c > 0 ? c : 1;
  457. int d = (n - c) * 100 / c; // diff in %
  458. if (n > 50) id(rgb8x32)->set_brightness(190);
  459. else if (abs(d) > 2) id(rgb8x32)->set_brightness(n);
  460. }
  461.  
  462.  
  463.  
  464. text_sensor:
  465. - platform: template
  466. name: "${name} Current Screen"
  467. id: current_screen
  468. update_interval: never
  469. icon: "mdi:overscan"
  470. entity_category: diagnostic
  471.  
  472. switch:
  473. - platform: restart
  474. name: ${name} Restart
  475.  
  476. - platform: template
  477. name: "${name} Auto-Adjust Brightness"
  478. id: switch_autobrightness
  479. icon: mdi:brightness-auto
  480. restore_mode: RESTORE_DEFAULT_ON
  481. lambda: |-
  482. if (id(aab_enable))
  483. {
  484. return true;
  485. }
  486. else
  487. {
  488. return false;
  489. }
  490. turn_on_action:
  491. lambda: |-
  492. id(aab_enable) = true;
  493. turn_off_action:
  494. lambda: |-
  495. id(aab_enable) = false;
  496.  
  497. - platform: template
  498. name: "${name} Night Mode"
  499. id: switch_night_mode
  500. icon: mdi:weather-night
  501. restore_mode: RESTORE_DEFAULT_OFF
  502. lambda: |-
  503. return id(rgb8x32)->night_mode;
  504. turn_on_action:
  505. lambda: |-
  506. id(rgb8x32)->set_night_mode_on();
  507. turn_off_action:
  508. lambda: |-
  509. id(rgb8x32)->set_night_mode_off();
  510.  
  511.  
  512. - platform: template
  513. name: "${name} Display"
  514. icon: "mdi:clock-digital"
  515. restore_mode: ALWAYS_ON
  516. lambda: |-
  517. return id(rgb8x32)->show_display;
  518. turn_on_action:
  519. lambda: |-
  520. id(rgb8x32)->set_display_on();
  521. turn_off_action:
  522. lambda: |-
  523. id(rgb8x32)->set_display_off();
  524.  
  525. number:
  526. - platform: template
  527. name: "${name} Brightness"
  528. min_value: 20
  529. max_value: 220
  530. step: 1
  531. lambda: |-
  532. return id(rgb8x32)->get_brightness();
  533. set_action:
  534. lambda: |-
  535. id(rgb8x32)->set_brightness(x);
  536.  
  537. ### Firmware, Hardware, ESP
  538.  
  539. substitutions:
  540. device: ulanzi_tram
  541. name: Ulanzi_tram
  542. location: ${name}
  543. update_interval: 60s
  544. reboot_timeout: 0s
  545. project_name: "Ulanzi.EHMTXv2"
  546. project_version: "2023.9.1"
  547. comment: "Ulanzi Pixel Clock"
  548.  
  549. # Pin definition from https://github.com/aptonline/PixelIt_Ulanzi
  550. battery_pin: GPIO34
  551. buzzer_pin: GPIO15
  552. ldr_pin: GPIO35
  553. matrix_pin: GPIO32
  554. left_button_pin: GPIO26
  555. mid_button_pin: GPIO27
  556. right_button_pin: GPIO14
  557. scl_pin: GPIO22
  558. sda_pin: GPIO21
  559.  
Advertisement
Add Comment
Please, Sign In to add comment