-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Refactor threshold trigger and condition docs into shared includes #45719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
abmantis
wants to merge
2
commits into
next
Choose a base branch
from
threshold_triggers_conditions_reuse
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| {% comment %} | ||
| Reusable "Options in the UI" block for entity conditions that test a reading | ||
| against the threshold-mapping schema. | ||
|
|
||
| Parameters: | ||
| reading quantity noun, e.g. "humidity" | ||
| value_short Number-entry phrasing, e.g. "a fixed percentage (0–100)" | ||
| has_unit set (to anything) to add a "Unit" row for the temperature unit | ||
| {% endcomment %} | ||
| {% options_ui %} | ||
| Threshold type: | ||
| description: | | ||
| The {{ include.reading }} level the entity has to meet for the condition to pass. **Above** and **Below** are exclusive: a reading equal to the threshold does not pass. **In range** is exclusive at both bounds. **Outside range** is inclusive: a reading equal to either bound passes. Choose **Number** to enter {{ include.value_short }}, or **Entity** to use a sensor or number helper as a dynamic threshold. | ||
| {% if include.has_unit %} | ||
| Unit: | ||
| description: The temperature unit to use for threshold comparison. Accepts `°C` or `°F`. Required when using numerical thresholds (not required when using entity references). | ||
| default: °C | ||
| {% endif %} | ||
| Condition passes if: | ||
| description: | | ||
| When multiple entities are targeted, controls how results combine: | ||
|
|
||
| - **Any**: The condition passes if at least one targeted entity meets the threshold (default). | ||
| - **All**: The condition passes only when every targeted entity meets the threshold. | ||
| {% endoptions_ui %} |
54 changes: 54 additions & 0 deletions
54
source/_includes/conditions/threshold_value_options_yaml.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| {% comment %} | ||
| Reusable "Options in YAML" block for entity conditions that test a reading | ||
| against the threshold-mapping schema. The `behavior` description is shared | ||
| across the family. Unitless members (humidity, brightness, counter) get the | ||
| per-type "Provide value..." guidance; members with a temperature unit get the | ||
| unit_of_measurement guidance and a unit-style example instead. | ||
|
|
||
| Parameters: | ||
| reading quantity noun, e.g. "humidity" | ||
| range_note parenthetical range for above/below (unitless), e.g. "0–100" | ||
| number_final closing number guidance (unitless), e.g. "a percentage value (0–100)" | ||
| has_unit set (to anything) for temperature unit_of_measurement guidance + example | ||
| threshold_required "true" or "false" for the threshold field (default "false") | ||
| {% endcomment %} | ||
| {% options_yaml %} | ||
| threshold: | ||
| description: | | ||
| The {{ include.reading }} level the entity has to meet for the condition to pass: | ||
|
|
||
| - `type: above` (exclusive): Sets a minimum. The reading must be strictly above the threshold to pass.{% unless include.has_unit %} Provide `value` with a `number` key ({{ include.range_note }}) or an `entity` key.{% endunless %} | ||
| - `type: below` (exclusive): Sets a maximum. The reading must be strictly below the threshold to pass.{% unless include.has_unit %} Provide `value` with a `number` key ({{ include.range_note }}) or an `entity` key.{% endunless %} | ||
| - `type: between` (exclusive): Defines a range. The reading must be strictly between both bounds to pass.{% unless include.has_unit %} Provide `value_min` and `value_max`, each with a `number` key or an `entity` key.{% endunless %} | ||
| - `type: outside` (inclusive): Defines an outside-range. The reading must be at or beyond either bound to pass.{% unless include.has_unit %} Provide `value_min` and `value_max`, each with a `number` key or an `entity` key.{% endunless %} | ||
| {% if include.has_unit %} | ||
|
|
||
| For `type: above` and `type: below`, use `value` with either `number` and `unit_of_measurement`, or `entity`. For `type: between` and `type: outside`, use `value_min` and `value_max`, each with either `number` and `unit_of_measurement`, or `entity`. For example: | ||
|
|
||
| ```yaml | ||
| threshold: | ||
| type: between | ||
| value_min: | ||
| entity: input_number.comfort_temperature_min | ||
| value_max: | ||
| number: 22 | ||
| unit_of_measurement: °C | ||
| ``` | ||
|
|
||
| When using an `entity`, its current reading is used as the threshold at the moment the condition is evaluated, which lets you compare two temperature readings dynamically. | ||
| {% else %} | ||
|
|
||
| For the `number` key, use {{ include.number_final }}. For the `entity` key, use an `input_number`, `number`, or `sensor` entity. | ||
| {% endif %} | ||
| required: {{ include.threshold_required | default: "false" }} | ||
| type: map | ||
| behavior: | ||
| description: | | ||
| When multiple entities are targeted, controls how results combine: | ||
|
|
||
| - `any`: The condition passes if at least one targeted entity meets the threshold. | ||
| - `all`: The condition passes only when every targeted entity meets the threshold. | ||
| required: false | ||
| type: string | ||
| default: any | ||
| {% endoptions_yaml %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| {% comment %} | ||
| Reusable "To use ... in an automation" steps for entity conditions that test a | ||
| reading against the threshold-mapping schema (above/below/in range/outside | ||
| range). Used by humidity.is_value; reusable by climate.target_humidity, | ||
| light.is_brightness, counter.is_value, and similar. | ||
|
|
||
| Parameters: | ||
| title UI display name, e.g. "Relative humidity" | ||
| sensor sensor noun, e.g. "humidity sensor" | ||
| areas example areas, e.g. "bedroom or bathroom" | ||
| reading quantity noun, e.g. "humidity" | ||
| value_long Number-entry phrasing, e.g. "a fixed percentage directly, for example `65` for 65%" | ||
| has_unit set (to anything) to add a "Unit" step for the temperature unit | ||
| {% endcomment %} | ||
| To use **{{ include.title }}** in an automation: | ||
|
|
||
| 1. Go to {% my automations title="**Settings** > **Automations & scenes**" %}. | ||
| 2. Open an existing automation, or select **Create automation** > **Create new automation**. | ||
| 3. In the **And if** section, select **Add condition**. | ||
| 4. Select what you want to check. Under **By target** (see [Targets](#targets)), pick the area your {{ include.sensor }} is in (like your {{ include.areas }}). You can also select a device, a specific entity, or a label. | ||
| 5. From the conditions shown for that target, select **{{ include.title }}**. | ||
| 6. Under **Threshold type**, set the {{ include.reading }} level the condition checks against: | ||
| 1. Pick whether the reading must be **Above**, **Below**, **In range**, or **Outside range** of the threshold. | ||
| 2. Select **Number** or **Entity**: | ||
| - **Number**: Enter {{ include.value_long }}. For **In range** or **Outside range**, enter both a lower and upper bound. | ||
| - **Entity**: Use a sensor entity or a [number helper](/integrations/input_number/) entity as the threshold: | ||
| - Number helper: You can adjust the threshold value without editing the automation. The sensor reading is compared against the number helper's current value. | ||
| - Sensor: Its current reading becomes the threshold and updates automatically as the sensor changes. This is useful for comparing two {{ include.reading }} readings, for example to check whether indoor {{ include.reading }} is higher than outdoor {{ include.reading }}. | ||
| - For **In range** or **Outside range**, you need two entities: one for the lower bound and one for the upper bound (for example, two separate number helpers). | ||
| - If you don't have a number helper, you can create one by selecting **Create a new number helper**. | ||
| {%- if include.has_unit %} | ||
| 7. Under **Unit**, select the temperature unit (°C or °F) to use for the threshold comparison. | ||
| {%- endif %} | ||
| 8. Under **Condition passes if** (see [Behavior](#behavior-with-multiple-targets)), pick **Any** or **All**. | ||
| 9. Select **Save**. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| {% comment %} | ||
| Reusable "Options in the UI" block for "changed" entity triggers that use the | ||
| threshold-mapping schema. | ||
|
|
||
| Parameters: | ||
| unit_phrase_ui value-entry phrasing, e.g. "a fixed percentage (0–100%)" | ||
| has_unit set (to anything) to add a "Unit" row for the temperature unit | ||
| {% endcomment %} | ||
| {% options_ui %} | ||
| Threshold type: | ||
| description: | | ||
| Controls which changes fire the trigger: | ||
|
|
||
| - **Any change**: fires on any change, regardless of direction or new value. | ||
| - **Above** or **Below** (exclusive): fires only when the new reading is strictly above or below the threshold. A reading equal to the threshold does not fire the trigger. | ||
| - **In range** (exclusive): fires only when the new reading is strictly between the two bounds. A reading equal to either bound does not fire the trigger. | ||
| - **Outside range** (inclusive): fires when the new reading is at or below the lower bound, or at or above the upper bound. A reading equal to either bound fires the trigger. | ||
|
|
||
| For each mode you can enter {{ include.unit_phrase_ui }} or reference a sensor entity or a [number helper](/integrations/input_number/) entity. | ||
| {% if include.has_unit %} | ||
| Unit: | ||
| description: The temperature unit to use for threshold comparison. Accepts `°C` or `°F`. Required when using numerical thresholds (not required when using entity references). Default is `°C`. | ||
| {% endif %} | ||
| {% endoptions_ui %} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.