From 38cd217210624d7ce1b05edb626dc05c60987deb Mon Sep 17 00:00:00 2001 From: CCOSTAN Date: Sun, 30 Oct 2016 05:31:52 +0000 Subject: [PATCH] Look at the time and adjust the brightness of the lights when turning on. --- automation/time_5am_8am.yaml | 33 ++++++++++++++++++++++++++++++++ automation/time_8am_8pm.yaml | 33 ++++++++++++++++++++++++++++++++ automation/time_8pm_5am.yaml | 37 ++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100755 automation/time_5am_8am.yaml create mode 100755 automation/time_8am_8pm.yaml create mode 100755 automation/time_8pm_5am.yaml diff --git a/automation/time_5am_8am.yaml b/automation/time_5am_8am.yaml new file mode 100755 index 00000000..aa1ca0d3 --- /dev/null +++ b/automation/time_5am_8am.yaml @@ -0,0 +1,33 @@ +- alias: detect_light_between 5am and 8am + trigger: + - platform: event + event_type: state_changed + condition: + - condition: state + entity_id: group.family + state: home + - condition: time + after: '05:00:00' + - condition: time + before: '7:59:00' + - 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.new_state is not none }}" + - condition: template + value_template: "{{ trigger.event.data.new_state.state is not none }}" + - condition: template + value_template: "{{ trigger.event.data.new_state.state == 'on' }}" + - condition: template + value_template: "{{ trigger.event.data.new_state.attributes is not none }}" + - condition: template + value_template: "{{ trigger.event.data.new_state.attributes.brightness|default(0)|int > 50 }}" + action: + - service: light.turn_on + data_template: + entity_id: "{{ trigger.event.data.entity_id }}" + brightness: 50 \ No newline at end of file diff --git a/automation/time_8am_8pm.yaml b/automation/time_8am_8pm.yaml new file mode 100755 index 00000000..7cb9a8e3 --- /dev/null +++ b/automation/time_8am_8pm.yaml @@ -0,0 +1,33 @@ +- alias: detect_light_between 8am and 12pm + trigger: + - platform: event + event_type: state_changed + condition: + - condition: state + entity_id: group.family + state: home + - condition: time + after: '08:00:00' + - condition: time + before: '20:00:00' + - 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.new_state is not none }}" + - condition: template + value_template: "{{ trigger.event.data.new_state.state is not none }}" + - condition: template + value_template: "{{ trigger.event.data.new_state.state == 'on' }}" + - condition: template + value_template: "{{ trigger.event.data.new_state.attributes is not none }}" + - condition: template + value_template: "{{ trigger.event.data.new_state.attributes.brightness|default(0)|int > 254 }}" + action: + - service: light.turn_on + data_template: + entity_id: "{{ trigger.event.data.entity_id }}" + brightness: 255 \ No newline at end of file diff --git a/automation/time_8pm_5am.yaml b/automation/time_8pm_5am.yaml new file mode 100755 index 00000000..cb2c454d --- /dev/null +++ b/automation/time_8pm_5am.yaml @@ -0,0 +1,37 @@ +- alias: detect_light_between 8pm and 5am + trigger: + - platform: event + event_type: state_changed + condition: + condition: and + conditions: + - condition: or + conditions: + - condition: time + after: '20:00:00' + - condition: time + before: '12:00:00' + - 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.new_state is not none }}" + - condition: template + value_template: "{{ trigger.event.data.new_state.state is not none }}" + - condition: template + value_template: "{{ trigger.event.data.new_state.state == 'on' }}" + - condition: template + value_template: "{{ trigger.event.data.new_state.attributes is not none }}" + - condition: template + value_template: "{{ trigger.event.data.new_state.attributes.brightness|default(0)|int > 254 }}" + action: + - service: light.turn_on + data_template: + entity_id: "{{ trigger.event.data.entity_id }}" + brightness: 255 \ No newline at end of file