Keep the light on with Ikea Tradfri motion sensor

Hey,

I would like to make a simple automation and keep the lights on as long there is a movement in the bathroom. Nevertheless the light turns off after 1 minute and then I need to wave and wait for around 30 seconds until the light turns on again.
I am using Raspberry Pi 3 + Deconz + Home Assistant in a docker container. For sensors I am using Ikea motion sensor & light bulb. My automation code is:

- id: '1578393462491'
  alias: Turn the light on when motion is detected & it's dark
  description: ''
  trigger:
  - entity_id: binary_sensor.tradfri_motion_sensor
    platform: state
    to: 'on'
  action:
  - device_id: 8059b3a0a5ea4c42aa6134173d14aaca
    domain: light
    entity_id: light.ikea_dimmable_light_bad
    type: turn_on
- id: '1579034320307'
  alias: Turn off the light in bathroom after 2 mins
  description: ''
  trigger:
  - entity_id: binary_sensor.tradfri_motion_sensor
    platform: state
    to: 'off'
    for:
      minutes: 1
  action:
  - device_id: 8059b3a0a5ea4c42aa6134173d14aaca
    domain: light
    entity_id: light.ikea_dimmable_light_bad
    type: turn_off

Hi there and welcome to the Forum. You are not the first to have the “problem”. Maybe this will help you …

https://community.home-assistant.io/t/motion-detection-sensor-advice/150630

Hi Volker,

hmm not really, I still don’t know how to adjust the code so that my motion sensor checks let say every 15 seconds if there is some motion in order to let the lights on. And than go down with the brightness after 30 seconds and turn of the light after 1 minute without any movement.

You cannot set the motion sensor to check for motion in less than 1 minute.
It checks every minute for motion. If detects motion at exacly 60th second, it will not turn off the light.
You can extend the detection time after 60s if you add 30s or more in your automation before turning off the light. If it detects motion in that additional time of 30s, it will trigger the automation and extend the 1min time with 30s again.

Here is my automation:

- id: '1562755519522'
  alias: Kitchen - Light on when Motion detected
  trigger:
  - entity_id: binary_sensor.kitchen_motion_sensor
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      entity_id: light.kitchen_lightstrip
    service: light.turn_on
- id: '1562755519502'
  alias: Kitchen - Light off when no Motion detected
  trigger:
  - entity_id: binary_sensor.kitchen_motion_sensor
    for: 0:00:30
    from: 'on'
    platform: state
    to: 'off'
  condition: []
  action:
  - data:
      entity_id: light.kitchen_lightstrip
    service: light.turn_off

Motion sensors are built to big detect motion movements, eg. a person walking. They cannot detect a person sitting on the toilet and only fingers moving or fidgeting while seated.

With that in mind, you need to consider typically how long you might be in the room stationary.

For example, for my living room auto ambient lights, I’ve chosen 15 minutes timeout with override if TV is on. Similarly, for study (where I sit infront of computer to tweak HA), I’ve chosen 10 minutes and sometimes still find not long enough.
For toilet, I think 10 minutes is more suitable than 1-2 minutes.