Time not synchronized + check time now() in log or sensor time

Hi everyone, after more than a month of seamless puzzle games, I am asking for your help.
One thing I thought was simple but I was wrong.
I have an ESP32 programmed with ESP HOME with a temperature dallas that reads the temperature and at each reading activates a script that opens more or less a window.
Everything works.
The problem is that I want to tell him that between 09:00 and 15:00 it remains closed.
I added the time in the time slot, but in the Log I do not get a synchronization response and to do some checks I would like to read an output with the time in the log or in a text sensor.
I have tried every but to no avail.

time:
  - platform: sntp
    id: sntp_time
    timezone: "Europe/Rome"
    on_time_sync:
      then:
        - logger.log: "Synchronized sntp clock"
text_sensor:
  - platform: template
    name: "Ora Text"
    lambda: |-
      auto time = id(sntp_time).now();
      char str[17];
      time_t currTime = id(sntp_time).now().time;
      strftime(str, sizeof(str), "%Y-%m-%d %H:%M", localtime(&currTime));
      return { str };
    update_interval: 30s

Log time:

[21:48:08][C][sntp:044]: SNTP Time:
[21:48:08][C][sntp:045]:   Server 1: '0.pool.ntp.org'
[21:48:08][C][sntp:046]:   Server 2: '1.pool.ntp.org'
[21:48:08][C][sntp:047]:   Server 3: '2.pool.ntp.org'
[21:48:08][C][sntp:048]:   Timezone: 'CET-1CEST-2,M3.4.0/2,M10.5.0/3'

No sync

Do you have a DNS server set?

i tried with that too, but the docs say
servers (Optional , list of strings):…
I also tried it as an alternative

  - platform: homeassistant
    id: ha_time
    on_time_sync:
      then:
        - logger.log: "Synchronized home assistant clock"

same result

The docs say you need a dns server for sntp to work.

I have a similar issue. Since OS update 6.3 my Pi4 is stuck on 2021-08-31 and time: 11:03 everytime I reboot the host.
DNS is working and I have checked all sorts of settings. I have no idea from where it is pulling that date/time.
I am a total loss since restoring a snapshot (backup) will not make a difference.
I am about to create a fresh HASS image and try to boot to check what time it gets from DNS

This thread is about esphome, not HAOS.

After further attempts I found that the time syncs without setting up a server and I created a text sensor to function as a log since ESPHOME does not display anything in the log and I found that it synchronized.
Then I played by trial and error until the solution
public that can serve others who don’t go crazy for a month like me on this one
Synchronization problem now if I set static IP for now I leave it dynamic


time:
  - platform: sntp
    id: sntp_time
    timezone: "Europe/Rome"
    on_time_sync:
      then:
        - logger.log: "Synchronized sntp clock"
        - text_sensor.template.publish:
            id: ora_text_sync
            state: "Sync SNTP clock"
text_sensor:
  - platform: template
    name: "Ora Text Sync"
    id: ora_text_sync

  - platform: template
    name: "Ora Text"
    id: ora_text
    update_interval: 60s
    lambda: |-
      auto time_text = id(sntp_time).now().strftime("%H:%M:%S - %d-%m-%Y");
      return { time_text };