Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bessarabov/45d79c557fc8c2ba4118e1465157f600 to your computer and use it in GitHub Desktop.
Save bessarabov/45d79c557fc8c2ba4118e1465157f600 to your computer and use it in GitHub Desktop.
- id: auto_light_desk_on
alias: auto_light_desk_on
trigger:
action:
- service: light.turn_on
entity_id: group.light
data_template:
brightness_pct: >
{% set v = ( states("sensor.0x04cf8cdf3c7727a6_illuminance_lux") | float * -0.18 + 100) | int %}
{{ v if v > 0 else 0 }}
kelvin: >
{% if is_state('binary_sensor.morning', 'on') %}
4000
{% elif is_state('binary_sensor.day', 'on') %}
5000
{% elif is_state('binary_sensor.evening', 'on') %}
1000
{% elif is_state('binary_sensor.night', 'on') %}
2000
{% else %}
5000
{% endif %}
- id: auto_light_desk
alias: auto_light_desk
trigger:
platform: time_pattern
minutes: "/5"
condition:
- condition: state
entity_id: group.light
state: 'on'
action:
- service: light.turn_on
entity_id: group.light
data_template:
brightness_pct: >
{% set v = ( states("sensor.0x04cf8cdf3c7727a6_illuminance_lux") | float * -0.18 + 100) | int %}
{{ v if v > 0 else 0 }}
kelvin: >
{% if is_state('binary_sensor.morning', 'on') %}
4000
{% elif is_state('binary_sensor.day', 'on') %}
5000
{% elif is_state('binary_sensor.evening', 'on') %}
1000
{% elif is_state('binary_sensor.night', 'on') %}
2000
{% else %}
5000
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment