--- # https://github.com/lubeda/EspHoMaTriXv2 substitutions: name: ulanzi friendly_name: Ulanzi static_ip: 10.18.44.207 battery_pin: GPIO34 ldr_pin: GPIO35 matrix_pin: GPIO32 left_button_pin: GPIO26 mid_button_pin: GPIO27 right_button_pin: GPIO14 buzzer_pin: GPIO15 scl_pin: GPIO22 sda_pin: GPIO21 packages: board: !include boards/esp32dev.yaml base: !include common/base.yaml external_components: - source: type: local path: custom_components refresh: 60s components: [ehmtxv2] esphome: name: ${name} friendly_name: ${friendly_name} on_boot: then: - ds1307.read_time: api: web_server: globals: # aab = auto-adjustable brightness - id: aab_enable type: "bool" restore_value: true initial_value: "true" - id: aab_add type: int initial_value: '10' - id: aab_max type: int initial_value: '220' - id: aab_min type: int initial_value: '29' - id: aab_multiplier type: float initial_value: '1.05' - id: netwarn type: "int" initial_value: "2" time: - platform: homeassistant on_time_sync: then: ds1307.write_time: - platform: ds1307 update_interval: never id: ehmtx_time on_time: - seconds: 0 minutes: 37 hours: 1,5 then: - lambda: |- ESP_LOGI("lambda", "Resetting clock"); id(rgb8x32)->del_screen("*", 2); id(rgb8x32)->del_screen("*", 3); id(rgb8x32)->del_screen("*", 5); id(rgb8x32)->clock_screen(1440, 10, true, 255, 255, 255); id(rgb8x32)->date_screen(1440, 5, true, 255, 255, 255); font: - file: fonts/DMDSmall.ttf id: default_font size: 16 glyphs: '!?"%()+*=,-_.:0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnÖÄÜöäüopqrstuvwxyz@<>ß/' - file: fonts/MatrixChunky6.bdf id: special_font glyphs: | ! "#$%&'()*+,-./0123456789:APMTapmt # https://github.com/lubeda/EspHoMaTriXv2/blob/7ee13ba06a823c92ec656bebe4885ba3648dac9d/README.md#attention image: - file: icons/1pixel.gif id: breaking20237 animation: - file: icons/1pixel.gif id: breaking202371 i2c: sda: $sda_pin scl: $scl_pin scan: true id: i2cbus output: - platform: gpio pin: number: $buzzer_pin ignore_strapping_warning: true id: buzzer_pin number: - platform: template id: screen_brightness name: "brightness" min_value: 0 max_value: 255 update_interval: 10s step: 25 lambda: |- return id(rgb8x32)->get_brightness(); set_action: lambda: |- id(rgb8x32)->set_brightness(x); interval: - interval: 2s startup_delay: 30s then: - lambda: |- if (id(wan).state && id(wired_wan).state) { if (id(netwarn) != 0) id(rgb8x32)->hide_alarm(); id(netwarn) = 0; } else if (id(wan).state && ! id(wired_wan).state) { if (! id(netwarn) != 1) id(rgb8x32)->show_alarm(255, 200, 0, 2); id(netwarn) = 1; } else { if (! id(netwarn) != 2) id(rgb8x32)->show_alarm(255, 0, 0, 3); id(netwarn) = 2; } switch: - platform: template 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 id: switch_display name: "Display" icon: "mdi:power" 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(); binary_sensor: - platform: status name: "Status" - platform: homeassistant id: wired_wan entity_id: binary_sensor.wired_wan - platform: homeassistant id: wan entity_id: binary_sensor.wan - platform: gpio name: "left button" pin: number: $left_button_pin inverted: true - platform: gpio name: "middle button" pin: inverted: true number: $mid_button_pin mode: INPUT_PULLUP - platform: gpio name: "right button" pin: number: $right_button_pin inverted: true 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: "Light" restore_mode: ALWAYS_OFF 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 lambda: |- id(rgb8x32)->tick(); id(rgb8x32)->draw(); sensor: - platform: sht3xd temperature: name: "Temperature" humidity: name: "Relative Humidity" update_interval: 60s - platform: adc pin: $battery_pin name: "Battery" id: battery_voltage update_interval: 60s 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: "Illuminance" pin: $ldr_pin update_interval: 10s attenuation: auto device_class: illuminance unit_of_measurement: lx accuracy_decimals: 0 filters: - lambda: |- return (x / 10000.0) * 2000000.0 - 13; on_value: then: - lambda: |- if (id(aab_enable)) { int n = x / 4 * id(aab_multiplier) + id(aab_add); if (n > id(aab_max)) n = id(aab_max); if (n < id(aab_min)) n = id(aab_min); ESP_LOGD("lambda", "Auto-adjusted brightness from sensor: %i", n); int c = id(rgb8x32)->get_brightness(); c = c > 0 ? c : 1; ESP_LOGD("lambda", "Current brightness: %i", c); int D = 2 + (n + c) / 100; if (abs(n - c) > D) id(rgb8x32)->set_brightness(n); } ehmtxv2: id: rgb8x32 icons2html: true matrix_component: ehmtx_display time_component: ehmtx_time time_format: "%H:%M" date_format: "%d %b" show_seconds: false default_font_id: default_font default_font_yoffset: 6 special_font_id: default_font special_font_yoffset: 6 week_start_monday: true # false equals sunday icons: - id: warning file: icons/8x8/warning.gif - id: knight_rider file: icons/8x8/knight_rider.gif - id: baby_girl file: icons/8x8/baby_girl.gif - id: ha file: icons/8x8/ha.gif - id: humidity file: icons/8x8/humidity.gif - id: temperature file: icons/8x8/temperature.png on_start_running: then: - lambda: |- ESP_LOGI("lambda", "Screen started, adding clock"); id(rgb8x32)->del_screen("*", 2); id(rgb8x32)->del_screen("*", 3); id(rgb8x32)->del_screen("*", 5); id(rgb8x32)->clock_screen(1440, 10, true, 255, 255, 255); id(rgb8x32)->date_screen(1440, 5, true, 255, 255, 255); on_add_screen: then: - lambda: |- ESP_LOGI("lambda", "Added screen: %s, mode: %s", icon.c_str(), mode); on_next_clock: then: - lambda: |- ESP_LOGI("lambda", "Next screen: clock"); on_next_screen: then: - lambda: |- ESP_LOGI("lambda", "Next screen: %s", icon.c_str()); - homeassistant.event: event: esphome.ulanzi_new_screen data_template: iconname: !lambda "return icon.c_str();" text: !lambda "return text.c_str();" on_expired_screen: then: - lambda: |- ESP_LOGI("lambda", "Expired screen: %s", icon.c_str());