Skip to content

Instantly share code, notes, and snippets.

@quallenbezwinger
Last active January 13, 2021 10:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quallenbezwinger/9e37a046474dc555f75b871c27ad5693 to your computer and use it in GitHub Desktop.
Save quallenbezwinger/9e37a046474dc555f75b871c27ad5693 to your computer and use it in GitHub Desktop.
Turn on scene if illuminance will gow under a specific illuminance and if in specific time frame. Turn off group elements, if illuminance is above threshold. Illuminance check will be done every five minutes and not by every sensor state change. This saves performance.
blueprint:
name: Activate scene by illuminance in time-frame
description: Turn on scene if illuminance will gow under a specific threshold and if in specific time frame. Turn off group elements, if illuminance is above threshold. Scene will not activated if lightgoup is active to prevent an overwrite.
domain: automation
source_url: https://gist.github.com/dirkk1980/9e37a046474dc555f75b871c27ad5693
input:
lightsensor_entity:
name: Illuminance Sensor
selector:
entity:
domain: sensor
device_class: illuminance
illuminace_level:
name: Max Illuminance
description: Maximal immuminance level in lux. If illuminance is higher, scene will not be enabled
default: 600
selector:
number:
min: 0
max: 5000
unit_of_measurement: lux
off_group:
name: Elements to turn off
description: Elements which should be turned off if illuminance is above threshold
selector:
entity:
domain: group
scene_to_activate:
name: Scene to activate
description: Scene which will be activated if illuminance will be under threshold
selector:
entity:
domain: scene
time_scene_start:
name: Scene - time frame start
description: Time from which on scene will be activated
default: "00:00:00"
selector:
time:
time_scene_end:
name: Scene - time frame end
description: Time from which on scene will be not activated
default: "00:00:00"
selector:
time:
mode: single
trigger:
platform: state
entity_id: !input lightsensor_entity
action:
- choose:
- conditions:
- condition: time
after: !input time_scene_start
before: !input time_scene_end
- condition: numeric_state
entity_id: !input lightsensor_entity
below: !input illuminace_level
- condition: state
entity_id: !input off_group
state: "off"
sequence:
- scene: !input scene_to_activate
- conditions:
- condition: time
after: !input time_scene_start
before: !input time_scene_end
- condition: numeric_state
entity_id: !input lightsensor_entity
above: !input illuminace_level
- condition: state
entity_id: !input off_group
state: "on"
sequence:
- service: homeassistant.turn_off
entity_id: !input off_group
- conditions:
- condition: time
before: !input time_scene_start
after: !input time_scene_end
- condition: state
entity_id: !input off_group
state: "on"
sequence:
- service: homeassistant.turn_off
entity_id: !input off_group
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment