esphome / esphome/feature-requests
Delay/Timed/Manual initialisation of sensor component code
- Dominant language
- No language data
- Stars
- 450
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the problem you have/What new integration you would like**
I have a battery powered ESP32 and a Hydreon RG-9 rainsensor.
What I am trying to do is this:
- ESP wakes from a period of deep sleep.
- ESP requests the state of a rooflight in Home Assistant
- If the rooflight is closed, then the ESP goes back to sleep
- If the rooflight is open, then I power up the RG-9 and start sending readings back to HA to automate closing of the rooflight when it rains.
- Once closed, the ESP goes back to the sleep routine
Most of this works, but the RG-9 sensor component is loaded when the ESP wakes up/boots and as the physical RG-9 device is not yet powered, then the component initialization fails and I can't see any way to re-initialize it when I need to. I have tried using component.update() but this doesn't appear to help. Ideally need some kind of "component.init: id" function that I can call after I have powered up the RG-9. Maybe with a "component:initDelay INT" option so a user can decide either to delay initialization for "n" seconds or set it to 0 so it is never automatically initialized and has to be triggered by code later.
**Please describe your use case for this integration and alternatives you've tried:**
The issue is that the component sensor code is being initialized before the physical device is powered on. Ideally I would like to be able to control when the sensor code is loaded so I can run it *after* the ESP has validated the use case and enabled a GPIO to turn on the rain sensor (via a small mosfet but that isn't important).
I have achieved all I want using arduino C code and HA MQTT but I really like the deep integration with HA offered by ESPHome and the ability to easily do OTA updates etc.
**Additional context**
I have asked about this on discord and was told that it isn't something that is available right now. There is my example yaml code in this thread too:
https://discord.com/channels/429907082951524364/1157611493643268147
Thanks
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the example YAML referenced in the Discord thread and the reported behavior of component.update(). The intended result is a way to delay or manually trigger sensor initialization after the ESP32 powers the RG-9 through GPIO, while preserving the existing deep-sleep workflow.
Written by the indexing model from the issue text.
Assessment
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100