Condition with light brightness

Hi,
does anyone know what’s wrong with my automation? I am quite new to HA and I’ve created an automation switching on my ceiling light when the motion sensor detects a movement. This works perfectly fine. Now I created a second automation in order to switch off the light when no more motion is detected. Since I only want this to happen in the night I set the brightness to 8 in my first automation. I now want to switch the light off only when the brightness is below 8. Because in the evenings when I have the light on 100% and it is already on, I dont want it to get switched off by the second automation.

Somehow the second automation does not work and the light stays on with brightness 8.
This is my automation file:

alias: Movement detected - Light on
  description: ''
  trigger:
  - type: motion
    platform: device
    device_id: 52d9386366cf84cd8b3702b05b30a2ad
    entity_id: binary_sensor.0xbc33acfffe254161_occupancy
    domain: binary_sensor
  condition:
  - condition: or
    conditions:
    - condition: sun
      after: sunset
      after_offset: -01:00:00
    - condition: sun
      before: sunrise
      before_offset: 01:00:00
  - condition: device
    type: is_off
    device_id: b62064ed3a3b6b48b72f3b688e43fa70
    entity_id: light.deckenlampe
    domain: light
  action:
  - type: turn_on
    device_id: b62064ed3a3b6b48b72f3b688e43fa70
    entity_id: light.deckenlampe
    domain: light
    brightness_pct: 8
  mode: single
- id: '1628276907020'
  alias: No Movement detected- Light off
  description: ''
  trigger:
  - type: no_motion
    platform: device
    device_id: 52d9386366cf84cd8b3702b05b30a2ad
    entity_id: binary_sensor.0xbc33acfffe254161_occupancy
    domain: binary_sensor
  condition:
  - condition: numeric_state
    entity_id: light.deckenlampe
    attribute: brightness
    below: '20'
  action:
  - type: turn_off
    device_id: b62064ed3a3b6b48b72f3b688e43fa70
    entity_id: light.deckenlampe
    domain: light
  mode: single

Would be awesome if anybody could help me. Thanks in advance :slight_smile:

Brightness_pct 8 = 20.4 brightness. So the condition to go off isn’t met.

1 Like

Thanks man, works flawlessly now. Beginners mistake I guess. Didn’t know that there is a different between percentage and the actual brightness.

1 Like