266 lines
7.1 KiB
YAML
266 lines
7.1 KiB
YAML
---
|
|
|
|
homeassistant:
|
|
customize:
|
|
package.node_anchors:
|
|
common_attrs: &common_attrs
|
|
package: "more_lights"
|
|
|
|
light.study_plants:
|
|
icon: mdi:sprout
|
|
proto: zigbee
|
|
<<: *common_attrs
|
|
|
|
binary_sensor.grow_lights_1_schedule:
|
|
start_time: "09:00"
|
|
end_time: "18:00"
|
|
icon: mdi:sprout
|
|
<<: *common_attrs
|
|
|
|
input_boolean:
|
|
grow_lights_1_state:
|
|
name: grow_lights_1_state
|
|
icon: mdi:sprout
|
|
grow_lights_1_on_set_max_brightness:
|
|
name: input_boolean.grow_lights_1_on_set_max_brightness
|
|
icon: mdi:brightness-percent
|
|
|
|
input_number:
|
|
grow_lights_1_color_temp:
|
|
name: grow_lights_1_color_temp
|
|
step: 1.0
|
|
# some hardcoded requirement in hass that color temp is 157-500
|
|
max: 158
|
|
min: 153
|
|
initial: 153
|
|
|
|
grow_lights_1_brightness:
|
|
name: grow_lights_1_brightness
|
|
min: 1
|
|
max: 8
|
|
step: 1.0
|
|
initial: 8
|
|
mode: slider
|
|
icon: mdi:sprout
|
|
|
|
|
|
script:
|
|
grow_lights_1_on:
|
|
mode: single
|
|
sequence:
|
|
- service: input_boolean.turn_on
|
|
data: {}
|
|
target:
|
|
entity_id: input_boolean.grow_lights_1_state
|
|
- service: remote.send_command
|
|
target:
|
|
entity_id: remote.broadlink
|
|
data:
|
|
device: grow_lights_1
|
|
command: power_on
|
|
#num_repeats: 1
|
|
#delay_secs: 1.0
|
|
#hold_secs: 0.0
|
|
- if:
|
|
- condition: template
|
|
value_template: >-
|
|
{{ is_state("input_boolean.grow_lights_1_on_set_max_brightness", "on") | bool or False }}
|
|
then:
|
|
- service: script.grow_lights_1_brightness_max
|
|
|
|
grow_lights_1_off:
|
|
mode: single
|
|
sequence:
|
|
- service: input_boolean.turn_off
|
|
data: {}
|
|
target:
|
|
entity_id: input_boolean.grow_lights_1_state
|
|
- service: remote.send_command
|
|
target:
|
|
entity_id: remote.broadlink
|
|
data:
|
|
device: grow_lights_1
|
|
command: power_off
|
|
#num_repeats: 1
|
|
#delay_secs: 1.0
|
|
#hold_secs: 0.0
|
|
|
|
grow_lights_1_brightness_up:
|
|
mode: single
|
|
sequence:
|
|
- service: remote.send_command
|
|
target:
|
|
entity_id: remote.broadlink
|
|
data:
|
|
device: grow_lights_1
|
|
command: brightness_up
|
|
delay_secs: 1.1
|
|
num_repeats: "{{ num_repeats | default(1) | int | abs }}"
|
|
|
|
grow_lights_1_brightness_down:
|
|
mode: single
|
|
sequence:
|
|
- service: remote.send_command
|
|
target:
|
|
entity_id: remote.broadlink
|
|
data:
|
|
device: grow_lights_1
|
|
command: brightness_down
|
|
delay_secs: 1.1
|
|
#hold_secs: 0.1
|
|
num_repeats: "{{ num_repeats | default(1) | int | abs }}"
|
|
|
|
grow_lights_1_brightness_min:
|
|
mode: single
|
|
sequence:
|
|
- service: remote.send_command
|
|
target:
|
|
entity_id: remote.broadlink
|
|
data:
|
|
device: grow_lights_1
|
|
command: brightness_down
|
|
hold_secs: 0.1
|
|
num_repeats: "{{ 8*2 | int }}"
|
|
- service: input_number.set_value
|
|
target:
|
|
entity_id: input_number.grow_lights_1_brightness
|
|
data:
|
|
value: "{{ 1 | int }}"
|
|
|
|
grow_lights_1_brightness_max:
|
|
mode: single
|
|
sequence:
|
|
- service: remote.send_command
|
|
target:
|
|
entity_id: remote.broadlink
|
|
data:
|
|
device: grow_lights_1
|
|
command: brightness_up
|
|
hold_secs: 0.1
|
|
num_repeats: "{{ 8*2 | int }}"
|
|
- service: input_number.set_value
|
|
target:
|
|
entity_id: input_number.grow_lights_1_brightness
|
|
data:
|
|
value: "{{ 8 | int }}"
|
|
|
|
grow_lights_1_brightness_set:
|
|
mode: single
|
|
sequence:
|
|
- service: script.grow_lights_1_brightness_min
|
|
- service: script.grow_lights_1_brightness_up
|
|
data:
|
|
num_repeats: "{{ brightness_steps | int }}"
|
|
- service: input_number.set_value
|
|
target:
|
|
entity_id: input_number.grow_lights_1_brightness
|
|
data:
|
|
value: "{{ brightness_steps | int }}"
|
|
|
|
grow_lights_1_color_temp:
|
|
mode: single
|
|
sequence:
|
|
- service: remote.send_command
|
|
target:
|
|
entity_id: remote.broadlink
|
|
data:
|
|
device: grow_lights_1
|
|
command: color_temp
|
|
- service: input_number.set_value
|
|
target:
|
|
entity_id: input_number.grow_lights_1_color_temp
|
|
data:
|
|
value: "{{ color_temp }}"
|
|
|
|
automation:
|
|
- alias: grow_lights_1_schedule
|
|
id: grow_lights_1_schedule
|
|
trigger:
|
|
- platform: state
|
|
entity_id: binary_sensor.grow_lights_1_schedule
|
|
to: "on"
|
|
- platform: state
|
|
entity_id: binary_sensor.grow_lights_1_schedule
|
|
to: "off"
|
|
condition: []
|
|
action:
|
|
- service: >-
|
|
light.turn_{{ trigger.to_state.state }}
|
|
target:
|
|
entity_id:
|
|
- light.grow_lights_1
|
|
- light.study_plants
|
|
data: {}
|
|
- alias: grow_lights_1_cron_send_state
|
|
id: grow_lights_1_cron_send_state
|
|
trigger:
|
|
- platform: time_pattern
|
|
minutes: /10
|
|
condition: []
|
|
action:
|
|
- if:
|
|
- condition: state
|
|
entity_id: binary_sensor.grow_lights_1_schedule
|
|
state: "on"
|
|
then:
|
|
- service: script.grow_lights_1_on
|
|
data: {}
|
|
- if:
|
|
- condition: state
|
|
entity_id: binary_sensor.grow_lights_1_schedule
|
|
state: "off"
|
|
then:
|
|
- service: script.grow_lights_1_off
|
|
data: {}
|
|
mode: single
|
|
|
|
|
|
binary_sensor:
|
|
- platform: tod
|
|
unique_id: grow_lights_1_schedule
|
|
name: grow_lights_1_schedule
|
|
after: "09:00"
|
|
before: "18:00"
|
|
|
|
|
|
light:
|
|
- platform: template
|
|
lights:
|
|
grow_lights_1:
|
|
unique_id: grow_lights_1
|
|
friendly_name: "Grow lights 1"
|
|
value_template: "{{ states('input_boolean.grow_lights_1_state') }}"
|
|
temperature_template: >-
|
|
{{ states("input_number.grow_lights_1_color_temp") }}
|
|
level_template: >-
|
|
{% set brightness_max_8 = states('input_number.grow_lights_1_brightness')|int %}
|
|
{% set brightness_max_256 = brightness_max_8 * 32 %}
|
|
{% set brightness_max_255 = min(255, brightness_max_256) %}
|
|
{{ max(1, brightness_max_255) }}
|
|
icon_template: >-
|
|
{% if is_state('input_boolean.grow_lights_1_state', 'on') %}
|
|
mdi:sprout
|
|
{% else %}
|
|
mdi:sprout-outline
|
|
{% endif %}
|
|
turn_on:
|
|
service: script.grow_lights_1_on
|
|
turn_off:
|
|
service: script.grow_lights_1_off
|
|
set_temperature:
|
|
service: script.grow_lights_1_color_temp
|
|
set_level:
|
|
service: >-
|
|
{% if brightness > 200 %}
|
|
script.grow_lights_1_brightness_max
|
|
{% elif brightness < 100 %}
|
|
script.grow_lights_1_brightness_min
|
|
{% else %}
|
|
script.grow_lights_1_brightness_set
|
|
{% endif %}
|
|
data:
|
|
brightness: "{{ brightness | int }}"
|
|
brightness_steps: >-
|
|
{% set steps = brightness // 32 | default(8) | round | int %}
|
|
{{ max(1, steps) | int }}
|