Skip to content

Templated Thresholds

Jason Rhubottom edited this page Jun 11, 2026 · 1 revision

Templated Thresholds

Nine numeric threshold fields accept a Home Assistant Jinja2 template in place of a fixed number. Type a template into the field and Adaptive Cover Pro renders it to a number once per update cycle, so the threshold can follow a season, a sensor, an input_number helper, or any other state you can express in a template, without an external automation calling a service.

A tenth field, the Motion Occupancy Template on the Automation screen, takes a condition template (truthy/falsy) rather than a number. It is documented at the bottom of this page.

Available in v2.28.0-beta.5 and later. This is a beta feature; behaviour may change before the stable v2.28.0 release.


Which fields accept a template

Screen Field
Climate β†’ Light & Cloud Lux Threshold
Climate β†’ Light & Cloud Irradiance Threshold
Climate β†’ Light & Cloud Cloud Coverage Threshold
Climate β†’ Temperature & Climate Minimum Comfort Temperature
Climate β†’ Temperature & Climate Maximum Comfort Temperature
Climate β†’ Temperature & Climate Outdoor Temperature Threshold
Weather Safety Wind Speed Threshold
Weather Safety Rain Rate Threshold
Weather Safety Wind Direction Tolerance

A plain number still works in every one of these fields. Templating is opt-in: leave a number and nothing changes.


Writing a template

The field is a Jinja code editor with entity autocomplete and syntax highlighting, the same editor Home Assistant uses for template sensors. Your template must render to a number.

{{ states('input_number.summer_high_temp') | float }}
{# Tighter comfort band in winter, wider in summer #}
{{ 23 if now().month in (11, 12, 1, 2) else 26 }}
{# Track an outdoor sensor, with a fallback if it goes unavailable #}
{{ states('sensor.outdoor_temp') | float(25) }}

The unit for each field (Β°C, lux, W/mΒ², %, and so on) is shown in the field's description text rather than next to the editor, because the template editor has no fixed unit.


How rendering works

  • The template is rendered once per update cycle, before the position calculation runs. The calculation engine only ever sees the resulting number, never the raw template.
  • Use a float default (| float(25)) for any value that can go unavailable. A bare | float on an unavailable sensor renders to 0, which is rarely the threshold you want.
  • If a template fails to render to a number β€” a syntax error, an unavailable entity with no fallback, a non-numeric result β€” that field falls back to its built-in default for the cycle, and the failure is logged once (not every cycle) until it recovers. The cover keeps operating; one bad template does not stall the rest of the configuration.

Seeing the resolved value

Open the cover's diagnostics (see Debug & Diagnostics). Any field configured with a template appears under templated_thresholds, showing both the raw template string and the value it last rendered to:

"templated_thresholds": {
  "temp_high": { "template": "{{ 23 if now().month in (11,12,1,2) else 26 }}", "resolved": 26.0 }
}

Fields configured with a plain number do not appear there, so the list is exactly the set of thresholds currently driven by a template.


Motion Occupancy Template

The Motion Occupancy Template field on the Automation screen is the condition-template counterpart. It takes a template that renders truthy or falsy, and treats a truthy result as occupancy. It is OR'd with the configured Motion Sensors: presence is reported when any motion sensor is active or the template renders truthy.

{# Treat the room as occupied whenever a guest switch is on #}
{{ is_state('input_boolean.guest_mode', 'on') }}

Truthiness follows Home Assistant's usual condition rules (on, true, 1 count as true). An empty field, a non-template value, or a render failure all read as falsy, so a broken template can never wedge the room into permanent occupancy. The template can be used on its own, with no motion sensors configured, when occupancy is something you compute upstream.


Related pages

Clone this wiki locally