mirror of
https://github.com/CCOSTAN/Home-AssistantConfig.git
synced 2025-02-22 09:01:22 +00:00
44 lines
1.7 KiB
YAML
Executable File
44 lines
1.7 KiB
YAML
Executable File
##############################################################################
|
|
### Detect when lights are turned on and adjust them accordingly based on time.
|
|
### Here is 8pm to 5am
|
|
##############################################################################
|
|
- alias: detect_light_between 5am and 8am
|
|
trigger:
|
|
- platform: event
|
|
event_type: state_changed
|
|
|
|
condition:
|
|
- condition: state
|
|
entity_id: group.family
|
|
state: home
|
|
- condition: template
|
|
value_template: "{{ trigger.event.data is not none }}"
|
|
- condition: template
|
|
value_template: "{{ trigger.event.data.entity_id is not none }}"
|
|
- condition: template
|
|
value_template: "{{ trigger.event.data.entity_id.split('.')[0] == 'light' }}"
|
|
- condition: template
|
|
value_template: "{{ trigger.event.data.entity_id.split('_')[0] != 'light.tv' }}"
|
|
- condition: template
|
|
value_template: "{{ trigger.event.data.entity_id.split('_')[0] != 'light.couch' }}"
|
|
- condition: template
|
|
value_template: "{{ trigger.event.data.entity_id.split('_')[0] != 'light.office' }}"
|
|
- condition: template
|
|
value_template: "{{ trigger.event.data.new_state.state == 'on' }}"
|
|
- condition: template
|
|
value_template: "{{ trigger.event.data.old_state.state == 'off' }}"
|
|
|
|
action:
|
|
- service: light.turn_on
|
|
data_template:
|
|
entity_id: "{{ trigger.event.data.entity_id }}"
|
|
brightness: >
|
|
{% set hour=states("sensor.time").split(':')[0] | int %}
|
|
{%- if hour >= 5 or hour < 8 -%}
|
|
50
|
|
{%- elif hour >= 8 or hour <20 -%}
|
|
255
|
|
{%- else -%}
|
|
35
|
|
{%- endif %}
|
|
|