I’ve finally gotten my matrix led to work, thanks to the new function pixelmapper for that in ESPHome, THANKYOU for that!
I’ve toyed with ESPHomeMatrixLED/matrixleddemo.yaml at 69a054d0a0de2f855e3a9d1271437b87313ed3d4 · rnauber/ESPHomeMatrixLED · GitHub for quite a while, but had given up, until this function in ESPHome came up.
So now I actually have a scrolling 32x8 display, soooo cool
I would however very much like to set the color of the scrolling text from HA, and I have no idea how to accomplish that.
Looking in rnauber’s code it’s set statically.
With this I can send a text string to it via MQTT, and I can turn it on and off.
The color setting for the light entity is unfortunately not used. If I change the color it is shortly flashed on the display, and then it continues the text scrolling in the fixed color (currently red).
Is there a way I can use the color set (or have it set through a colorwheel on ha somehow), and transfer it to the it.print command?
I want to set this up for my “studio” so I can warn others of recording taking place And it would be great to be able to set the color.through an automatiion or something like that.
Hey fribse,
not sure if you could solve it in the meantime but I had the same request as I was trying to make a little display for my dad that shows the temperature status for a boiler. My not-so-elegant workaround was as follows:
I defined my colours in the Display segment (see below as “auto temp”) and made the R G B values sensors. These are then connected to my MQTT Broker and get injected via Node Red.
Trying to get the same thing done. for some reason the compiler is not liking auto temp = Color(id(temp_red).state, id(temp_green).state, id(temp_blue).state);
Ideally, I would like to define some colors, I only really need 3 or 4 colors. Define them like @fribse did above:
Hi @serimi89
I whish I had any experience with C++ coding, because this is so close.
I would like to be able to just set a color in HA (with a regular colorwheel), and then have it picked up in the it.print.
I tried different variations of this:
But I can’t make it work And it’s simply because of my lack of knowledge in C++ I guess.
I then thought about the Light MQTT platform.
If I could split up the RGB value there, into three different topics, then it would be great, and I could just use your example.
But how do I create a template that sends the three variables red, green and blue into different topics?
So far I’ve gotten to this:
Great news here. @ssieb has been a real gem here, and used a LOT of time on me, thankyou very very much, and he got everything working.
So now there are two settings that’s in HA.
A helper, in this case called input_text.matrix1_scrolling_text
That holds the text to be shown on the matrix sign
And then the ESPHome code is going to make a single light that holds colour and brightness.
This is the code
substitutions:
device_name: Matrix1
espname: matrix1
xscrollpadding: "8" # in pix
device_description: "10.11.13.149 Matrix display that shows scrolling text published on MQTT"
esphome:
name: '${espname}'
comment: '${device_description}'
platform: esp8266
board: esp8285
on_boot:
- light.turn_off: matrixcolor
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
reboot_timeout: 60min
manual_ip:
static_ip: 10.11.13.149
gateway: 10.11.13.1
subnet: 255.255.255.0
ap:
ssid: "${device_name} Hotspot"
password: !secret appw
logger:
baud_rate: 0
api:
password: !secret apipw
ota:
password: !secret otapw
time:
- platform: homeassistant
id: homeassistant_time
sensor:
- platform: wifi_signal
name: '${device_name} wifi signal'
update_interval: 60s
accuracy_decimals: 0
- platform: uptime
name: '${device_name} uptime'
unit_of_measurement: days
update_interval: 300s
accuracy_decimals: 1
filters:
- multiply: 0.000011574
text_sensor:
- platform: version
name: "${device_name} ESPHome Version"
- platform: wifi_info
ip_address:
name: "${device_name} ip"
ssid:
name: "${device_name} ssid"
- platform: homeassistant
entity_id: input_text.matrix1_scrolling_text
id: scrolltext
font:
- id: tinyfont
file: "DejaVuSans-Bold.ttf"
size: 9
glyphs: '♡ÆØÅæøå!"%()+,-_.:*=°?~#0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz'
light:
- platform: neopixelbus
type: GRB
variant: WS2812X
pin: GPIO2
num_leds: 256
id: matrix
default_transition_length: 0s
color_correct: [50%, 50%, 50%]
internal: true
- platform: rgb
name: "Scrolling Sign"
id: matrixcolor
red: output_red
green: output_green
blue: output_blue
on_turn_on:
- switch.turn_on: matrixpower
- light.turn_on: matrix
on_turn_off:
- switch.turn_off: matrixpower
- light.turn_off: matrix
# Turns the relay for the LED's on / off, saves power by not having them supplied when the sign is off
switch:
- platform: gpio
pin: GPIO5
id: matrixpower
internal: true
# Used for extraction of colours from the RGB light, to be used in it.print
output:
- platform: template
id: output_red
type: float
write_action:
lambda: ;
- platform: template
id: output_green
type: float
write_action:
lambda: ;
- platform: template
id: output_blue
type: float
write_action:
lambda: ;
display:
- platform: addressable_light
id: matrix_display
addressable_light_id: matrix
width: 32
height: 8
pixel_mapper: |-
if (x % 2 == 0) {
return (x * 8) + y;
}
return (x * 8) + (7 - y);
rotation: 0° # Which way is the text scrolled
update_interval: 200ms # Scroll speed
lambda: |-
static uint16_t xpos = 0;
const char * text = id(scrolltext).state.c_str();
int x_start, y_start;
int width, height;
it.get_text_bounds(0, 0, text, id(tinyfont),
TextAlign::TOP_LEFT, &x_start, &y_start, &width, &height);
auto values = id(matrixcolor).current_values;
float brightness = values.get_brightness();
Color color(values.get_red() * brightness * 255, values.get_green() * brightness * 255, values.get_blue() * brightness * 255);
it.print(-(xpos % (width + $xscrollpadding)), -2,
id(tinyfont), color,
TextAlign::TOP_LEFT, text);
xpos++;
I can’t take ANY credit for this, the code is borrowed, stolen and given to me