This is my EspHoMaTriX version 2 (EHMTXv2) Example Setup that I got working with TeddyCloud, HomeAssistant, ESPhome and MQTT
I made this Post, as I will also post some of my Demo automations that was shown at the 37C3 Talk in this Video
But as first step, I would like to show how i setup my Ulanzi TC0001 with ESPhome and EspHoMaTriX V2 in HomeAssistant and ESPhome, this step is needed to Display Informations form TeddyCloud on it.
The additional needed Files are (linked from the original GitHube Repo:
1pixel.gif
1pixel.gif
ESPHome Ulanzi.yaml
substitutions:
devicename: ulanzi
friendly_name: Ulanzi LED Matrix
board: esp32dev
# 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
switch:
- platform: template
name: "$devicename 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: "$devicename Display"
id: displaycontrol
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();
# - platform: template
# name: "$devicename Night Mode"
# id: nightmode
# icon: "mdi:weather-night"
# restore_mode: ALWAYS_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();
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: '20'
external_components:
- source:
type: git
url: https://github.com/lubeda/EspHoMaTriXv2
ref: main
refresh: 60s
components: [ ehmtxv2 ]
esphome:
comment: "EHMTXv2 from LuBeDa"
name: $devicename
project:
name: "Ulanzi.EHMTXv2"
version: "2.0.0"
on_boot:
then:
- ds1307.read_time:
image:
- file: 1pixel.gif
id: breaking20237
animation:
- file: 1pixel.gif
id: breaking202371
output:
- platform: ledc
pin: $buzzer_pin
id: rtttl_out
rtttl:
output: rtttl_out
esp32:
board: esp32dev
font:
# Font included in this folder
- file: fonts/mateine.ttf
size: 16
id: default_font
glyphs: |
!?"%&()+*=,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnÖÄÜöäüopqrstuvwxyz@<>ߧ€/
# Matrix Clock Fonts
# Grab these from https://github.com/trip5/Matrix-Fonts
# See https://github.com/lubeda/EspHoMaTriXv2#font
# Store in a "fonts" subfolder of your ESPHome config folder or change paths below
#- file: fonts/MatrixLight8.bdf
# id: default_font
# glyphs: |
# ! "#$%&'()*+,-.€/0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜß[\]^_`abcdefghijklmnopqrstuvwxyzäöü°
#- file: fonts/MatrixChunky6.bdf
# id: special_font
# glyphs: |
# ! "#$%&'()*+,-./0123456789:APMTapmt
binary_sensor:
- platform: status
name: "$devicename Status"
- platform: gpio
pin:
number: $left_button_pin
inverted: true
name: "$devicename Left button"
on_press:
lambda:
id(rgb8x32)->skip_screen();
- platform: gpio
pin:
inverted: true
number: $mid_button_pin
mode: INPUT_PULLUP
name: "$devicename Middle button"
on_press:
then:
- switch.toggle: displaycontrol
- platform: gpio
pin:
number: $right_button_pin
inverted: true
name: "$devicename Right button"
on_press:
lambda:
id(rgb8x32)->hold_screen(120);
number:
- platform: template
name: "$devicename LED brightness"
id: brightness
min_value: 0
max_value: 255
step: 1
lambda: |-
return id(rgb8x32)->get_brightness();
set_action:
lambda: |-
id(rgb8x32)->set_brightness(x);
logger:
level: WARN
api:
services:
- service: alarm
variables:
icon_name: string
message: string
then:
lambda: |-
id(rgb8x32)->icon_screen(icon_name,message,7,20,true);
id(rgb8x32)->force_screen(icon_name);
- service: tune
variables:
tune: string
then:
- rtttl.play:
rtttl: !lambda 'return tune;'
sensor:
- platform: sht3xd
temperature:
name: "$devicename Temperature"
humidity:
name: "$devicename Relative Humidity"
update_interval: 60s
- platform: adc
pin: $battery_pin
name: "$devicename 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: "$devicename 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 ( abs(d) > 2 ) id(rgb8x32)->set_brightness(n);
}
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
web_server:
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: "$devicename Light"
restore_mode: ALWAYS_OFF
time:
- platform: homeassistant
on_time_sync:
then:
ds1307.write_time:
- platform: ds1307
update_interval: never
id: ehmtx_time
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();
ehmtxv2:
id: rgb8x32
icons2html: true
matrix_component: ehmtx_display
time_component: ehmtx_time
#clock_interval: 5 # duration to display the clock after this time the date is display until next "show_screen"
date_format: "%d.%m" # defaults "%d.%m." (use "%m.%d." for the US)
time_format: "%H:%M" # defaults "%H:%M" (use "%I:%M%p" for the US)
show_seconds: false
show_dow: false # draw the day indicator on the bottom of the screen, defaults to true
show_date: false # show the date for show_screen - show_clock seconds otherwise only shows the clock for show_screen seconds, defaults to true
week_start_monday: true # default monday is first day of week, false = sunday
# Uncomment below if using the mateine font
default_font_id: default_font
special_font_id: default_font
# Comment out below if using mateine font
# default_font_id: default_font
default_font_yoffset: 8
# special_font_id: special_font
# special_font_yoffset: 6
# until here
scroll_interval: 80 # the interval in ms to scroll the text (default=80), should be a multiple of the update_interval from the display (default: 16ms)
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)
boot_logo: "[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63519,63519,63519,63519,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63519,0,0,0,0,2016,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,0,0,63488,0,63488,0,0,0,63519,0,0,0,0,2016,2016,0,0,0,65514,0,65514,0,0,0,31,0,0,0,64512,0,0,64512,0,63488,63488,0,63488,63488,0,0,63519,63519,63519,0,0,2016,0,2016,0,65514,0,65514,0,65514,0,31,31,31,0,0,0,64512,64512,0,0,63488,63488,63488,63488,63488,0,0,63519,0,0,0,0,2016,0,2016,0,65514,0,65514,0,65514,0,0,31,0,0,0,0,64512,64512,0,0,0,63488,63488,63488,0,0,0,63519,63519,63519,63519,0,2016,0,2016,0,65514,0,65514,0,65514,0,0,0,31,31,0,64512,0,0,64512,0,0,0,63488,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]"
icons:
- id: ha
lameid: 7956
- id: tempc
lameid: 2422
- id: plug
lameid: 403
- id: humidity
lameid: 51764
- id: co2
lameid: 30662
- id: teddy
file: "teddy.gif"
- id: plex_play
lameid: 45671
- id: plex_pause
lameid: 45672
- id: fon
lameid: 14647
on_next_screen:
- homeassistant.event:
event: esphome.new_screen
data_template:
iconname: !lambda "return icon.c_str();"
text: !lambda "return text.c_str();"
If you need a more detailed howto on setup your Ulanzi with EspHoMaTriX version 2 (EHMTXv2) please visit the original Project