Puzzling Timer Example

This example, from:


would serve my purpose well:
automation:
- alias: Turn on kitchen light when there is movement
  trigger:
    platform: state
    entity_id: sensor.motion_sensor
    to: 'on'
  action:
    service: light.turn_on
    entity_id: light.kitchen_light

- alias: Turn off kitchen light 10 minutes after last movement
  trigger:
    platform: state
    entity_id: sensor.motion_sensor
    to: 'off'
    for:
      minutes: 10
  action:
    service: light.turn_off
    entity_id: light.kitchen_light

But how could I implement it with the Automations UI?
If it can’t be, then can I just paste it into my automations.yaml file (with appropriate modifications to suit my set-up), ignoring the fact that it hasn’t got a HA generated id?
Jim

Where’s the problem with the automations UI? Where did you get stuck?

Yes, you can. You can add the id yourself, just needs to be unique. You could also create an additional, separate file for automations you wrote manually and keep the “notmal” one for UI generated automations.
See here for more details

1 Like

The example shows just one ‘automation’, but includes two ‘sets’ of ‘Trigger->Actions’. When you get to the last Action in the UI, you can’t continue by following it with a further ‘Trigger->Action’.

Thanks for the reply ‘Burningstone’.
Jim

Because it’s two automations not one. You need to create one for turning it on and a second one for turning it off. The example shows two automations as well. In the example, each automation starts with a hyphen and alias:
Are you sure that these automations fit in your setup? How long does it take until your motion sensor changes from ‘on’ to ‘off’ once there is no more motion? There are some motion sensor where you can adjust this, but for some it’s fixed at e.g. 5 minutes, this would mean it would actually take 15 minutes (5 motion sensor + 10 automation) for the light to turn off after no motion.

Like Burningstone said, there are two automations in the example. What leads you to interpret it as being only one automation?

If it’s the presence of the word “automation:” then that simply serves as a heading to indicate that everything beneath it are automations. Take note of the format. The word “automation:” is not indented and then each automation beneath it begins with a hyphen.

Thanks for the helpful replies.
Jim