A Home Assistant custom integration that automatically turns off configured entities after a user-defined timeout—optionally gated by custom Jinja2 template conditions. When an entities is turned on and the user-specified condition evaluates to true
, a timer starts; when the timer expires the entities is switched off. The timer is cancelled if the entities is manually turned off or renewed if some attribute is modified (e.g., brightness change). Each entities has its own independent timer. Timers are persisted, if Home Assistant is restarted, the timers will be restored.
- Starts an individual timer whenever a configured entity is turned on
- Automatically turns off the entity when the timeout expires
- Cancels the timer if the entity is manually turned off
- Renews the timer if the entity’s state is modified while on
- Supports multiple entities simultaneously, each with its own timeout
- Condition via Template: define any Jinja2 template that must evaluate to
true
to enable/disable the timeout
- Make sure HACS is installed in your Home Assistant.
- Add this repository as a custom repository in HACS:
- Go to HACS → Integrations → ⋮ → Custom repositories
- Paste the URL
https://github.com/0x3333/auto_off_timer
- Select the category Integration
- Click Download to install
- Restart Home Assistant
- Copy the
auto_off_timer
folder intocustom_components/auto_off_timer
in your Home Assistant configuration directory. - Restart Home Assistant
Note: You do not need to edit
configuration.yaml
— all configuration is done through the UI (Config Flow).
After installation and restart:
- Go to Settings → Devices & Services → Integrations.
- Click Add Integration and search for Auto Off Timer.
- Fill out the form:
- Name: a friendly title for this instance (e.g., “Living Room Timeout”).
- Entities: select one or more entities to monitor.
- Timeout: choose a timeout duration in
HH:MM:SS
format (e.g.,00:10:00
for 10 minutes). - Condition Template (optional): enter a Jinja2 template that will be evaluated after the entity is turned
on
. The timer will only be started if the template renderstrue
.
- Click Submit.
The integration will begin monitoring the selected entities. You can create as many instances (Config Entries) as you like, each with its own set of entities, timeout and condition.
This integration does not create any new entities. All behavior is handled via state listeners and native service calls (DOMAIN.turn_off
).
Contributions are welcome! Feel free to open a Pull Request or file Issues in the official repository.
- Fork this repository.
- Create a branch (
git checkout -b feature/new-feature
). - Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature/new-feature
). - Open a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.