Wondering the difference between ‘data’ and ‘target’

Hi, wondering the difference between ‘data’ and ‘target’ as I’m seeing below? In this case, I’m wanting to turn my lights on 60 minutes before sunrise using the switch, and then set the scene (which is to dim the lights to 50%) after 2.5 seconds. I noticed that transition is used common for delay, but in my blob I am seeing target, not data as in the examples above. Also, does it matter the order? Meaning do I need to change it around to switch the light on first and then call the scene in code? Thanks much!

  alias: Turn on Garage and Porch Lights at Sunrise - Automation
  description: ''
  trigger:
  - platform: sun
    event: sunrise
    offset: '-60'
  condition: []
  action:
  - service: scene.turn_on
    target:
      entity_id: scene.dim_garage_and_porch_lights_at_9
      transition: 2.5
    metadata: {}
  - type: turn_on
    device_id: 66a47bb533cd30bd22dbb8963272dd06
    entity_id: switch.front_garage_and_porch_lights
    domain: switch
  mode: single

As the forum hints when you started that reply - please don’t resurrect a thread marked as resolved.

transition is not for a delay, it’s how long the light takes to turn to the new state.

In your automation the scene will be turned on and immediately the switch will be turned on. If you want a delay you have to add one.

Sorry, should have seen/heeded to the warning. Felt weird to reopen and I shouldn’t have.

Is the use of delay below correct? Does the action of the switch turning on need to come before the scene in code?

Again, my apologies and lesson learned.

  alias: Turn on Garage and Porch Lights at Sunrise - Automation
  description: ''
  trigger:
  - platform: sun
    event: sunrise
    offset: '-60'
  condition: []
  action:
  - service: scene.turn_on
    target:
      entity_id: scene.dim_garage_and_porch_lights_at_9
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
    metadata: {}
  - type: turn_on
    device_id: 66a47bb533cd30bd22dbb8963272dd06
    entity_id: switch.front_garage_and_porch_lights
    domain: switch
  mode: single

The sequence you’ve written is:

  1. Turn on the scene
  2. Wait 2 seconds
  3. Turn on the switch

Is that what you want?

Ha, I am looking for the opposite. It’s starting to make sense now.

  1. Turn on the switch
  2. Wait 2 seconds
  3. Change the scene
alias: Turn on Garage and Porch Lights at Sunrise - Automation
description: ""
trigger:
  - platform: sun
    event: sunrise
    offset: "-60"
condition: []
action:
  - type: turn_on
    device_id: 66a47bb533cd30bd22dbb8963272dd06
    entity_id: switch.front_garage_and_porch_lights
    domain: switch
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - service: scene.turn_on
    target:
      entity_id: scene.dim_garage_and_porch_lights_at_9
    metadata: {}
mode: single

That look correct?

Well, after adding the yaml and going back to the graphical UI, it seems there is actually a graphically way to do the delay which would have saved us both some time. I guess it got me into yaml for a bit, though! Thanks

1 Like