The YAML you've provided appears to be an automation script for Home Assistant, designed to control the blinds in a bedroom based on various conditions such as time, sunlight, and a "Do Not Disturb" (DND) mode.
However, there are a few issues and improvements that can be suggested:
-
Duplicate Triggers: You have two triggers with the id baby_its_hot_out. YAML typically requires unique IDs for each item. You can merge these or rename one of them.
-
Empty Conditions List: Your conditions: [] list is empty. If you're not intending to use it, you can remove it altogether.
-
Consistent Spacing and Indentation: Make sure that your YAML file uses consistent spacing and indentation. This is crucial for YAML as it uses indentation to denote nesting.
-
Trigger IDs and Entity IDs: Ensure that all entity IDs and trigger IDs are correctly formatted and exist within your Home Assistant setup.
-
Error Handling: While your script seems comprehensive, consider adding some form of error handling or logging for situations that might not be explicitly covered.
Here's a slightly refactored version of your YAML with some improvements and without the duplicate trigger:
alias: BLINDS Bedroom
description: Automation to control bedroom blinds based on time, sunlight, and DND mode.
triggers:
- trigger: sun
event: sunset
offset: "-0:30"
id: Sunset
- trigger: time
at: "20:00:00"
id: closeB4bedtime
- trigger: state
entity_id:
- input_boolean.dnd_bedroom
from: "on"
to: "off"
id: DND Off
- trigger: state
entity_id:
- input_boolean.dnd_bedroom
from: "off"
to: "on"
id: DND On
- trigger: template
value_template: >-
{{ states('sensor.met_office_gogerddan_temperature_3_hourly') | float > 16 }}
id: highTemperature
- device_id: 2af47b9300fcf239cc70b5f2c832ca22
domain: cover
entity_id: d9c57312f1a60951eaf7d55d38530662
type: closed
trigger: device
id: Manual closed
- device_id: 2af47b9300fcf239cc70b5f2c832ca22
domain: cover
entity_id: d9c57312f1a60951eaf7d55d38530662
type: opened
trigger: device
id: Manual open
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id:
- Sunset
- closeB4bedtime
- DND On
- condition: state
entity_id: cover.blinds_upstairs_bedroom
state: open
sequence:
- action: cover.close_cover
target:
entity_id: cover.blinds_upstairs_bedroom
data: {}
- action: system_log.write
data:
message: Closed blinds due to sunset, bedtime, or DND on.
- action: input_boolean.turn_on
metadata: {}
data: {}
target:
entity_id: input_boolean.automation_closing_bedroom_blinds
- conditions:
- condition: trigger
id: DND Off
sequence:
- if:
- condition: time
after: "08:29:00"
- condition: sun
before: sunset
before_offset: "-0:30"
then:
- action: cover.set_cover_position
data:
position: 98
target:
entity_id: cover.blinds_upstairs_bedroom
- delay:
seconds: 30
- action: cover.set_cover_position
data:
position: 100
target:
entity_id: cover.blinds_upstairs_bedroom
- action: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.automation_closing_bedroom_blinds
- action: system_log.write
data:
message: Opened blinds due to DND off during daytime.
- conditions:
- condition: trigger
id: Manual closed
sequence:
- wait_for_trigger:
- trigger: state
entity_id:
- cover.blinds_upstairs_bedroom
to: open
from: closed
timeout:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- if:
- condition: time
after: "08:30:00"
before: "17:59:00"
- condition: state
entity_id: input_boolean.automation_closing_bedroom_blinds
state: "off"
then:
- action: input_boolean.turn_on
target:
entity_id: input_boolean.dnd_bedroom
data: {}
- wait_for_trigger:
- trigger: state
entity_id:
- cover.blinds_upstairs_bedroom
to: open
from: closed
timeout:
hours: 2
minutes: 0
seconds: 0
- if:
- condition: or
conditions:
- condition: sun
before: sunset
before_offset: "1:00"
- condition: time
before: "21:00:00"
then:
- action: input_boolean.turn_off
target:
entity_id: input_boolean.dnd_bedroom
data: {}
- action: system_log.write
data:
message: >-
Turned off DND mode after blinds were manually closed
and then opened.
- conditions:
- condition: trigger
id: Manual open
sequence:
- if:
- condition: sun
before: sunset
then:
- action: system_log.write
data:
message: >-
Turned off DND mode after blinds were manually opened and
then opened.
- action: input_boolean.turn_off
target:
entity_id: input_boolean.dnd_bedroom
data: {}
- conditions:
- condition: trigger
id: highTemperature
- condition: state
entity_id: cover.blinds_upstairs_bedroom
state: open
sequence:
- if:
- condition: time
before: "13:00:00"
then:
- wait_for_trigger:
- trigger: time
at: "13:00:00"
continue_on_timeout: false
- action: cover.set_cover_position
data:
position: 5
target:
entity_id: cover.blinds_upstairs_bedroom
- delay:
seconds: 30
- action: cover.set_cover_position
data:
position: 0
target:
entity_id: cover.blinds_upstairs_bedroom
- action: input_boolean.turn_on
metadata: {}
data: {}
target:
entity_id: input_boolean.automation_closing_bedroom_blinds
- action: system_log.write
data:
message: Adjusted blinds for sunlight before 1 PM.
else:
- action: cover.set_cover_position
data:
position: 5
target:
entity_id: cover.blinds_upstairs_bedroom
- delay:
seconds: 30
- action: cover.set_cover_position
data:
position: 0
target:
entity_id: cover.blinds_upstairs_bedroom
- action: system_log.write
data:
message: Adjusted blinds for sunlight after 1 PM.