Skip to content

Instantly share code, notes, and snippets.

@jack-fin
Last active January 5, 2022 03:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jack-fin/66d8cb32c7c2cd0641ebd623af126139 to your computer and use it in GitHub Desktop.
Set Light Status Based On Illuminance
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