ESP and change lambda page in specific time

Hi,

i would like to ask you. I have two pages in lambda and i need to switch lambda from one to other one in specific time. Is it possible?

I think i can do it via this line, but i dont know how to write change it.
I need switch from page1 to page2 from 7am till 9am and the nswitch it back to page1.

image

Can you help me please?

Try HA time source:
https://esphome.io/components/time/homeassistant.html

Then use on_time trigger as described here:

1 Like

Something like this:

time:
  - platform: homeassistant
    on_time:
      - seconds: 0
        minutes: 0
        hours: 7
        then:
          - display.page.show: page2
          - component.update: epaper
      - seconds: 0
        minutes: 0
        hours: 9
        then:
          - display.page.show: page1
          - component.update: epaper

its not working :frowning:
image

My bad. Delete the second on_time. I’ve updated the post to reflect this.

i dont know why but if i add time code to my yaml, all looks ok, yaml is valid. But when i upload this to my esp8266, esp is bricked…

This is my yaml

esphome:
  name: epaper
  friendly_name: ePaper

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "xSRGJlGi7MeioRooW9e56yIe4bRC4XPYn5c+hQhxinE="

ota:
  - platform: esphome
    password: "d9ebd26a2bf16a45451ff134d3dd0f70"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Epaper Fallback Hotspot"
    password: "ln6jD4MgFKZD"

captive_portal:
  
 # Nic vyse nemenit!!!!

sensor:
# jednotlive senzory, ktere se budou zobrazovat
  - platform: homeassistant
    name: "Outside Temperature in Sobin"
    id: outside_temp
    entity_id: weather.forecast_sobin
    attribute: temperature

  - platform: homeassistant
    name: "Teplota v obyvacim pokoji"
    id: teplota_obyvak
    entity_id: sensor.teplomer_teplota

  - platform: homeassistant
    name: "Teplota v predsini"
    id: teplota_predsin
    entity_id: sensor.shelly_dvere_vstupni_temperature

  - platform: homeassistant
    name: "Teplota v loznici"
    id: teplota_loznice
    entity_id: sensor.teplomer_loznice_teplota

# Textove senzory
text_sensor:
  - platform: homeassistant
    name: svatek
    id: dnes_ma_svatek
    entity_id: sensor.dnes_ma_svatek

  - platform: homeassistant
    name: "Vychod slunce"
    id: vychod_slunce
    entity_id: sensor.vychod_slunce

  - platform: homeassistant
    name: "Zapad slunce"
    id: zapad_slunce
    entity_id: sensor.zapad_slunce

  - platform: homeassistant
    name: "Aktualni den v tydnu"
    id: aktualni_den
    entity_id: sensor.aktualni_den

  - platform: homeassistant
    name: "Aktualni pocasi"
    entity_id: weather.forecast_sobin
    id: aktualni_pocasi

  - platform: homeassistant
    name: "Bus1"
    entity_id: sensor.blatnicka_b_departure_1
    id: Bus1

  - platform: homeassistant
    name: "Bus2"
    entity_id: sensor.blatnicka_b_departure_2
    id: Bus2

  - platform: homeassistant
    name: "Zpozdeni1"
    entity_id: sensor.zpozdeni_1
    id: Zpozdeni1

  - platform: homeassistant
    name: "Zpozdeni2"
    entity_id: sensor.zpozdeni_2
    id: Zpozdeni2

  - platform: homeassistant
    name: "Odjezdza1"
    entity_id: sensor.odjezd_za_1
    id: Odjezdza1

  - platform: homeassistant
    name: "Odjezdza2"
    entity_id: sensor.odjezd_za_2
    id: Odjezdza2

# Ikonky na ePaper
image:
  - file: mdi:home-export-outline
    id: outdooricon
    resize: 40x40

  - file: mdi:sofa
    id: sofa
    resize: 40x40

  - file: mdi:door
    id: door
    resize: 40x40

  - file: mdi:bed
    id: bed
    resize: 40x40

  - file: mdi:weather-sunny
    id: vychod
    resize: 20x20

  - file: mdi:moon-full
    id: zapad
    resize: 20x20

  # SPI for display
spi:
  clk_pin: 14
  mosi_pin: 13

font:
  - file: 'fonts/calibrib.ttf'
    id: pismo
    size: 36

  - file: 'fonts/calibrib.ttf'
    id: pismomale
    size: 18

  - file: 'fonts/tahoma.ttf'
    id: tahoma
    size: 18

time:
  - platform: homeassistant
    on_time:
      - seconds: 0
        minutes: 0
        hours: 7
        then:
          - display.page.show: page2
          - component.update: epaper
      - seconds: 0
        minutes: 0
        hours: 9
        then:
          - display.page.show: page1
          - component.update: epaper

external_components:
  - source: github://pr#6209
    components: [ waveshare_epaper ]

display:
  - platform: waveshare_epaper
    cs_pin: 15
    dc_pin: 4
    busy_pin: 5
    reset_pin: 2
    id: epaper
    # The model of the E-Paper display
    #model: 2.70in
    model: 4.20in-v2
    update_interval: 120s
    # If everything works, try to set full_update_every to 30 or 60
    full_update_every: 120
    rotation: 0
    pages:
    - id: page1
      lambda: |-
        it.line(300, 90, 400, 90);
        it.line(300, 0, 300, 90);

        it.line(10, 210, 10, 265);
        it.line(10, 265, 87, 265);
        it.line(87, 210, 87, 265);
        it.line(10, 210, 87, 210);

        it.line(97, 265, 184, 265);
        it.line(97, 210, 97, 265);
        it.line(184, 210, 184, 265); 
        it.line(97, 210, 184, 210); 

        it.line(194, 265, 281, 265);
        it.line(194, 210, 194, 265);
        it.line(281, 210, 281, 265); 
        it.line(194, 210, 281, 210); 

        it.line(291, 265, 378, 265);
        it.line(291, 210, 291, 265);
        it.line(378, 210, 378, 265); 
        it.line(291, 210, 378, 210); 

        it.line(0, 275, 400, 275);
        it.printf(26, 244, id(tahoma), "%.1f%°C", id(outside_temp).state);      
        it.printf(117, 244, id(tahoma), "%.1f%°C", id(teplota_obyvak).state);
        it.printf(215, 244, id(tahoma), "%.1f%°C", id(teplota_predsin).state); 
        it.printf(310, 244, id(tahoma), "%.1f%°C", id(teplota_loznice).state); 
        it.printf(335, 147, id(tahoma), "%s", id(vychod_slunce).state.c_str());
        it.printf(335, 177, id(tahoma), "%s", id(zapad_slunce).state.c_str());
        it.printf(200, 301, id(tahoma), TextAlign::BOTTOM_CENTER, "Dnes ma svatek %s", id(dnes_ma_svatek).state.c_str());
        it.image(28, 210, id(outdooricon));
        it.image(120, 210, id(sofa));
        it.image(217, 210, id(door));
        it.image(313, 210, id(bed));
        it.image(310, 150, id(vychod));
        it.image(310, 180, id(zapad));
        it.printf(3, 3, id(pismo), "%s", id(aktualni_den).state.c_str());
        it.strftime(3, 44, id(pismo), "%d.%m.%Y", id(cas).now());
     

    - id: page2
      lambda: |-
        it.printf(70, 5, id(pismo), "Odjezdy autobusu");             
        it.printf(150, 45, id(pismomale), "Blatnicka");  
        it.printf(5, 65, id(pismomale), "Bus");              
        it.printf(5, 90, id(pismomale), "%s", id(Bus1).state.c_str()); 
        it.printf(5, 115, id(pismomale), "%s", id(Bus2).state.c_str());               
        it.printf(40, 65, id(pismomale), "Odjezd za");    
        it.printf(40, 90, id(pismomale), "%s", id(Odjezdza1).state.c_str()); 
        it.printf(40, 115, id(pismomale), "%s", id(Odjezdza2).state.c_str());    
        it.printf(160, 65, id(pismomale), "Zpozdeni");
        it.printf(160, 90, id(pismomale), "%s", id(Zpozdeni1).state.c_str()); 
        it.printf(160, 115, id(pismomale), "%s", id(Zpozdeni2).state.c_str());     


This is log from esp…

19:50:00.112 -> 3fffff70:  3fff476c 00000005 3fff181c 4021ea5d  
19:50:00.112 -> 3fffff80:  0000001d 0000001d 3fff4a24 feefeffe  
19:50:00.112 -> 3fffff90:  0000001c 00000002 00000005 00000004  
19:50:00.152 -> 3fffffa0:  feefeffe feefeffe feefeffe 3fff1d10  
19:50:00.152 -> 3fffffb0:  3fffdad0 00000000 3fff1ce4 40231008  
19:50:00.152 -> 3fffffc0:  feefeffe feefeffe 3fffdab0 40100481  
19:50:00.152 -> <<<stack<<<
19:50:00.152 -> 
19:50:00.152 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
19:50:00.185 -> 
19:50:00.185 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,7)
19:50:00.185 -> 
19:50:00.185 -> load 0x4010f000, len 3424, room 16 
19:50:00.185 -> tail 0
19:50:00.185 -> chksum 0x2e
19:50:00.185 -> load 0x3fff20b8, len 40, room 8 
19:50:00.185 -> tail 0
19:50:00.185 -> chksum 0x2b
19:50:00.185 -> csum 0x2b
19:50:00.185 -> v000875e0
19:50:00.185 -> ~ld
19:50:00.254 ->     n r  n|  l rlb  |r l n  n l`  r l l  e[0;32m[I][logger:034]: Log initializede[0m
19:50:00.254 -> e[0;35m[C][safe_mode:079]: There have been 8 suspected unsuccessful boot attemptse[0m
19:50:00.254 -> e[0;32m[I][app:029]: Running through setup()...e[0m
19:50:00.254 -> e[0;36m[D][spi:039]: Setting up SPI bus...e[0m
19:50:00.302 -> e[0;36m[D][spi_device:379]: mode 0, data_rate 2000kHze[0m
19:50:00.909 -> 
19:50:00.909 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
19:50:00.909 -> 
19:50:00.909 -> Exception (29):
19:50:00.909 -> epc1=0x4000e1b2 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
19:50:00.909 -> 
19:50:00.909 -> >>>stack>>>
19:50:00.909 -> 
19:50:00.909 -> ctx: cont
19:50:00.909 -> sp: 3ffffe00 end: 3fffffd0 offset: 0150
19:50:00.951 -> 3fffff50:  3fff487c 00000190 3fff487c 40219577  
19:50:00.951 -> 3fffff60:  00000000 00000006 3fff487c 4021f13e  
19:50:00.951 -> 3fffff70:  3fff476c 00000005 3fff181c 4021ea5d  
19:50:00.951 -> 3fffff80:  0000001d 0000001d 3fff4a24 feefeffe  
19:50:00.951 -> 3fffff90:  0000001c 00000002 00000005 00000004  
19:50:00.951 -> 3fffffa0:  feefeffe feefeffe feefeffe 3fff1d10  
19:50:00.951 -> 3fffffb0:  3fffdad0 00000000 3fff1ce4 40231008  
19:50:00.951 -> 3fffffc0:  feefeffe feefeffe 3fffdab0 40100481  
19:50:00.951 -> <<<stack<<<
19:50:00.951 -> 
19:50:00.951 -> --------------- CUT HERE FOR EXCEPTION DECODER ---------------
19:50:00.985 -> 
19:50:00.985 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,7)
19:50:00.985 -> 
19:50:00.985 -> load 0x4010f000, len 3424, room 16 
19:50:00.985 -> tail 0
19:50:00.985 -> chksum 0x2e
19:50:00.985 -> load 0x3fff20b8, len 40, room 8 
19:50:00.985 -> tail 0
19:50:00.985 -> chksum 0x2b
19:50:00.985 -> csum 0x2b
19:50:00.985 -> v000875e0
19:50:00.985 -> ~ld
19:50:01.051 ->     n r  n|  l rlb  |r l n  n l`  r l l  e[0;32m[I][logger:034]: Log initializede[0m
19:50:01.083 -> e[0;35m[C][safe_mode:079]: There have been 9 suspected unsuccessful boot attemptse[0m
19:50:01.083 -> e[0;32m[I][app:029]: Running through setup()...e[0m
19:50:01.083 -> e[0;36m[D][spi:039]: Setting up SPI bus...e[0m
19:50:01.083 -> e[0;36m[D][spi_device:379]: mode 0, data_rate 2000kHze[0m

When i delete time segment esp works ok