1
0
Fork 0
ha-config/config/packages/grow.yaml

388 lines
11 KiB
YAML

camera:
- platform: mjpeg_timelapse
image_url: http://10.10.10.112:8080/shot.jpg
name: Tent Timelapse
fetch_interval: 3600
max_frames: 1000
framerate: 5
quality: 80
loop: true
# - platform: mjpeg_timelapse
# image_url: http://10.10.10.112:8080/shot.jpg
# name: Tent Timelapse (Daily, )
# fetch_interval:
# max_frames: 365
# framerate: 10
# quality: 80
# loop: true
sensor:
- platform: schedule_state
name: Tent light schedule
template:
- binary_sensor:
- unique_id: tent_lights_status
name: Tent lights status
state: |
{{ 500 < [states('sensor.ble_illuminance_tent_c47c8d6dd13f') | int(default=0), states('sensor.ble_illuminance_tent_c47c8d6dd155') | int(default=0)] | max }}
# trigger:
# - platform: numeric_state
# entity_id:
# # - sensor.ble_illuminance_tent_c47c8d6dd155
# - sensor.ble_illuminance_tent_c47c8d6dd13f
# below: 700
# variables:
# state: false
# - platform: numeric_state
# entity_id:
# # - sensor.ble_illuminance_tent_c47c8d6dd155
# - sensor.ble_illuminance_tent_c47c8d6dd13f
# above: 700
# variables:
# state: true
- sensor:
- unique_id: tent_svp
name: "Tent SVP (Saturation Vapor Pressure)"
unit_of_measurement: kPa
device_class: pressure
state_class: measurement
state: |
{% set T = float(states('sensor.ble_temperature_tent_a4c1385ec751')) %}
{% if is_number(T) %}
{{ (0.61078 * e ** (17.2694 * T / (T + 238.3))) | round(3) }}
{% else %}
{{ states('sensor.tent_svp') | round(3) }}
{% endif %}
- unique_id: tent_avp
name: "Tent AVP (Actual Vapor Pressure)"
unit_of_measurement: kPa
device_class: pressure
state_class: measurement
state: |
{% set SVP = float(states('sensor.tent_svp')) %}
{% set RH = float(states('sensor.ble_humidity_tent_a4c1385ec751')) %}
{% if is_number(SVP) and is_number(RH) %}
{{ (SVP * (RH/100.0)) | round(3) }}
{% else %}
{{ states('sensor.tent_avp') | round(3) }}
{% endif %}
- unique_id: tent_vpd
name: "Tent VPD (Vapor Pressure Deficit)"
unit_of_measurement: kPa
device_class: pressure
state_class: measurement
state: |
{% set SVP = float(states('sensor.tent_svp')) %}
{% set AVP = float(states('sensor.tent_avp')) %}
{% if is_number(SVP) and is_number(AVP) %}
{{ (SVP - AVP) | round(3) }}
{% else %}
{{ states('sensor.tent_vpd') | round(3) }}
{% endif %}
automation:
- id: snapshot_camera
alias: Snapshot grow camera every 12 hours
trigger:
- platform: time_pattern
hours: "/12"
condition:
- "{{ is_state('binary_sensor.tent_lights_status', 'on') }}"
action:
- service: camera.snapshot
target:
entity_id: camera.tent_camera_mjpeg
data_template:
filename: "/config/camera/camera.tent_camera_mjpeg/{{ now().strftime('%Y%m%d-%H%M%S') }}.jpg"
- id: "1635395611631"
alias: Tent Cam Night Mode When Light Is Off
description: ""
trigger:
- platform: device
type: turned_off
device_id: 3a26463c21d89cc84ffad181fa45ff06
entity_id: switch.tent_power_strip_grow_lights
domain: switch
for:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
condition: []
action:
- service: switch.turn_on
target:
entity_id: switch.tent_cam_night_vision
mode: single
- id: "1635395660038"
alias: Tent Cam Night Mode When Light Is On
description: ""
trigger:
- platform: device
type: turned_on
device_id: 3a26463c21d89cc84ffad181fa45ff06
entity_id: switch.tent_power_strip_grow_lights
domain: switch
for:
hours: 0
minutes: 0
seconds: 5
milliseconds: 0
condition: []
action:
- service: switch.turn_off
target:
entity_id: switch.tent_cam_night_vision
mode: single
- id: "1635483973733"
alias: Restore tent power strip's state when available
description: ""
trigger:
- platform: state
entity_id: switch.tent_lights_local
from: unavailable
to: "off"
- platform: state
entity_id: switch.tent_usb_local
from: unavailable
to: "off"
- platform: state
entity_id: switch.tent_fans_local
from: unavailable
to: "off"
- platform: state
entity_id: switch.tent_misc_local
from: unavailable
to: "off"
- platform: state
entity_id: switch.tent_humidifier_local
from: unavailable
to: "off"
condition: []
action:
- scene: scene.tent_power_strip_state
mode: restart
- id: "1635546763394"
alias: Snapshot Tent Power Strip state on any state change
description:
Allows restoring that state when the device goes offline and comes
back online
trigger:
- platform: state
entity_id: switch.tent_misc_local
- platform: state
entity_id: switch.tent_lights_local
- platform: state
entity_id: switch.tent_fans_local
- platform: state
entity_id: switch.tent_usb_local
- platform: state
entity_id: switch.tent_humidifier_local
condition: []
action:
- service: scene.create
data:
scene_id: tent_power_strip_state
snapshot_entities:
- switch.tent_lights_local
- switch.tent_fans_local
- switch.tent_humidifier_local
- switch.tent_misc_local
- switch.tent_usb_local
mode: restart
- id: "1635838578022"
alias: Tent lights off
description: ""
trigger:
- platform: time
at: "17:30:00"
condition: []
action:
- type: turn_off
device_id: 3a26463c21d89cc84ffad181fa45ff06
entity_id: switch.tent_power_strip_grow_lights
domain: switch
mode: single
- id: "1635838786987"
alias: Tent lights on after 6 hrs
description: ""
trigger:
- platform: time
at: "23:30:00"
condition: []
action:
- type: turn_on
device_id: 3a26463c21d89cc84ffad181fa45ff06
entity_id: switch.tent_power_strip_grow_lights
domain: switch
mode: single
- id: "1635838809246"
alias: Tent lights on after 12 hrs
description: ""
trigger:
- platform: time
at: 05:30:00
condition: []
action:
- type: turn_on
device_id: 3a26463c21d89cc84ffad181fa45ff06
entity_id: switch.tent_power_strip_grow_lights
domain: switch
mode: single
- id: "1640915453691"
alias: Alert if pH drops out of range
description: ""
trigger:
- platform: numeric_state
entity_id: sensor.tent_reservoir_ph
above: input_number.maximum_ph
for:
hours: 0
minutes: 5
seconds: 0
- platform: numeric_state
entity_id: sensor.tent_reservoir_ph
below: input_number.minimum_ph
for:
hours: 0
minutes: 5
seconds: 0
condition: []
action:
- device_id: 180bff5b35717d9bb9082d52551b5065
domain: mobile_app
type: notify
message: pH outside of specified range
mode: single
- id: "1644557480025"
alias: Turn on tent humidifier
description: if VPD is high _and_ it is not above maximum allowable humidity
trigger:
- platform: numeric_state
entity_id: sensor.tent_vpd
above: input_number.maximum_tent_vpd
for:
hours: 0
minutes: 0
seconds: 0
- platform: numeric_state
entity_id: sensor.tent_humidity_cached
below: input_number.minimum_tent_humidity
condition:
- condition: numeric_state
entity_id: sensor.tent_humidity_cached
below: input_number.maximum_tent_humidity
action:
- service: switch.turn_on
data: {}
target:
entity_id:
- switch.tent_humidifier
- switch.tent_humidifier_local
mode: restart
- id: "1644557631412"
alias: Turn off tent humidifier
description: if VPD in range or humidity too high
trigger:
- platform: numeric_state
entity_id: sensor.tent_vpd
for:
hours: 0
minutes: 0
seconds: 0
below: input_number.minimum_tent_vpd
- platform: numeric_state
entity_id: sensor.tent_humidity_cached
above: input_number.maximum_tent_humidity
for:
hours: 0
minutes: 0
seconds: 0
condition:
- condition: or
conditions:
- "{{ is_state('binary_sensor.tent_lights_status', 'off') }}"
- condition: numeric_state
entity_id: sensor.tent_humidity_cached
above: input_number.minimum_tent_humidity
action:
- service: switch.turn_off
data: {}
target:
entity_id:
- switch.tent_humidifier
- switch.tent_humidifier_local
mode: restart
- id: "1645058611536"
alias: Count humidifier run time
description: ""
trigger:
- platform: time_pattern
seconds: /1
condition:
- condition: device
type: is_on
device_id: 4f8a04a40876b2a1914ea8d004b6aac5
entity_id: switch.tent_humidifier_local
domain: switch
action:
- service: counter.increment
data: {}
target:
entity_id: counter.humidifier_run_time_since_refill
mode: queued
max: 120
- id: "1645060500738"
alias: Humidifier tank timer
description: ""
trigger:
- platform: device
type: turned_on
device_id: 4f8a04a40876b2a1914ea8d004b6aac5
entity_id: switch.tent_humidifier_local
domain: switch
- platform: device
type: turned_off
device_id: 4f8a04a40876b2a1914ea8d004b6aac5
entity_id: switch.tent_humidifier_local
domain: switch
condition: []
action:
- service:
"timer.{{ 'start' if trigger.to_state.state == 'on' else 'pause'
}}
"
data: {}
target:
entity_id: timer.humidifier_time_till_refill
mode: restart
- id: "b30ad63e38bec67a0207"
alias: Timelapse tent cam only when tent lights on
trigger:
- platform: state
entity_id: binary_sensor.tent_lights_status
not_to:
- unknown
- unavailable
not_from:
- unknown
- unavailable
variables:
service: >
{% if trigger.to_state.state == 'on' %}
mjpeg_timelapse.resume_recording
{% else %}
mjpeg_timelapse.pause_recording
{% endif %}
condition: []
action:
- service: "{{ service }}"
data: {}
target:
entity_id: camera.tent_timelapse
mode: single