I need some help please understanding what I am doing wrong here. I want a manual event (event_type: said_task_finished) to trigger running an automation which in turn runs a script provided it meets a date range condition.
Logical steps:
- Manual event triggers automation to run
- additional condition is met (switch.tank_fill = off)
- automation decides which script is run based on a pre-defined date range
I have managed to get it working fine in an automation but I need to create a few of these and thought it would be easier to do/manage in a blueprint
My code:
blueprint:
name: "Nutrient Feed Phase"
description: ''
domain: automation
input:
event_type:
name: "Feed Trigger"
description: Select notification to trigger feed cycle
selector:
trigger:
veg_phase_1:
name: "Vegetative Phase 1 - Nutrient Type"
description: "Select nutrient feed script"
selector:
entity:
filter:
- domain: script
condition_veg_phase_1:
name: "Vegetative Phase 1 Condition"
description: "Add conditions if needed"
selector:
condition:
veg_phase_2:
name: "Vegetative Phase 2 - Nutrient Type"
description: "Select nutrient feed script"
selector:
entity:
filter:
- domain: script
condition_veg_phase_2:
name: "Vegetative Phase 2 Condition"
description: "Add conditions if needed"
default: []
selector:
condition:
triggers:
- trigger: event
event_type: ''
event_data:
entity_id: !input event_type
conditions:
- condition: state
entity_id: switch.esphome_web_f54944_tank_fill
state: 'off'
actions:
- choose:
- conditions:
- condition: template
value_template: "{{ condition_veg_phase_1 }}"
sequence:
- action: !input veg_phase_1
- conditions:
- condition: template
value_template: "{{ condition_veg_phase_2 }}"
sequence:
- action: !input veg_phase_2
mode: single
Condition template (for date range)
condition: template
value_template: >
{% set begin = states('sensor.vegetative_phase_1') | as_datetime | as_local %}
{% set end = states('sensor.vegetative_phase_2') | as_datetime | as_local %}
{% set d = [now().month, now().day] %} {{ [begin.month, begin.day] >= d or d <
[end.month, end.day] }}