Home Automation / Projects · May 25, 2021

ESPHome Wake from Deep-Sleep with MQTT

Welcome back! In this episode, I’m taking you through how to manage your deep-sleep mode battery-powered IoT sensors remotely, using MQTT retain flags. This lets you catch the device at its’ next wakeup interval and keep it online, so you can do a firmware update, then put it back in its’ deep-sleep cycle, all without any physical intervention! Here’s the video, and below are the code samples referenced in the video. Enjoy!

YouTube player
deep_sleep:
  id: deep_sleep_1
  run_duration: 1s
  sleep_duration: 5min

mqtt:
  broker: [ipaddress]
  on_message:
    - topic: omg-esp/ota_mode
      payload: 'ON'
      then:
        - deep_sleep.prevent: deep_sleep_1
    - topic: omg-esp/sleep_mode
      payload: 'ON'
      then:
        - deep_sleep.enter: deep_sleep_1