Output integer as minutes and seconds format

After much trying I have finally managed to get a countdown to be displayed on the screen using a counter in HA and an automation that decrement the value each second.

And in ESP-home I have:

sensor:
  - platform: homeassistant
    id: david_counter
    entity_id: counter.egg_david

display:
  - platform: waveshare_epaper
    cs_pin: 5
    dc_pin: 19
    busy_pin: 4
    reset_pin: 12
    model: 2.90in
    full_update_every: 30
    update_interval: 1s
    lambda: |-
         it.printf(20, 260, id(my_font_small), "%.0f", id(david_counter).state); 
         it.strftime(0, 280, id(my_font_small), "%M:%S", id(david_counter).state);

The first output shows the integer value as 200 seconds.
The second line fails because it can’t convert the integer to a timestamp.

What are my options to convert the seconds to minutes and seconds?

What is the exact error message, perhaps post your log.

I will have a look tonight.

Edit.
I just realized I could compile without the having the ESP on…

src/main.cpp: In lambda function:
src/main.cpp:586:10: error: 'class esphome::display::DisplayBuffer' has no member named 'strftime'
       it.strftime(0, 280, my_font_small, "%M:%S", david_counter->state);
          ^
*** [/data/eggklocka/.pioenvs/eggklocka/src/main.cpp.o] Error 1

Here is what I used as reference:
Time — ESPHome

Are there any lines after that?

Is id(david_counter).state an integer, or a string, or something else?

I believe it’s an integer.
You can see it in the first post, it comes from a counter in HA.
The first lambda line outputs it as an integer, but that could be because it’s forced as integer with “%.0f” (?)

Here is the complete debug window.

INFO Reading configuration /config/esphome/eggklocka.yaml...
INFO Generating C++ source...
INFO Compiling app...
INFO Running:  platformio run -d /config/esphome/eggklocka
Processing eggklocka (board: esp32dev; framework: arduino; platform: [email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
PACKAGES: 
 - framework-arduinoespressif32 3.10004.200129 (1.0.4) 
 - tool-esptoolpy 1.20600.0 (2.6.0) 
 - toolchain-xtensa32 2.50200.80 (5.2.0)
Library Manager: Installing Hash
Library Manager: Already installed, built-in library
Dependency Graph
|-- <AsyncTCP-esphome> 1.1.1
|-- <ESPmDNS> 1.0
|   |-- <WiFi> 1.0
|-- <FS> 1.0
|-- <ESPAsyncWebServer-esphome> 1.2.7
|   |-- <AsyncTCP-esphome> 1.1.1
|   |-- <FS> 1.0
|   |-- <WiFi> 1.0
|-- <DNSServer> 1.1.0
|   |-- <WiFi> 1.0
|-- <Update> 1.0
|-- <WiFi> 1.0
|-- <SPI> 1.0
Compiling /data/eggklocka/.pioenvs/eggklocka/src/main.cpp.o
src/main.cpp:493:3: warning: multi-line comment [-Wcomment]
   //   lambda: !lambda "it.print(15, 0, id(my_font), \"Eggtimer\");\nit.print(0, 40, id(my_font_small),\
   ^
src/main.cpp: In lambda function:
src/main.cpp:586:10: error: 'class esphome::display::DisplayBuffer' has no member named 'strftime'
       it.strftime(0, 280, my_font_small, "%M:%S", david_counter->state);
          ^
*** [/data/eggklocka/.pioenvs/eggklocka/src/main.cpp.o] Error 1
========================= [FAILED] Took 12.03 seconds =========================

the first warning for multi line comment is wrong. There is no multi line comment and it works just as expected so I just ignore it.

Am I missing something? If it just an int with seconds and you want to display it as minutes and seconds you can do someting like:

 it.printf(20, 260, id(my_font_small), "%2d:%2d",   int(id(david_counter).state/60), int(id(david_counter))%60  );

By some reason the seconds is always 40.
The minutes count down as it should but not the seconds.

I “resolved” the issue by creating a input_text that is edited with an automation in HA and that is displayed.
Not an ideal solution as it creates extra entities but it works.