Read counter from ha

Hello,

After a reboot i wan’t to load a total counter in esphome which is stored in HA, so after a new puls the counter is updated and send back to HA.

Is this possible, i don’t what to make use of retaind in esphome.