#If I directly edit the YAML, can I run multiple automations within a single script?

1 messages · Page 1 of 1 (latest)

analog arrow
#

So here's a basic lighting automation. If I wanted to also run multiple more automations for different lights with different transition times, brightness, sunset offsets, etc., is that something I can do within the same YAML file or does that require a separate automation entirely?

alias: LV-Q1-1
description: ""
triggers:
  - trigger: sun
    event: sunset
    offset: "-01:00:00"
conditions:
  - condition: template
    value_template: "{{ (now().month >=1) and (now().month <=3) }}"
actions:
  - action: light.turn_on
    metadata: {}
    data:
      transition: 3600
      brightness_pct: 50
    target:
      device_id:
        - ebf8c14642851326484882d1f9ef91ed
mode: single
normal garnet
#

you can do as much or as little as you want in an automation. i have one thats 900 lines

#

if your question is more specific its not quite clear what youre asking

analog arrow
#

How would I format different devices with different conditions while not letting the differing conditions interfere with each other?

normal garnet
#

triggers with trigger ids and choose actions is the easiest way to "force" an automation down a certain path

oblique frost
#

It sounds like you want to apply the same automation logic but with different parameters to different devices. This is a job for a blueprint. If you convert your working automation into a blueprint, you can sub in different values for any parameter you define, point it at any allowable entity that you define, and create any number of automations. Then when you want to tweak the logic, just edit the blueprint, reload automations from Dev Tools > YAML, and all your automations using the same blueprint will be updated.

analog arrow
#

Awesome! Thank you both! It looks like, if I'm understanding correctly, I should be able to utilize blueprints to simplify the formatting in automations and then nest many automations within a single yaml file using a layout somewhat like this:

automation:
  - alias: Lights-Q1
    use_blueprint:
    path: lights.yaml
      input:
        target_lights:
          - <device ID>
        offset_time: "-01:00:00"
        transition_time: 3600
        brightness_pct: 60
        rgb_color: [255, 170, 0]
        month_range: [1, 2, 3]
  - alias: Lights-Q2
    use_blueprint:
    path: lights.yaml
      input:
        target_lights:
          - <device ID>
        offset_time: "-01:00:00"
        transition_time: 3600
        brightness_pct: 60
        rgb_color: [255, 85, 0]
        month_range: [4, 5, 6]