Illumance in automation

How can I Turn on light when aqara motions sensor illumance is less than 1.2 and the time is after 8pm

Like this:

trigger:
  - platform: numeric_state
    entity_id: sensor.your_luminance
    below: 1.2
  - platform: time
    at: '20:00:00'
condition:
  - condition: time
    after: '20:00:00'
  - condition: numeric_state
    entity_id: sensor.your_luminance
    below: 1.2
action:
   service: light.turn_on
   entity_id: light.your_light

This will turn the light on if it becomes dark after 8pm, or at 8pm if it was dark before then.

2 Likes

Thanks Tom.

This gives me an error

Message malformed: required key not provided @ data[‘trigger’][1][‘platform’]

alias: Family Room Dark
trigger:
  - platform: numeric_state
    entity_id: sensor.family_room_illuminance
    below: 1.2
  - trigger: time
    at: '20:00:00'
condition:
  - condition: time
    after: '20:00:00'
  - condition: numeric_state
    entity_id: sensor.family_room_illuminance
    below: 1.2
actions:
   service: light.turn_on
   entity_id: light.family_room_right

This:

  - trigger: time
    at: '20:00:00'

Should be:

  - platform: time
    at: '20:00:00'

Made that change and now getting
Message malformed: extra keys not allowed @ data[‘actions’]
I tried wrapping 1.2 in single quotes but that didn’t make a difference

Are your actions exactly like this?

actions:
   service: light.turn_on
   entity_id: light.family_room_right

Or like this:

actions:
   service: light.turn_on
   target:
     entity_id: light.family_room_right

Like the first one but I tried both without success

Try:

  trigger:
    platform: numeric_state
    entity_id: sensor.family_room_illuminance
    below: 1.2
  condition:
    - condition: time
      after: '20:00:00'
      before: '06:00:00'
  action:
  - service: light.turn_on
    entity_id: light.family_room_right

A similar automation is working flawlessly here.

I’m not having a good day. This

Should be:

action:

I’ve corrected the original post in case any one else want’s to use it.