Add configurable update interval for LTR390 sensor#76
Conversation
- Add global variable ltr390_last_update to track last sensor update time - Add LTR390 Update Interval template number (1-300s, default: 60s) - Set LTR390 update_interval to never (disables automatic polling) - Add interval component to manually trigger updates based on configured interval Users can now adjust the LTR390 sensor update frequency through the web interface without editing YAML, recompiling, or reflashing firmware. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
WalkthroughVersion bumped to 26.2.2.1; LTR390 sensor moved from fixed 5s updates to manual/update_interval never driven by two new interval automations and a new configurable template sensor that sets the update frequency (1–300 s). A global timestamp tracks last update. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@Integrations/ESPHome/Core.yaml`:
- Around line 410-422: The first LTR390 reading is delayed because
ltr390_last_update initializes to 0 and the interval lambda only triggers after
the configured interval; modify the lambda in the interval block so that if
id(ltr390_last_update) == 0 it calls id(ltr_390).update() and sets
id(ltr390_last_update) to current_time immediately (in addition to the existing
periodic check against id(ltr390_update_interval).state), ensuring an immediate
sensor read at boot.
Add check for first boot condition (last_update == 0 && current_time > 0) to trigger an immediate sensor update instead of waiting for the full configured interval to elapse. The current_time > 0 guard prevents edge case where both values are 0 in the first second after boot. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
This PR implements a configurable update interval for the LTR390 light sensor, matching the functionality added to MSR-2 in ApolloAutomation/MSR-2#56.
Changes
Number Input Added
LTR390 Update Interval- Configurable sensor polling rate (1-300 seconds, default: 60s)Sensor Configuration Updates
update_intervaltonever(disables automatic polling)ltr390_last_updateto track last sensor update timeintervalcomponent that runs every 1 second to check if configured interval has elapsedcomponent.update()when neededTechnical Details
Why use interval component?
ESPHome sensor platforms don't support templatable
update_intervalparameters. Attempting to use a lambda forupdate_intervalresults in compilation error: "This option is not templatable!"How it works:
update_interval: never)id(ltr_390).update()The setting:
restore_value: true)Benefits
Users can now adjust the LTR390 sensor update frequency without:
Simply adjust the value through the web interface and the sensor will update at the new interval.
Testing
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Chores