AutomationDataset/growboxguy/growboxguy_automations.yaml

450 lines
14 KiB
YAML

- alias: Gbox420 Hempy Bucket State Notification
description: Notify and manage persistent notification for Hempy bucket state changes.
IMPORTANT Update mobile_app_bits20 to mobile_app_<your_mobile_name> using lowercase
letters, as listed in Home Assistant under Settings > Devices & Services > Devices
triggers:
- entity_id:
- sensor.hempy_bucket1_state
- sensor.hempy_bucket2_state
trigger: state
- event_type: mobile_app_notification_action
event_data:
action: START_WATERING
trigger: event
- event_type: mobile_app_notification_action
event_data:
action: STOP_WATERING
trigger: event
conditions: []
actions:
- variables:
bucket_number: '{{ trigger.entity_id.split(''_'')[-2][-1] if ''entity_id'' in
trigger else ''-1'' }}'
new_state: '{{ (trigger.to_state.state if trigger.to_state is defined else ''UNKNOWN'').strip()
}}'
- choose:
- conditions:
- condition: template
value_template: '{{ new_state == ''DISABLED'' }}'
sequence:
- data:
notification_id: hempy_bucket{{ bucket_number }}_disabled
title: Gbox420
message: "Hempy bucket {{ bucket_number }} is {{ new_state }} \
\ \n"
action: persistent_notification.create
- data:
title: Gbox420
message: 'Hempy bucket {{ bucket_number }} is {{ new_state }}
'
data:
actions:
- action: START_WATERING
title: Start Watering
- action: STOP_WATERING
title: Stop watering
- action: DISMISS_NOTIFICATION
title: Dismiss
action: notify.mobile_app_bits20
- conditions:
- condition: template
value_template: '{{ new_state != ''DISABLED'' }}'
sequence:
- data:
notification_id: hempy_bucket{{ bucket_number }}_disabled
action: persistent_notification.dismiss
- choose:
- conditions:
- condition: template
value_template: '{{ trigger.platform == ''event'' and trigger.event.event_type
== ''mobile_app_notification_action'' }}'
sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ trigger.event.data.action == ''START_WATERING'' }}'
sequence:
- action: esphome.hempy_bucket1_start_watering
data: {}
- conditions:
- condition: template
value_template: '{{ trigger.event.data.action == ''STOP_WATERING'' }}'
sequence:
- action: esphome.hempy_bucket1_stop_watering
data: {}
mode: parallel
- alias: Send Light1 Brightness via MQTT
trigger:
- platform: state
entity_id: number.gbox420_light1_brightness
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Lt1_B
payload: '{{ trigger.to_state.state | int }}'
- alias: Send Light1 OnTime via MQTT
mode: single
trigger:
- platform: state
entity_id:
- number.gbox420_light1_ontimehour
- number.gbox420_light1_ontimeminute
action:
- delay: 00:00:03
- service: mqtt.publish
data:
topic: Gbox420CMD/Lt1_OnT
payload: '{% set hour = states(''number.gbox420_light1_ontimehour'') | int %}
{% set minute = states(''number.gbox420_light1_ontimeminute'') | int %} {{
"%02d%02d" | format(hour, minute) }}
'
- alias: Send Light1 OffTime via MQTT
mode: single
trigger:
- platform: state
entity_id:
- number.gbox420_light1_offtimehour
- number.gbox420_light1_offtimeminute
action:
- delay: 00:00:03
- service: mqtt.publish
data:
topic: Gbox420CMD/Lt1_OfT
payload: '{% set hour = states(''number.gbox420_light1_offtimehour'') | int
%} {% set minute = states(''number.gbox420_light1_offtimeminute'') | int %}
{{ "%02d%02d" | format(hour, minute) }}
'
- alias: Send Light2 OnTime via MQTT
trigger:
- platform: state
entity_id: number.gbox420_light2_brightness
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Lt2_B
payload: '{{ trigger.to_state.state | int }}'
- alias: Send MQTT when Light2 OnTime Changes
mode: single
trigger:
- platform: state
entity_id:
- number.gbox420_light2_ontimehour
- number.gbox420_light2_ontimeminute
action:
- delay: 00:00:03
- service: mqtt.publish
data:
topic: Gbox420CMD/Lt2_OnT
payload: '{% set hour = states(''number.gbox420_light2_ontimehour'') | int %}
{% set minute = states(''number.gbox420_light2_ontimeminute'') | int %} {{
"%02d%02d" | format(hour, minute) }}
'
- alias: Send Light2 OffTime via MQTT
mode: single
trigger:
- platform: state
entity_id:
- number.gbox420_light2_offtimehour
- number.gbox420_light2_offtimeminute
action:
- delay: 00:00:03
- service: mqtt.publish
data:
topic: Gbox420CMD/Lt2_OfT
payload: '{% set hour = states(''number.gbox420_light2_offtimehour'') | int
%} {% set minute = states(''number.gbox420_light2_offtimeminute'') | int %}
{{ "%02d%02d" | format(hour, minute) }}
'
- alias: Send Hempy bucket1 StartWeight
trigger:
- platform: state
entity_id: number.gbox420_bucket1_startweight
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Hemp1_B1SW
payload: '{{ trigger.to_state.state | float }}'
- alias: Send Hempy bucket1 WateringIncrement
trigger:
- platform: state
entity_id: number.gbox420_bucket1_wateringincrement
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Hemp1_B1WI
payload: '{{ trigger.to_state.state | float }}'
- alias: Send Hempy bucket1 MaxWeight
trigger:
- platform: state
entity_id: number.gbox420_bucket1_maxweight
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Hemp1_B1MW
payload: '{{ trigger.to_state.state | float }}'
- alias: Send Hempy bucket1 EvaporationTarget
trigger:
- platform: state
entity_id: number.gbox420_bucket1_evaporationtarget
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Hemp1_B1ET
payload: '{{ trigger.to_state.state | float }}'
- alias: Send Hempy bucket1 DrainTarget
trigger:
- platform: state
entity_id: number.gbox420_bucket1_draintarget
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Hemp1_B1DT
payload: '{{ trigger.to_state.state | float }}'
- alias: Send Hempy bucket1 DrainTime
trigger:
- platform: state
entity_id: number.gbox420_bucket1_draintime
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Hemp1_B1D
payload: '{{ trigger.to_state.state | int }}'
- alias: Send Hempy bucket1 PumpSpeed
trigger:
- platform: state
entity_id: number.gbox420_bucket1_pumpspeed
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Hemp1_B1PS
payload: '{{ trigger.to_state.state | int }}'
- alias: Send Hempy bucket1 PumpTimeout
trigger:
- platform: state
entity_id: number.gbox420_bucket1_pumptimeout
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Hemp1_B1T
payload: '{{ trigger.to_state.state | int }}'
- alias: Send Hempy bucket2 StartWeight
trigger:
- platform: state
entity_id: number.gbox420_bucket2_startweight
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Hemp1_B2SW
payload: '{{ trigger.to_state.state | float }}'
- alias: Send Hempy bucket2 WateringIncrement
trigger:
- platform: state
entity_id: number.gbox420_bucket2_wateringincrement
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Hemp1_B2WI
payload: '{{ trigger.to_state.state | float }}'
- alias: Send Hempy bucket2 MaxWeight
trigger:
- platform: state
entity_id: number.gbox420_bucket2_maxweight
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Hemp1_B2MW
payload: '{{ trigger.to_state.state | float }}'
- alias: Send Hempy bucket2 EvaporationTarget
trigger:
- platform: state
entity_id: number.gbox420_bucket2_evaporationtarget
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Hemp1_B2ET
payload: '{{ trigger.to_state.state | float }}'
- alias: Send Hempy bucket2 DrainTarget
trigger:
- platform: state
entity_id: number.gbox420_bucket2_draintarget
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Hemp1_B2DT
payload: '{{ trigger.to_state.state | float }}'
- alias: Send Hempy bucket2 DrainTime
trigger:
- platform: state
entity_id: number.gbox420_bucket2_draintime
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Hemp1_B2D
payload: '{{ trigger.to_state.state | int }}'
- alias: Send Hempy bucket2 PumpSpeed
trigger:
- platform: state
entity_id: number.gbox420_bucket2_pumpspeed
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Hemp1_B2PS
payload: '{{ trigger.to_state.state | int }}'
- alias: Send Hempy bucket2 PumpTimeout
trigger:
- platform: state
entity_id: number.gbox420_bucket2_pumptimeout
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Hemp1_B2T
payload: '{{ trigger.to_state.state | int }}'
- alias: Send Aeroponics MinPressure
trigger:
- platform: state
entity_id: number.gbox420_aero1_minpressure
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Aero1_PMn
payload: '{{ trigger.to_state.state | float }}'
- alias: Send Aeroponics MaxPressure
trigger:
- platform: state
entity_id: number.gbox420_aero1_maxpressure
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Aero1_PMx
payload: '{{ trigger.to_state.state | float }}'
- alias: Send Aeroponics DayInterval
trigger:
- platform: state
entity_id: number.gbox420_aero1_dayinterval
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Aero1_DInt
payload: '{{ trigger.to_state.state | int }}'
- alias: Send Aeroponics NightInterval
trigger:
- platform: state
entity_id: number.gbox420_aero1_nightinterval
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Aero1_NInt
payload: '{{ trigger.to_state.state | int }}'
- alias: Send Aeroponics SprayDuration
trigger:
- platform: state
entity_id: number.gbox420_aero1_sprayduration
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Aero1_Dur
payload: '{{ trigger.to_state.state | float }}'
- alias: Send Aeroponics PumpSpeed
trigger:
- platform: state
entity_id: number.gbox420_aero1_pumpspeed
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Aero1_PS
payload: '{{ trigger.to_state.state | int }}'
- alias: Send Aeroponics PumpPrimingTime
trigger:
- platform: state
entity_id: number.gbox420_aero1_pumpprimingtime
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Aero1_PPT
payload: '{{ trigger.to_state.state | int }}'
- alias: Send Aeroponics PumpTimeout
trigger:
- platform: state
entity_id: number.gbox420_aero1_pumptimeout
action:
- service: mqtt.publish
data:
topic: Gbox420CMD/Aero1_PT
payload: '{{ trigger.to_state.state | int }}'
- alias: Gbox420 Hempy Bucket State Notification
description: 'Notify and manage persistent notification for Hempy bucket state changes.
IMPORTANT: Update mobile_app_bits20 to mobile_app_<your_mobile_name> using lowercase
letters, as listed in Home Assistant under Settings > Devices & Services > Devices'
triggers:
- entity_id:
- sensor.hempy_bucket1_state
- sensor.hempy_bucket2_state
trigger: state
- event_type: mobile_app_notification_action
event_data:
action: START_WATERING
trigger: event
- event_type: mobile_app_notification_action
event_data:
action: STOP_WATERING
trigger: event
conditions: []
actions:
- variables:
bucket_number: "{% if trigger.entity_id == 'sensor.hempy_bucket1_state' %}\n\
\ 1\n{% elif trigger.entity_id == 'sensor.hempy_bucket2_state' %}\n 2\n\
{% else %}\n {{ trigger.event.data.message[13] if trigger.event.data.message|length\
\ > 13 else '-1' }}\n{% endif %}"
new_state: '{{ (trigger.to_state.state if trigger.to_state is defined else ''UNKNOWN'').strip()
}}'
- if:
- condition: template
value_template: '{{ new_state == ''DISABLED'' or new_state == ''DRY'' }}'
then:
- data:
notification_id: hempy_bucket{{ bucket_number }}_alert
title: Gbox420
message: 'Hempy bucket {{ bucket_number }} is {{ new_state }}
'
action: persistent_notification.create
- data:
title: Gbox420
message: 'Hempy bucket {{ bucket_number }} is {{ new_state }}
'
data:
actions:
- action: START_WATERING
title: Start watering
data:
bucket_number: '{{ bucket_number }}'
- action: STOP_WATERING
title: Stop watering
data:
bucket_number: '{{ bucket_number }}'
- action: DISMISS_NOTIFICATION
title: Dismiss
action: notify.mobile_app_bits20
- if:
- condition: template
value_template: '{{ new_state != ''DISABLED'' and new_state != ''DRY''}}'
then:
- data:
notification_id: hempy_bucket{{ bucket_number }}_alert
action: persistent_notification.dismiss
- if:
- condition: template
value_template: '{{ trigger.event.data.action in [''START_WATERING'', ''STOP_WATERING'']
}}'
then:
- action: "{% if trigger.event.data.action == 'START_WATERING' %}\n esphome.hempy_bucket{{\
\ bucket_number }}_start_watering\n{% else %}\n esphome.hempy_bucket{{ bucket_number\
\ }}_stop_watering\n{% endif %}"
mode: parallel