Yaml + automation

Hello

I’m trying to set up an automation that occurs when one light turns off causing another one to flash on and off. Can someone look at this yaml code and tell me what I need to do to make this automation work? Right now when the “switch.basement_light_switch” goes from “on” to “off”, nothing happens.

Thanks in advance for any help that can be provided.

  alias: Notification
  description: ''
  trigger:
  - platform: state
    entity_id:
    - switch.basement_light_switch
    from: 'on'
    to: 'off'
    condition: []
    action:
      - type: turn_on
        device_id: 654b1aedfd56068db0376a100ab8de2b
        entity_id: light.washer_dryer_notification_bulb_mintransitionlight
        domain: light
        data:
          brightness: 255
          rgb_color: [255, 255, 255]
      - delay:
          seconds: 1
      - type: turn_off
        device_id: 654b1aedfd56068db0376a100ab8de2b
        entity_id: light.washer_dryer_notification_bulb_mintransitionlight
        domain: light- 
        delay:
          seconds: 1
      - type: turn_on
        device_id: 654b1aedfd56068db0376a100ab8de2b
        entity_id: light.washer_dryer_notification_bulb_mintransitionlight
        domain: light
        data:
          brightness: 255
          rgb_color: [255, 255, 255]
      - delay:
          seconds: 1
      - type: turn_off
        device_id: 654b1aedfd56068db0376a100ab8de2b
        entity_id: light.washer_dryer_notification_bulb_mintransitionlight
        domain: light

Please format your yaml right so we can see if there are some indentation erros, look here how to do it:

In brief, wrap your block in three backticks (```)

Hello
Thanks for the back tick suggestion. I’ve updated my post.

Your indentation is a little bit wrong. I updated the code, it’s untested but should work:

- id: some_automations_id
  alias: Notification
  description: ''
  trigger:
    - platform: state
      entity_id: switch.basement_light_switch
      from: 'on'
      to: 'off'
  condition: []
  action:
    - service: light.turn_on
      entity_id: light.washer_dryer_notification_bulb_mintransitionlight
      data:
        brightness: 255
        rgb_color: [255, 255, 255]
    - delay:
        seconds: 1
    - service: light.turn_off
      entity_id: light.washer_dryer_notification_bulb_mintransitionlight
    - delay: 
        seconds: 1
    - service: light.turn_on
      entity_id: light.washer_dryer_notification_bulb_mintransitionlight
      data:
        brightness: 255
        rgb_color: [255, 255, 255]
    - delay:
        seconds: 1
    - service: light.turn_off
      entity_id: light.washer_dryer_notification_bulb_mintransitionlight

When writing your automations in yaml, don’t use device actions. It’s far more complicated and has no advantage compared to the services i used. Just a little hint, it makes the things much more easy :wink:

Thanks for the help. Ultimately I’d like to replace " switch.basement_light_switch" with “binary_sensor.washer_wash_complete” and trigger the “light.washer_dryer_notification_bulb_mintransitionlight”. Will the code still work if I do this? Ultimately I want a light bulb to flash whenever the washing machine has finished. I was using the above code as a test before adding the washer.

Yes you can. Just exchange the entities in the automation an it will work. Using the services there is no fiddeling with device ids or domains, just entity id and thats all!