Good morning,
In ESPHome, I have a 64*64 MATRIX screen and I have configured 2 display pages on it.
I have configured an interval of 5 seconds for the display so that each page is displayed alternately but I would like to put a condition on it.
That is to say, activate the interval sequence only if printing is in progress, otherwise only display the first page.
Below is my current code:
esphome:
name: "esp-matrix"
friendly_name: ESP-Matrix
external_components:
- source: github://TillFleisch/ESPHome-HUB75-MatrixDisplayWrapper@main
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "***************"
ota:
password: "****************"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
manual_ip:
static_ip: 192.168.1.121
gateway: 192.168.1.1
subnet: 255.255.255.0
dns1: 192.168.1.1
ap:
ssid: "Esp-Test Fallback Hotspot"
password: "************"
captive_portal:
# codage
sensor:
- platform: wifi_signal
name: "WiFi Signal"
update_interval: 10s
- platform: homeassistant
id: meteo
entity_id: weather.chelles
attribute: temperature
- platform: homeassistant
id: x1c_pourcentage
entity_id: sensor.x1c_00m09c422100198_progression_de_l_impression
- platform: homeassistant
id: etat_impression
entity_id: sensor.x1c_00m09c422100198_etat_de_l_impression
time:
- platform: homeassistant
id: esptime
text_sensor:
- platform: homeassistant
id: temps
entity_id: weather.chelles
- platform: homeassistant
id: finish_print_date
entity_id: sensor.impression_3d_5
- platform: homeassistant
id: finish_print_heure
entity_id: sensor.impression_3d_6
font:
- file: "/config/esphome/materialdesignicons-webfont.ttf"
id: icon
size: 15
glyphs: &mdi-weather-glyphs
- "\U000F0590" # mdi-weather-cloudy
- "\U000F0F2F" # mdi-weather-cloudy-alert
- "\U000F0E6E" # mdi-weather-cloudy-arrow-right
- "\U000F0591" # mdi-weather-fog
- "\U000F0592" # mdi-weather-hail
- "\U000F0F30" # mdi-weather-hazy
- "\U000F0898" # mdi-weather-hurricane
- "\U000F0593" # mdi-weather-lightning
- "\U000F067E" # mdi-weather-lightning-rainy
- "\U000F0594" # mdi-weather-night
- "\U000F0F31" # mdi-weather-night-partly-cloudy
- "\U000F0595" # mdi-weather-partly-cloudy
- "\U000F0F32" # mdi-weather-partly-lightning
- "\U000F0F33" # mdi-weather-partly-rainy
- "\U000F0F34" # mdi-weather-partly-snowy
- "\U000F0F35" # mdi-weather-partly-snowy-rainy
- "\U000F0596" # mdi-weather-pouring
- "\U000F0597" # mdi-weather-rainy
- "\U000F0598" # mdi-weather-snowy
- "\U000F0F36" # mdi-weather-snowy-heavy
- "\U000F067F" # mdi-weather-snowy-rainy
- "\U000F0599" # mdi-weather-sunny
- "\U000F0F37" # mdi-weather-sunny-alert
- "\U000F14E4" # mdi-weather-sunny-off
- "\U000F059A" # mdi-weather-sunset
- "\U000F059B" # mdi-weather-sunset-down
- "\U000F059C" # mdi-weather-sunset-up
- "\U000F0F38" # mdi-weather-tornado
- "\U000F059D" # mdi-weather-windy
- "\U000F059E" # mdi-weather-windy-variant
- "\U000F00E9" # mdi-cake
- "\U000F0A70" # mdi-silverware-fork-knife
- "\U000F1A74" # mdi-solar-power-variant-outline
- "\U000F1904" # mdi-home-lightning-bolt-outline
- "\U000F05C3" # mdi-youtube
- "\U000F05D6" # mdi-alert-circle-outline
- file: "/config/esphome/Roboto.ttf"
id: roboto6
size: 6
- file: "/config/esphome/Roboto.ttf"
id: roboto8
size: 8
- file: "/config/esphome/Roboto.ttf"
id: roboto12
size: 12
- file: "/config/esphome/FreeSansBold.ttf"
id: freesb12
size: 12
- file: "/config/esphome/FreeSansBold.ttf"
id: freesb8
size: 8
display:
- platform: hub75_matrix_display
id: matrix
width: 64
height: 64
R1_pin: 25
G1_pin: 26
B1_pin: 27
R2_pin: 14
G2_pin: 12
B2_pin: 13
A_pin: 23
B_pin: 19
C_pin: 5
D_pin: 17
E_pin: 18
LAT_pin: 22
OE_pin: 15
CLK_pin: 16
driver: MBI5124
i2sspeed: HZ_20M
latch_blanking: 4
clock_phase: false
update_interval: 8 ms
pages:
- id: page1
lambda: |-
std::map<std::string, std::string> weather_icon_map
{
{"cloudy", "\U000F0590"},
{"cloudy-alert", "\U000F0F2F"},
{"cloudy-arrow-right", "\U000F0E6E"},
{"fog", "\U000F0591"},
{"hail", "\U000F0592"},
{"hazy", "\U000F0F30"},
{"hurricane", "\U000F0898"},
{"lightning", "\U000F0593"},
{"lightning-rainy", "\U000F067E"},
{"night", "\U000F0594"},
{"night-partly-cloudy", "\U000F0F31"},
{"partlycloudy", "\U000F0595"},
{"partly-lightning", "\U000F0F32"},
{"partly-rainy", "\U000F0F33"},
{"partly-snowy", "\U000F0F34"},
{"partly-snowy-rainy", "\U000F0F35"},
{"pouring", "\U000F0596"},
{"rainy", "\U000F0597"},
{"snowy", "\U000F0598"},
{"snowy-heavy", "\U000F0F36"},
{"snowy-rainy", "\U000F067F"},
{"sunny", "\U000F0599"},
{"sunny-alert", "\U000F0F37"},
{"sunny-off", "\U000F14E4"},
{"sunset", "\U000F059A"},
{"sunset-down", "\U000F059B"},
{"sunset-up", "\U000F059C"},
{"tornado", "\U000F0F38"},
{"windy", "\U000F059D"},
{"windy-variant", "\U000F059E"},
};
std::map<std::string, std::string> weather_traduction
{
{"cloudy", "Nuageux"},
{"cloudy-alert", "Alerte"},
{"cloudy-arrow-right", "--"},
{"fog", "Brouillard"},
{"hail", "Grêle"},
{"hazy", "Brume"},
{"hurricane", "Ouragan"},
{"lightning", "Orage"},
{"lightning-rainy", "Orageux"},
{"night", "Nuit"},
{"night-partly-cloudy", "Nuageux"},
{"partlycloudy", "Nuageux"},
{"partly-lightning", "Orageux"},
{"partly-rainy", "Pluvieux"},
{"partly-snowy", "Neigeux"},
{"partly-snowy-rainy", "Neigeux"},
{"pouring", "À verse"},
{"rainy", "Pluvieux"},
{"snowy", "Neigeux"},
{"snowy-heavy", "Neigeux"},
{"snowy-rainy", "Neigeux"},
{"sunny", "Ensoleillé"},
{"sunny-alert", "Alerte"},
{"sunny-off", "--"},
{"sunset", "Crépuscule"},
{"sunset-down", "Crépuscule"},
{"sunset-up", "Aube"},
{"tornado", "Tornade"},
{"windy", "Venteux"},
{"windy-variant", "Venteux"},
};
it.strftime(32, 0, id(freesb8), TextAlign::TOP_CENTER, "%d-%m-%Y", id(esptime).now());
it.strftime(32, 10, id(freesb12), TextAlign::TOP_CENTER, "%H:%M:%S", id(esptime).now());
it.printf(32, 26, id(freesb12), TextAlign::TOP_CENTER, "%.1f°C", id(meteo).state);
it.printf(32, 44, id(icon), TextAlign::TOP_CENTER, "%s", weather_icon_map[id(temps).state].c_str());
- id: page2
lambda: |-
it.print(32, 0, id(roboto8), TextAlign::TOP_CENTER, "IMPRESSION");
it.printf(32, 8, id(freesb12), TextAlign::TOP_CENTER, "%.2f %%", id(x1c_pourcentage).state);
it.print(32, 22, id(roboto8), TextAlign::TOP_CENTER, "Fini le :");
it.printf(32, 32, id(roboto8), TextAlign::TOP_CENTER, id(finish_print_date).state.c_str());
it.print(32, 42, id(roboto8), TextAlign::TOP_CENTER, "a :");
it.printf(32, 50, id(roboto8), TextAlign::TOP_CENTER, id(finish_print_heure).state.c_str());
interval:
- interval: 5s
then:
- display.page.show_next: matrix
- component.update: matrix
switch:
- platform: hub75_matrix_display
matrix_id: matrix
name: "Power"
id: power
restore_mode: ALWAYS_ON
number:
- platform: hub75_matrix_display
matrix_id: matrix
name: "Brightness"