Skip to content

Instantly share code, notes, and snippets.

@pavax
Last active July 28, 2023 10:10
Show Gist options
  • Save pavax/c2065acdecc6d817e47ced0d52a7e7b8 to your computer and use it in GitHub Desktop.
Save pavax/c2065acdecc6d817e47ced0d52a7e7b8 to your computer and use it in GitHub Desktop.
illuminance_aware_cover_control.yaml
blueprint:
name: Illuminance aware cover control
description: >
Close cover based on a illuminance sensor.
Allow manual control to open the cover again, but reactivate the automatic control again after a defined time.
Optional defined state sensors to prevent re-opening again. For Example when a media_player is playing
domain: automation
source_url: https://gist.github.com/pavax/ed424e1d7bbb1c69b7e33e60d1415b5a
input:
cover_control:
name: Cover Control
description: This cover to control
selector:
entity:
filter:
domain: cover
illuminance_sensor:
name: Illuminance Sensor
description: "Sensor that decides if it is to bright"
selector:
entity:
filter:
domain: sensor
device_class: illuminance
illuminance_threshold:
name: Illumincance Threshold
description: "Defines the illumincance threshold above which the cover should close "
default: 10000
selector:
number:
min: 0
max: 100000
step: 100
unit_of_measurement: lux
illuminance_time_duration:
name: Illumincance Time Duration
description: "Defines the time to given illuminance sensor must be stay above/below the threshold before the cover is closed/opened again"
default: "00:01:00"
selector:
duration:
manual_control_wait_time:
name: Manual Control Wait Time
description: "Defines the time to gain control again, after the cover was manualy opened"
default: "00:05:00"
selector:
time:
condition_sensor_01:
name: "1. Condition Sensor (Optional)"
description: "Sensor to prevent to re-open the cover again"
default: null
selector:
entity:
condition_state_01:
name: "1. Condition Sensor State (Optional)"
description: "state the given `condition_sensor` must have"
default: "on"
condition_sensor_02:
name: "2. Condition Sensor (Optional)"
description: "Sensor to prevent to re-open the cover again"
default: null
selector:
entity:
condition_state_02:
name: "2. Condition Sensor State (Optional)"
description: "state the given `condition_sensor` must have"
default: "on"
variables:
condition_sensor_01: !input condition_sensor_01
condition_state_01: !input condition_state_01
condition_sensor_02: !input condition_sensor_02
condition_state_02: !input condition_state_02
trigger:
- platform: numeric_state
entity_id: !input illuminance_sensor
above: !input illuminance_threshold
for: !input illuminance_time_duration
- platform: state
entity_id: !input cover_control
from: "closed"
to: "open"
for: !input manual_control_wait_time
- platform: state
entity_id: !input condition_sensor_01
from: !input condition_state_01
- platform: state
entity_id: !input condition_sensor_02
from: !input condition_state_02
- platform: homeassistant
event: start
id: restart
- platform: event
event_type: automation_reloaded
id: system_reload
condition:
- alias: "Illuminance too bright"
condition: numeric_state
entity_id: !input illuminance_sensor
above: !input illuminance_threshold
- condition: template
alias: "1. condition to prevent automatic control"
value_template: "{{ condition_sensor_01 == {} or not is_state(condition_sensor_01,condition_state_01) }}"
- condition: template
alias: "2. condition to prevent automatic control"
value_template: "{{ condition_sensor_02 == {} or not is_state(condition_sensor_02,condition_state_02) }}"
action:
- service: cover.close_cover
target:
entity_id: !input cover_control
- wait_for_trigger:
- platform: numeric_state
entity_id: !input illuminance_sensor
below: !input illuminance_threshold
for: !input illuminance_time_duration
- platform: state
entity_id: !input cover_control
to: open
continue_on_timeout: false
- condition: template
alias: "1. condition to prevent automatic re-opening"
value_template: "{{ condition_sensor_01 == {} or not is_state(condition_sensor_01,condition_state_01) }}"
- condition: template
alias: "2. condition to prevent automatic re-opening"
value_template: "{{ condition_sensor_02 == {} or not is_state(condition_sensor_02,condition_state_02) }}"
- condition: state
alias: is cover is still closed
entity_id: !input cover_control
state: closed
- service: cover.open_cover
target:
entity_id: !input cover_control
mode: single
max_exceeded: silent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment