A tiny Home Assistant integration that wraps a light or switch
entity in a user-facing entity of the same domain. When the wrapper
is active, a Jinja condition template decides whether the target is
turned on or off. When inactive, the target is forced off.
- The wrapper's state is the user-controlled active / inactive flag.
- The wrapper's domain matches the target:
lighttarget →lightwrapper,switchtarget →switchwrapper. - When active, the condition template decides whether the target is on or off.
- When inactive, the target is forced off.
- State persists across restarts.
- HACS → Integrations → ⋯ → Custom repositories.
- Repository:
akentner/homeassistant-condition-gate-integration. - Category: Integration.
- Install Condition Gate.
- Restart Home Assistant.
- Settings → Devices & Services → Add Integration → Condition Gate.
- Copy
custom_components/condition_gate/into your HA config directory undercustom_components/. - Restart Home Assistant.
- Settings → Devices & Services → Add Integration → Condition Gate.
The config flow has three required fields:
| Field | Description |
|---|---|
| Name | Display name shown in the UI. |
| Target entity | A light.* or switch.* entity the wrapper drives. |
| Condition template | Jinja expression that evaluates to truthy / falsy. |
Three optional icon fields override the wrapper's state-dependent icon:
| Field | Default |
|---|---|
icon_inactive |
inherits from the target's icon |
icon_active_on |
inherits from the target's icon |
icon_active_off |
mdi:gate-alert |
Only light and switch targets are accepted. The wrapper entity
itself uses the same domain as the target, so a light.x target
produces a light.<name> wrapper.
See custom_components/condition_gate/docs/configuration.md
for the full configuration reference.
# Settings → Devices & Services → Add Integration → Condition Gate
Name: Candles
Target entity: light.livingroom22_candles
Condition: {{
state_attr('sun.sun', 'elevation') is not none
and state_attr('sun.sun', 'elevation') < -3
and now().hour < 1
}}- Architecture —
internal design, lifecycle,
thisrendering, persistence. - Configuration — config flow, validation, supported domains.
- Condition templates —
Jinja syntax,
this, common patterns. - Examples — real-world setups.
- Lovelace / card-mod examples — drop-in YAML for cards.
Triggers that fire a reconcile:
- Template subscription — any state change referenced in the
condition, plus a per-minute tick for
now()/utcnow()(HA standard, no manual polling). - User toggle —
turn_on/turn_offtrigger a reconcile. - Service —
condition_gate.re_evaluateruns reconcile on one or all wrappers. Useful from automations or scripts.
- Only
lightandswitchtargets are supported.scene,automation,input_boolean, etc. are rejected at config-flow time. - The wrapper domain is fixed at setup time and does not change on
reconfigure. To change
light↔switch, remove and re-add the entry. - The default time tracking fires once per minute. For tighter
reactivity (sub-minute polling), use a real
automation:with atimetrigger.
MIT — see LICENSE. The
HOME_ASSISTANT_COMMUNITY.md addendum
documents the additional expectations that come with publishing for the
Home Assistant ecosystem.