Add support for attributes in (numeric) state conditions (#14271)

This commit is contained in:
Franck Nijhof 2020-08-24 09:08:41 +02:00 committed by GitHub
parent a5d778cb40
commit 049cde6970
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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