Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wifi:
- ssid: !secret wifi_ssid
- password: !secret wifi_password
- # Enable fallback hotspot (captive portal) in case wifi connection fails
- ap:
- ssid: "Ulanzi-Tram Fallback Hotspot"
- password: "password"
- captive_portal:
- esphome:
- name: ${device}
- comment: $comment
- build_path: ./.build/$device
- project:
- name: $project_name
- version: $project_version
- on_boot:
- then:
- - ds1307.read_time:
- esp32:
- board: esp32dev
- # Enable logging
- logger:
- level: DEBUG
- baud_rate: 0
- id: esp_log
- # Enable Home Assistant API
- api:
- encryption:
- key: "key"
- reboot_timeout: ${reboot_timeout}
- services:
- - service: tune
- variables:
- tune: string
- then:
- - rtttl.play:
- rtttl: !lambda 'return tune;'
- ota:
- password: "d92b7b427db7a24b3e387e0be7cb2464"
- on_error:
- then:
- - logger.log:
- format: "OTA Update error %d"
- args: ["x"]
- level: "ERROR"
- tag: "ota"
- on_end:
- then:
- - logger.log:
- format: "OTA Update has completed successfully"
- level: "WARN"
- tag: "ota"
- web_server:
- log: false
- time:
- - platform: homeassistant
- id: esp_time
- update_interval: 1h
- on_time_sync:
- then:
- if:
- condition:
- time.has_time:
- then:
- - logger.log: Time has been set and is valid!
- - platform: homeassistant
- on_time_sync:
- then:
- ds1307.write_time:
- - platform: ds1307
- update_interval: never
- id: ehmtx_time
- i2c:
- sda: $sda_pin
- scl: $scl_pin
- scan: true
- id: i2cbus
- light:
- - platform: neopixelbus
- id: ehmtx_light
- type: GRB
- internal: true
- variant: WS2812
- pin: $matrix_pin
- num_leds: 256
- color_correct: [30%, 30%, 30%]
- gamma_correct: 2.0
- name: "${name} Light"
- restore_mode: ALWAYS_OFF
- image:
- - file: img/1pixel.gif
- id: breaking20237
- animation:
- - file: img/1pixel.gif
- id: breaking202371
- display:
- - platform: addressable_light
- id: ehmtx_display
- addressable_light_id: ehmtx_light
- width: 32
- height: 8
- pixel_mapper: |-
- if (y % 2 == 0)
- {
- return (y * 32) + x;
- }
- return (y * 32) + (31 - x);
- rotation: 0°
- update_interval: 16ms
- # auto_clear_enabled: true
- auto_clear_enabled: false
- lambda: |-
- id(rgb8x32)->tick();
- id(rgb8x32)->draw();
- output:
- - platform: ledc
- pin: $buzzer_pin
- id: rtttl_out
- rtttl:
- output: rtttl_out
- external_components:
- - source:
- type: git
- url: https://github.com/lubeda/EspHoMaTriXv2
- ref: latest
- components: [ ehmtxv2 ]
- refresh: 60s
- ### User Settings
- ehmtxv2:
- id: rgb8x32
- icons2html: true
- matrix_component: ehmtx_display
- time_component: ehmtx_time
- time_format: "%H:%M"
- date_format: "%d/%m"
- weekdays: "ВСПНВТСРЧТПТСБ"
- show_seconds: false
- default_font_id: default_font
- default_font_yoffset: 7
- special_font_id: special_font
- special_font_yoffset: 8
- blend_steps: 32
- scroll_count: 1 # scroll long text at least two times
- scroll_interval: 80 # milliseconds
- rainbow_interval: 32 # milliseconds
- vertical_scroll: false
- advanced_clock: true
- flip_flop_clock: true
- night_mode_screens:
- - 2
- - 3
- - 16
- on_start_running:
- then:
- lambda: |-
- if (id(ehmtx_time).now().day_of_week == 7) {
- id(rgb8x32)->icon_clock("calendar|day#2", 525600, 10, true);
- id(rgb8x32)->set_infotext_color(50, 50, 50, 50, 50, 50, true, 1);
- id(rgb8x32)->expand_icon_to_9(3);
- id(rgb8x32)->set_calendar_color(255,0,0);
- id(rgb8x32)->set_today_color(255,0,0);
- }
- else if (id(ehmtx_time).now().day_of_week == 1) {
- id(rgb8x32)->icon_clock("calendar|day#2", 525600, 10, true);
- id(rgb8x32)->set_infotext_color(50, 50, 50, 50, 50, 50, true, 1);
- id(rgb8x32)->expand_icon_to_9(3);
- id(rgb8x32)->set_calendar_color(255,0,0);
- id(rgb8x32)->set_today_color(255,0,0);
- }
- else {
- id(rgb8x32)->icon_clock("calendar|day#2", 525600, 10, true);
- id(rgb8x32)->set_infotext_color(50, 50, 50, 50, 50, 50, true, 1);
- id(rgb8x32)->expand_icon_to_9(3);
- id(rgb8x32)->set_calendar_color(255,0,0);
- id(rgb8x32)->set_today_color(0,255,255);
- }
- on_empty_queue:
- then:
- lambda: |-
- if (id(ehmtx_time).now().day_of_week == 7) {
- id(rgb8x32)->icon_clock("calendar|day#2", 525600, 10, true);
- id(rgb8x32)->set_infotext_color(50, 50, 50, 50, 50, 50, true, 1);
- id(rgb8x32)->expand_icon_to_9(3);
- id(rgb8x32)->set_calendar_color(255,0,0);
- id(rgb8x32)->set_today_color(255,0,0);
- }
- else if (id(ehmtx_time).now().day_of_week == 1) {
- id(rgb8x32)->icon_clock("calendar_|day#2", 525600, 10, true);
- id(rgb8x32)->set_infotext_color(50, 50, 50, 50, 50, 50, true, 1);
- id(rgb8x32)->expand_icon_to_9(3);
- id(rgb8x32)->set_calendar_color(255,0,0);
- id(rgb8x32)->set_today_color(255,0,0);
- }
- else {
- id(rgb8x32)->icon_clock("calendar|day#2", 525600, 10, true);
- id(rgb8x32)->set_infotext_color(50, 50, 50, 50, 50, 50, true, 1);
- id(rgb8x32)->expand_icon_to_9(3);
- id(rgb8x32)->set_calendar_color(255,0,0);
- id(rgb8x32)->set_today_color(0,255,255);
- }
- on_next_screen:
- - homeassistant.event:
- event: esphome.new_screen
- data_template:
- iconname: !lambda "return icon.c_str();"
- text: !lambda "return text.c_str();"
- - lambda: |-
- id(current_screen).publish_state(icon.c_str());
- on_next_clock:
- lambda: |-
- id(current_screen).publish_state("Clock");
- on_add_screen:
- - homeassistant.event:
- event: esphome.add_screen
- data_template:
- icon: !lambda "return icon.c_str();"
- mode: !lambda "return mode;"
- # https://developer.lametric.com/icons
- icons:
- - id: home_assistant
- lameid: 56370
- - id: temperature_cold
- lameid: 6980
- - id: temperature_home
- lameid: 22295
- - id: temperature_hot
- lameid: 9275
- - id: temperature
- lameid: 13593
- - id: temperature_down
- lameid: 19649
- - id: temperature_up
- lameid: 19650
- - id: bell
- lameid: 55163
- - id: door_open
- lameid: 21376
- - id: umbrella
- lameid: 41619
- - id: snow
- lameid: 17140
- - id: weather_clear_night #чистая ночь
- lameid: 26086
- - id: weather_exceptional
- lameid: 16754
- - id: weather_fog #туман
- lameid: 56703
- - id: weather_lightning #гроза
- lameid: 60936
- - id: weather_lightning_rainy #дождь с грозой
- lameid: 49299
- - id: weather_partlycloudy #малооблачно
- lameid: 60931
- - id: weather_cloudy #облачно
- lameid: 22160
- - id: weather_overcast #пасмурно
- lameid: 2283
- - id: weather_pouring #ливень
- lameid: 49300
- - id: weather_rainy #сильный дождь
- lameid: 2284
- - id: weather_extreme_rain #длительный сильный дождь
- lameid: 60932
- - id: weather_small_rain #небольшой дождь
- lameid: 60930
- - id: weather_hail #град
- lameid: 60933
- - id: weather_drizzle #морось
- lameid: 60934
- - id: weather_lightning_hail #гроза с градом
- lameid: 60935
- - id: weather_snowy #снег
- lameid: 2289
- - id: weather_snowfall #снегопад
- lameid: 60937
- - id: weather_small_snow #небольшой снег
- lameid: 60938
- - id: weather_snowy_rainy #снег с дождем
- lameid: 49301
- - id: weather_sunny #солнечно
- lameid: 2282
- - id: weather_windy
- lameid: 21909
- - id: weather_windy_variant
- lameid: 21909
- - id: weather_cloudy_night # луна и облачно
- lameid: 60950
- - id: weather_moon_drizzle # луна и дождь
- lameid: 26091
- - id: weather_moon_rain # луна и сильный дождь
- lameid: 26092
- - id: weather_moon_lightning # луна и молния
- lameid: 60939
- - id: weather_moon_fog # луна и туман
- lameid: 26085
- - id: humidifier
- lameid: 53067
- - id: humidity_out
- lameid: 39042
- - id: humidity_home
- lameid: 39041
- - id: wind
- lameid: 17076
- - id: wind_direction
- lameid: 21909
- - id: co2_aqi
- lameid: 44182
- - id: co2_good
- lameid: 60913
- - id: co2_middle
- lameid: 60916
- - id: co2_high
- lameid: 60917
- - id: pm25
- lameid: 38873
- - id: teapot
- lameid: 35124
- - id: doorbell
- lameid: 42802
- - id: washing
- lameid: 37472
- - id: purifier
- lameid: 21368
- - id: battery_full
- lameid: 12126
- - id: heart
- lameid: 5859
- - id: alice_listen
- lameid: 57047
- - id: alice_talking
- lameid: 57048
- - id: cover
- lameid: 32098
- - id: tv_on
- lameid: 9754
- - id: tv_off
- lameid: 13582
- - id: light_on
- lameid: 57051
- - id: alice_playing
- lameid: 57065
- - id: prognose
- lameid: 41116
- - id: alarma
- lameid: 34175
- - id: ozone
- lameid: 21688
- - id: chtree
- lameid: 47754
- - id: home
- lameid: 22737
- - id: door
- lameid: 42480
- - id: wnet
- lameid: 40695
- # - id: calendar
- # lameid: 55812
- # - id: calendar_r
- # lameid: 3575
- - id: shower
- lameid: 39805
- globals:
- # aab = auto-adjustable brightness
- - id: aab_enable
- type: "bool"
- restore_value: true
- initial_value: "true"
- - id: aab_add
- type: int
- initial_value: '5'
- - id: aab_max
- type: int
- initial_value: '220'
- - id: aab_min
- type: int
- initial_value: '20'
- font:
- # Matrix Clock Fonts
- # Grab these from hhttps://github.com/trip5/Matrix-Fonts
- # Store in a "fonts" subfolder of your ESPHome config folder or change paths below
- - file: fonts/MatrixChunky6.ttf
- size: 6
- id: default_font
- glyphs: |
- ! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz°|АаБбВвГ㥴ДдЕеЄєЖжЗзИиІіЇїЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЬьЮюЯяЁёЪъЫыЭэ℃₴€일월화수목금토
- - file: fonts/MatrixChunky8.ttf
- size: 8
- id: special_font
- glyphs: |
- ! "#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz°|АаБбВвГ㥴ДдЕеЄєЖжЗзИиІіЇїЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЬьЮюЯяЁёЪъЫыЭэ℃₴€일월화수목금토
- ### Home Assistant Entities
- binary_sensor:
- - platform: status
- name: ${name} Status
- device_class: connectivity
- - platform: gpio
- pin:
- number: $left_button_pin
- inverted: true
- name: "${name} Left button"
- - platform: gpio
- pin:
- inverted: true
- number: $mid_button_pin
- mode: INPUT_PULLUP
- name: "${name} Middle button"
- - platform: gpio
- pin:
- number: $right_button_pin
- inverted: true
- name: "${name} Right button"
- sensor:
- # - platform: sht3xd
- # temperature:
- # name: "${name} Temperature"
- # humidity:
- # name: "${name} Relative Humidity"
- # update_interval: ${update_interval}
- - platform: adc
- pin: $battery_pin
- name: "${name} Battery"
- id: battery_voltage
- update_interval: 10s
- device_class: battery
- accuracy_decimals: 0
- attenuation: auto
- filters:
- - sliding_window_moving_average:
- window_size: 15
- send_every: 15
- send_first_at: 1
- - multiply: 1.6
- - lambda: |-
- auto r = ((x - 3) / 0.69 * 100.00);
- if (r >= 100) return 100;
- if (r > 0) return r;
- if (r <= 0) return 1;
- return 0;
- unit_of_measurement: '%'
- - platform: adc
- id: light_sensor
- name: "${name} Illuminance"
- pin: $ldr_pin
- update_interval: 10s
- attenuation: auto
- unit_of_measurement: lx
- device_class: illuminance
- accuracy_decimals: 0
- filters:
- - lambda: |-
- return (x / 10000.0) * 2000000.0 - 15 ;
- on_value:
- then:
- - lambda: |-
- if ( id(aab_enable) )
- {
- int n = x / 4 + id(aab_add); // new_value
- if (n > id(aab_max)) n = id(aab_max);
- if (n < id(aab_min)) n = id(aab_min);
- int c = id(rgb8x32)->get_brightness(); // current value
- c = c > 0 ? c : 1;
- int d = (n - c) * 100 / c; // diff in %
- if (n > 50) id(rgb8x32)->set_brightness(190);
- else if (abs(d) > 2) id(rgb8x32)->set_brightness(n);
- }
- text_sensor:
- - platform: template
- name: "${name} Current Screen"
- id: current_screen
- update_interval: never
- icon: "mdi:overscan"
- entity_category: diagnostic
- switch:
- - platform: restart
- name: ${name} Restart
- - platform: template
- name: "${name} Auto-Adjust Brightness"
- id: switch_autobrightness
- icon: mdi:brightness-auto
- restore_mode: RESTORE_DEFAULT_ON
- lambda: |-
- if (id(aab_enable))
- {
- return true;
- }
- else
- {
- return false;
- }
- turn_on_action:
- lambda: |-
- id(aab_enable) = true;
- turn_off_action:
- lambda: |-
- id(aab_enable) = false;
- - platform: template
- name: "${name} Night Mode"
- id: switch_night_mode
- icon: mdi:weather-night
- restore_mode: RESTORE_DEFAULT_OFF
- lambda: |-
- return id(rgb8x32)->night_mode;
- turn_on_action:
- lambda: |-
- id(rgb8x32)->set_night_mode_on();
- turn_off_action:
- lambda: |-
- id(rgb8x32)->set_night_mode_off();
- - platform: template
- name: "${name} Display"
- icon: "mdi:clock-digital"
- restore_mode: ALWAYS_ON
- lambda: |-
- return id(rgb8x32)->show_display;
- turn_on_action:
- lambda: |-
- id(rgb8x32)->set_display_on();
- turn_off_action:
- lambda: |-
- id(rgb8x32)->set_display_off();
- number:
- - platform: template
- name: "${name} Brightness"
- min_value: 20
- max_value: 220
- step: 1
- lambda: |-
- return id(rgb8x32)->get_brightness();
- set_action:
- lambda: |-
- id(rgb8x32)->set_brightness(x);
- ### Firmware, Hardware, ESP
- substitutions:
- device: ulanzi_tram
- name: Ulanzi_tram
- location: ${name}
- update_interval: 60s
- reboot_timeout: 0s
- project_name: "Ulanzi.EHMTXv2"
- project_version: "2023.9.1"
- comment: "Ulanzi Pixel Clock"
- # Pin definition from https://github.com/aptonline/PixelIt_Ulanzi
- battery_pin: GPIO34
- buzzer_pin: GPIO15
- ldr_pin: GPIO35
- matrix_pin: GPIO32
- left_button_pin: GPIO26
- mid_button_pin: GPIO27
- right_button_pin: GPIO14
- scl_pin: GPIO22
- sda_pin: GPIO21
Advertisement
Add Comment
Please, Sign In to add comment