@Tinkerer suggestion is certainly the most accurate and robust method of accomplishing what you need. However, if you don’t have a physical illuminance sensor in all of your rooms, you could try a weather based illuminance sensor in the meantime.
Set up an automation that will turn off all your lights when the illuminance (sun elevation works too, but illuminance is more consistent) goes above the desired threshold. Then use this same value to determine if automatic lights should come on by using it as a condition in the automation that turns the lights on.
If all of your lights would use the same lux value to turn on/off, I suggest creating template binary sensor and use that as the trigger/condition in your automations. Then if you want to fine tune the trigger value or add other parameters (eg is someone home) you only have to do it in one place.
binary_sensor:
- platform: template
sensors:
auto_light_on:
value_template: "{{ states('sensor.outdoor_illuminance')|int < 50 }}"
Here’s an example automation from my config. This will turn the lights on anytime the “auto-light” sensor turns on or whenever the occupancy mode changes to Home, Guest or Night, but only if the auto-light sensor is on .
- id: light_front_porch_light_auto_on
alias: "[Light] Front Porch Light Auto On"
trigger:
- platform: state
entity_id: binary_sensor.auto_light_on
to: 'on'
- platform: state
entity_id: input_select.occupancy_mode
to:
- Home
- Guest
- Night
condition:
- condition: state
entity_id: binary_sensor.auto_light_on
state: 'on'
action:
- service: light.turn_on
entity_id: light.front_porch_light
- id: light_front_porch_light_auto_off
alias: "[Light] Front Porch Light Auto Off"
trigger:
- platform: state
entity_id: binary_sensor.auto_light_on
to: 'off'
action:
- service: light.turn_off
entity_id: light.front_porch_light