Deep Sleep seems to ignore run_duration

Something very strange going on with my sensor which seems to ignore the run duration. This is the yaml file:

esphome:
  name: portugal-weather
  platform: ESP8266
  board: d1_mini_pro

mqtt:
  discovery: true
  broker: 192.168.1.42
  port: 1883
  username: !secret mqtt_user
  password: !secret mqtt_password
  birth_message:
    topic: portugal/status
    payload: ''
  will_message:
    topic: portugal/status
    payload: ''
    
  on_message:
    - topic: portugal/deep_sleep_mode
      payload: 'OFF'
      then:
        - deep_sleep.prevent: deep_sleep_1
    - topic: portugal/deep_sleep_mode
      payload: 'ON'
      then:
        - deep_sleep.enter: deep_sleep_1

# Enable Home Assistant API
# api:

wifi:
  manual_ip:
    static_ip: 192.168.1.22
    gateway: 192.168.1.254
    subnet: 255.255.255.0
    dns1: 8.8.8.8
    dns2: 8.8.4.4
    
  networks:
    ssid: !secret wifi_ssid
    password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Portugal-Weather"
    password: !secret ap_password

logger:

deep_sleep:
  run_duration: 2min
  sleep_duration: 1min
  id: deep_sleep_1

sensor:
  - platform: bmp280
    temperature:
      name: "Portugal Temperature"
      oversampling: 16x
    pressure:
      name: "Portugal Pressure"
    address: 0x76
    update_interval: 5s

i2c:
  sda: D2
  scl: D1
  scan: false

ota:

If I disable deep_sleep (through the MQTT option) it works fine, if I enable deep-sleep, the below happens. Note that it does not run for 2 minutes, it goes to sleep in the middle of the initial setup logic. I’ve tried playing around with run_duration and sleep_duration but it doesn’t work. The net result is that when in deep sleep mode, it never gets to delivering a sensor value.

I have another (weight) sensor which works fine and the only difference I can think of, is that the sensor that doesn’t work runs from a 18650 (3.7v at the moment) battery connected to the 3.3V pin on my Wemos D1 Pro. The weight sensor runs from the 5V pin on that board.

Any ideas?

“Fixed” My own issue… by reading the manual again. I did not delete the “ON” payload.

Remember to turn “OTA mode” off again after the OTA update by sending a MQTT message with the payload OFF. To enter the deep sleep again after the OTA update send a message on the topic livingroom/sleep_mode with payload ON. Deep sleep will start immediately. Don’t forget to delete the payload before the node wakes up again.