bosmanrja
(RJA Bosman)
March 7, 2024, 3:00pm
1
Hello,
I have a 7 segment display max7219 connected to an ESP32. It seems that the wiring is right and the build is okay but I don’t know how to send text from homeassistant to the display.
I have used the following code at the end of the YAML but I don’t know how to call from homeassistant:
Example configuration entry
spi:
clk_pin: GPIO14
mosi_pin: GPIO15
display:
platform: max7219
cs_pin: GPIO13
num_chips: 1
lambda: |-
it.print(“01234567”);
Can try following:
text_sensor:
- platform: template
id: string_to_display
name: String to Display
api:
services:
- service: string_publish
variables:
string_from_ha: string
then:
- lambda: |-
id(string_to_display).publish_state(string_from_ha);
display:
- platform: max7219
...
lambda: |-
it.printf("%s", id(string_to_display).state);
Then on HA side You can publish string by calling
service: esphome.<Your_device_name>_string_publish
data:
string_from_ha: hello
1 Like
bosmanrja
(RJA Bosman)
March 12, 2024, 8:29pm
3
Thanks, the display works but parsing values from homeassistant not perfect, probably my own problem …
bosmanrja
(RJA Bosman)
March 20, 2024, 2:38pm
4
I can’t find the solution for parsing values to the display.
I use the following code:
---
substitutions:
device_name: esphome-testkit
device_description: "ESPHome testkit"
device_key: "????"
device_ota_pass: "???"
esphome:
name: ${device_name}
comment: "${device_description}"
friendly_name: "${device_description}"
esp32:
board: esp32dev
framework:
type: arduino
# Enable Home Assistant API
api:
encryption:
key: ${device_key}
# Services t.b.v. MAX7219
services:
- service: string_publish
variables:
string_from_ha: string
then:
- lambda: |-
id(string_to_display).publish_state(string_from_ha);
ota:
password: ${device_ota_pass}
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
.
.
.
.
text_sensor:
- platform: template
id: string_to_display
name: String to Display
spi:
# t.b.v. MAX7219 sclk_pin en mosi_pin
clk_pin: GPIO14
mosi_pin: GPIO2
display:
- platform: max7219
cs_pin: GPIO13
num_chips: 1
lambda: |-
it.printf("%s", id(string_to_display).state);
In Homeassistant I see that the state of ‘sensor.esphome_testkit_string_to_display’ is ‘123456’ but the display shows strange chars suct as ‘8.|8.p’.
Can somebody explain what is wrong?
Thanks!