Condition based on light not working

Hi, I’m not sure why, but this works:

- id: sunset_light_living_room_lamp_level
  alias: Test - light.living_room_lamp_level
  hide_entity: False
  trigger:
    platform: time
    at: '17:52:00'
  action:
    service: light.turn_on
    entity_id:
      - light.living_room_lamp_level
    data:
      brightness: 10

But this does not:

- id: sunset_light_living_room_lamp_level
  alias: Test - light.living_room_lamp_level
  hide_entity: False
  trigger:
    platform: time
    at: '17:52:00'
  condition:
    condition: state
      entity_id: light.living_room_lamp_level
      state: 'off'
  action:
    service: light.turn_on
    entity_id:
      - light.living_room_lamp_level
    data:
      brightness: 10

No matter what state the dimmer switch is in, the light never turns on when the condition is present. I’m trying to make an automation that sets the light levels only if the lights are off. Can anyone help?

The docs show the entity_id and state at the same indentation level as condition:state. Does that help you?


condition:
  condition: state
  entity_id: device_tracker.paulus
  state: not_home

That seems to have done the trick, thanks!

So, add-on question. Is there a way to do a condition on a service? I’m going to need a bunch of automations to make it work on a light-by-light level. I want the below to basically only change each individual light if that light is off, similar to the above.

- id: sunset_lights
  alias: Sunset lights
  hide_entity: False
  trigger:
    platform: sun
    event: sunset
    offset: "-00:30:00"
  action:
    - service: light.turn_on
      entity_id:
        - light.entry_way_lamp_level
        - light.kitchen_over_sink_level
        - light.kitchen_overheads_level
        - light.kitchen_pendant_lights_level
        - light.master_bedroom_lamps_level
      data:
        brightness: 25
    - service: light.turn_on
      entity_id:
        - light.kitchen_table_light_level
        - light.family_room_lamp_level
        - light.family_room_overheads_level
      data:
        brightness: 100
    - service: switch.turn_on
      entity_id:
        - switch.outside_back_door_switch
        - switch.outside_front_door_switch
        - switch.outside_garage_back_switch
        - switch.outside_garage_front_switch
        - switch.living_room_tall_lamps_switch