mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-24 17:57:14 +00:00
added another choose example (#16972)
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
parent
040aed613a
commit
259fb6f895
@ -610,6 +610,64 @@ automation:
|
|||||||
|
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
|
|
||||||
|
|
||||||
|
More `choose` can be used together. This is the case of an IF-IF.
|
||||||
|
|
||||||
|
The following example shows how a single automation can control entities that aren't related to each other but have in common the same trigger.
|
||||||
|
|
||||||
|
When the sun goes below the horizon, the `porch` and `garden` lights must turn on. If someone is watching the TV in the living room, there is a high chance that someone is in that room, therefore the living room lights have to turn on too. The same concept applies to the `studio` room.
|
||||||
|
|
||||||
|
{% raw %}
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# Example with "if" and "if"
|
||||||
|
automation:
|
||||||
|
- alias: "Turn lights on when the sun gets dim and if some room is occupied"
|
||||||
|
trigger:
|
||||||
|
- platform: numeric_state
|
||||||
|
entity_id: sun.sun
|
||||||
|
attribute: elevation
|
||||||
|
below: 4
|
||||||
|
action:
|
||||||
|
# This must always apply
|
||||||
|
- service: light.turn_on
|
||||||
|
data:
|
||||||
|
brightness: 255
|
||||||
|
color_temp: 366
|
||||||
|
target:
|
||||||
|
entity_id:
|
||||||
|
- light.porch
|
||||||
|
- light.garden
|
||||||
|
# IF a entity is ON
|
||||||
|
- choose:
|
||||||
|
- conditions:
|
||||||
|
- condition: state
|
||||||
|
entity_id: binary_sensor.livingroom_tv
|
||||||
|
state: "on"
|
||||||
|
sequence:
|
||||||
|
- service: light.turn_on
|
||||||
|
data:
|
||||||
|
brightness: 255
|
||||||
|
color_temp: 366
|
||||||
|
target:
|
||||||
|
entity_id: light.livingroom
|
||||||
|
# IF another entity not related to the previous, is ON
|
||||||
|
- choose:
|
||||||
|
- conditions:
|
||||||
|
- condition: state
|
||||||
|
entity_id: binary_sensor.studio_pc
|
||||||
|
state: "on"
|
||||||
|
sequence:
|
||||||
|
- service: light.turn_on
|
||||||
|
data:
|
||||||
|
brightness: 255
|
||||||
|
color_temp: 366
|
||||||
|
target:
|
||||||
|
entity_id: light.studio
|
||||||
|
```
|
||||||
|
|
||||||
|
{% endraw %}
|
||||||
|
|
||||||
[Script component]: /integrations/script/
|
[Script component]: /integrations/script/
|
||||||
[automations]: /getting-started/automation-action/
|
[automations]: /getting-started/automation-action/
|
||||||
[Alexa/Amazon Echo]: /integrations/alexa/
|
[Alexa/Amazon Echo]: /integrations/alexa/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user