For the most part, I’m using Node-RED for automations but I’m just playing with the automations within HA and trying to replicate the same functionality just using the interface rather than having to resort to YAML.
One thing I can’t work out is whether you can have ONE automation that turns a light on with motion and then off again if there is no motion for 5 minutes. At the moment, I have one automation to turn the light on, and then another to turn the light off.
Is that how it goes, or is there another way of doing it?
Like I say, this is just to kick the tyres on the automations inside HA, not to find a way of achieving the goal per se.
Hi Andy, I tend to do it all within one automation and also dim the light for 15 secs before it turns off just to let people know. See the example below:
I have it working through yaml mode exactly with the automation restart mode. It can be triggered by both motion sensors, or simply by me triggering the vibration sensor of my office chair. The automation couldn’t be done like this before one of the recent HA versions.
See my snippet below:
automation:
- alias: '[study|lights] Turn on lights when motion is detected'
mode: restart
trigger:
- platform: state
entity_id: binary_sensor.study_motion_combined
to: 'on'
- platform: state
entity_id: sensor.vibration_sensor_attributes
- platform: state
entity_id: binary_sensor.vibration_sensor
to: 'on'
condition:
- condition: numeric_state
entity_id: sensor.average_illumination_study
below: 40
action:
- service: light.turn_on
data:
entity_id: light.study_lights
brightness: 255
- service: switch.flux_study_update
- delay:
minutes: 15
- service: light.turn_off
entity_id: light.study_lights