From 049cde697071dfa9024dab7a3fcd2bcad0402e81 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Mon, 24 Aug 2020 09:08:41 +0200 Subject: [PATCH] Add support for attributes in (numeric) state conditions (#14271) --- source/_docs/scripts/conditions.markdown | 33 +++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/source/_docs/scripts/conditions.markdown b/source/_docs/scripts/conditions.markdown index cb824f79975..c5561c851ad 100644 --- a/source/_docs/scripts/conditions.markdown +++ b/source/_docs/scripts/conditions.markdown @@ -96,10 +96,18 @@ condition: ### Numeric state condition -This type of condition attempts to parse the state of the specified entity as a number, and triggers if the value matches the thresholds. +This type of condition attempts to parse the state of the specified entity or the attribute of an entity as a number, and triggers if the value matches the thresholds. If both `below` and `above` are specified, both tests have to pass. +```yaml +condition: + condition: numeric_state + entity_id: sensor.temperature + above: 17 + below: 25 +``` + You can optionally use a `value_template` to process the value of the state before testing it. ```yaml @@ -124,6 +132,18 @@ condition: below: 18 ``` +Alternatively, the condition can test against a state attribute. +The condition will pass if the attribute value of the entity matches the thresholds. + +```yaml +condition: + condition: numeric_state + entity_id: climate.living_room_thermostat + attribute: temperature + above: 17 + below: 25 +``` + ### State condition Tests if an entity is a specified state. @@ -178,6 +198,17 @@ condition: - paused ``` +Alternatively, the condition can test against a state attribute. +The condition will pass if the attribute matches the given state. + +```yaml +condition: + condition: state + entity_id: climate.living_room_thermostat + attribute: hvac_modes + state: heat +``` + ### Sun condition #### Sun state condition