ESPHome allow entity to be modified while offline

Is it possible to allow changes to an esphome entity (e.g.: turn on light) while device is in deep sleep. When it wakes up it should check if there are mqtt messages and tunr on / turn off accordingly and then go to sleep again.
Does this work with QOS 2? can I tell HA to use QOS 2 when switching on/off lights?

Rather then modifying a entity from a esphome node you will just use mqtt

to subscribe to a topic you modify/manipulate from ha.

Could you give me an example because i did not get it to work