Last active
January 5, 2022 03:21
Star
You must be signed in to star a gist
Set Light Status Based On Illuminance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Lights Based On Illuminance | |
description: > | |
Set a light's status based on a lux sensor | |
domain: automation | |
input: | |
lux_sensor: | |
name: Your Illuminance Sensor | |
selector: sensor | |
entity: | |
domain: sensor | |
device_class: illuminance | |
light: | |
name: Your light to set on/off value | |
selector: | |
target: | |
entity: | |
domain: light | |
illuminance_threshold_upper: | |
name: Illumincance Lower Threshold | |
description: "Defines what is considered 'dark enough' for the light to turn on." | |
default: 20 | |
selector: | |
number: | |
min: 0 | |
max: 100000 | |
unit_of_measurement: lux | |
illuminance_threshold_lower: | |
name: Illumincance Upper Threshold | |
description: "Defines what is considered 'bright enough' for the light to turn on." | |
default: 300 | |
selector: | |
number: | |
min: 0 | |
max: 100000 | |
unit_of_measurement: lux | |
mode: restart | |
max_exceeded: silent | |
variables: | |
lux_sensor: !input 'lux_sensor' | |
light: !input 'light' | |
illuminance_threshold_lower: !input 'illuminance_threshold_lower' | |
illuminance_threshold_upper: !input 'illuminance_threshold_upper' | |
trigger: | |
- platform: state | |
entity_id: !input 'lux_sensor' | |
condition: | |
- "{{ illuminance_sensor != None and states(illuminance_sensor)|int <= illuminance_threshold_lower|int }}" | |
action: | |
- service: homeassistant.turn_{{ trigger.to_state.state }} | |
data: | |
entity_id: '{% if trigger.from_state.entity_id == entity_1 %} {{ entity_2 }} {% else %} {{ entity_1 }} {% endif %}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment