Display and multiple lambda

Hello,

I have a max7219digit display, I successfully display current time:

   lambda: |-
      it.strftime(0, 0, id(digit_font), "%H:%M", id(hass_time).now());

I added a service to write a message from HA:

- service: write_message
      variables:
        message: string
      then:
        - lambda: |-
            id(matrix_display).printf(0, 0, id(digit_font), "%s", message.c_str());

My problem is that the time stay displays and I see the message at the same time, and for less than 1 second.
I don’t find how to display my message for x seconds then display time again, do you have a solution ?

Thanks

Does - delay work?
I’m doing something similar… Try this…

    then:
      - lambda: |-
            id(matrix_display).printf(0, 0, id(digit_font), "%s", message.c_str());
      - delay: 60s      
      - lambda: |-
          it.strftime(0, 0, id(digit_font), "%H:%M", id(hass_time).now());

I added a clear before and it works, but the message still displays less than one second

            id(matrix_display).clear();
            id(matrix_display).printf(0, 0, id(digit_font), "%s", message.c_str());
        - delay: 10s
        - lambda: |-
            id(matrix_display).clear();
            id(matrix_display).strftime(0, 0, id(digit_font), "%H:%M", id(hass_time).now());

I added update_interval: 20s to the display configuration, and now the message is displayed during 20s, but I don’t know if this is the good way :thinking: