-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c554957
Refactor threshold trigger and condition docs into shared includes
abmantis e7670fc
Fix hardcoded temperature related terms
abmantis fea5659
Merge branch 'current' into threshold_triggers_conditions_reuse
abmantis 0e14aff
Apply suggestion from @c0ffeeca7
c0ffeeca7 561400d
Apply suggestion from @c0ffeeca7
c0ffeeca7 66490b0
Apply suggestion from @c0ffeeca7
c0ffeeca7 67f8cd5
Apply suggestion from @c0ffeeca7
c0ffeeca7 3b01c53
Improve capitalization + punctuation
abmantis 7072c24
Remove reading param
abmantis 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,28 @@ | ||
| {% comment %} | ||
| Reusable "Options in the UI" block for entity conditions that test a reading | ||
| against the threshold-mapping schema. | ||
|
|
||
| Parameters: | ||
| value_short Number-entry phrasing. For example: "a fixed percentage (0–100)". | ||
| has_unit Set (to anything) to add a "Unit" row. Requires unit_label, | ||
| unit_options_code, and unit_default. | ||
| unit_label Unit label. For example: "temperature unit", "energy unit". | ||
| unit_options_code Inline code list of allowed units. For example: "`°C` or `°F`". | ||
| unit_default Default unit. For example: "°C" | ||
| {% endcomment %} | ||
| {% options_ui %} | ||
| Threshold type: | ||
| description: | | ||
| The threshold the entity's reading is compared against. **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 {{ include.unit_label }} to use for threshold comparison. Accepts {{ include.unit_options_code }}. Required when using numerical thresholds (not required when using entity references). | ||
| default: {{ include.unit_default }} | ||
| {% 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 %} |
58 changes: 58 additions & 0 deletions
58
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,58 @@ | ||
| {% 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 unit (temperature, energy, | ||
| etc.) get the unit_of_measurement guidance and a unit-style example instead. | ||
|
|
||
| Parameters: | ||
| range_note Parenthetical range for above/below (unitless). For example: "0–100". | ||
| number_final Closing number guidance (unitless). For example: "a percentage value (0–100)". | ||
| has_unit Set (to anything) for unit_of_measurement guidance and example. | ||
| Requires unit_default, unit_example_entity, and unit_example_value. | ||
| unit_default Default unit used in the example. For example: "°C". | ||
| unit_example_entity Entity reference used in the example. For example: | ||
| "input_number.comfort_temperature_min". | ||
| unit_example_value Literal number used in the example. For example: "22". | ||
| threshold_required "true" or "false" for the threshold field. Default "false". | ||
| {% endcomment %} | ||
| {% options_yaml %} | ||
| threshold: | ||
| description: | | ||
| The threshold the entity's reading is compared against: | ||
|
|
||
| - `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: {{ include.unit_example_entity }} | ||
| value_max: | ||
| number: {{ include.unit_example_value }} | ||
| unit_of_measurement: {{ include.unit_default }} | ||
| ``` | ||
|
|
||
| When using an `entity`, its current reading is used as the threshold at the moment the condition is evaluated, which lets you compare two 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,36 @@ | ||
| {% 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. For example: "Relative humidity". | ||
| sensor Sensor noun. For example: "humidity sensor". | ||
| areas Example areas. For example: "bedroom or bathroom". | ||
| value_long Number-entry phrasing. For example: "a fixed percentage directly, for example `65` for 65%". | ||
| has_unit Set (to anything) to add a "Unit" step. Requires unit_label and unit_options. | ||
| unit_label Unit label. For example: "temperature unit", "energy unit". | ||
| unit_options Bare list of allowed units for prose. For example: "°C or °F". | ||
| {% 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 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. | ||
| - 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 {{ include.unit_label }} ({{ include.unit_options }}) 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,28 @@ | ||
| {% comment %} | ||
| Reusable "Options in the UI" block for "changed" entity triggers that use the | ||
| threshold-mapping schema. | ||
|
|
||
| Parameters: | ||
| unit_phrase_ui Value-entry phrasing. For example: "a fixed percentage (0–100%)". | ||
| has_unit Set (to anything) to add a "Unit" row. Requires unit_label, | ||
| unit_options_code, and unit_default. | ||
| unit_label Unit label. For example: "temperature unit", "energy unit". | ||
| unit_options_code Inline code list of allowed units. For example: "`°C` or `°F`". | ||
| unit_default Default unit. For example: "°C". | ||
| {% 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 {{ include.unit_label }} to use for threshold comparison. Accepts {{ include.unit_options_code }}. Required when using numerical thresholds (not required when using entity references). Default is `{{ include.unit_default }}`. | ||
| {% 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.