Can ESPhome detect reset cause?

I would like to add actions based on reset cause - especially, I would like to detect reset by wifi not available (to go to deep sleep for 1hr) and reset by timer/RST_pin (to proceed normally.

Is it possible? I tried to add following code to on_boot:, but it does not work returns always reset_reason 0.

    priority: 900
    then:
      - lambda: |-
          rst_info *xyz;
          byte reset_reason;
          xyz = ESP.getResetInfoPtr();
          reset_reason = (*xyz).reason;
          ESP_LOGD("main", "Reset reason: %f", reset_reason);

I solved it. I check regularly if sensor is still alive after 8sec. It means that it did not connect to wifi on time and is still trying. In that case, I just send it to sleep:

    then:
      - lambda: |-
          //ESP_LOGD("main", "Millis: %d", millis());   //for debug purposes
          if (millis() > 30000) {
            ESP.deepSleep(20000000, WAKE_RF_DEFAULT);
            }
          delay(100);