Turn interior light on and off based on several triggers

This is beyond sun above horizon.

I live in Norway, and this time of the year it’s still dark inside (need interior light) at 10:30 AM, and it’s still no need for interior light in the summer when the sun barely dips below the horizon.

Below you see the big green part is the time of day when we need interior lights on around her :slight_smile:

So my approach to control interior and exterior lights is to determine when it’s dark inside and outside, based on a luminance sensor pointing to the sky on my south wall.

Today I found my automations did not trigger in the morning, and I found one reason would be the luminance sensor never changed to off during the night (doh…), thus never triggering the automation:

binary_sensor.dark_inside is set when luminance outside is below xx lux, and cleared when above the threshold.

  - alias: "[Lys] Grunnbelysning på eller alt lys av"
      - platform: state
        entity_id: binary_sensor.dark_inside   ## triggers when binary sensor changes
        # This script turns light on if the light is off and vice versa
      - service: script.lys_grunnbelysning_pa_eller_av

I am looking for a way to make sure we turn on the lights even when its dark in the moring.

Would my only solution here be to use a time trigger? Are there there other alternatives?

I have a template sensor based on a few other sensors to determine if it is dark outside. perhaps this might help:

########Environmental Sensor Templates########
        friendly_name: 'Dark Outside'
        value_template: >
          {% if (states.sun.sun.attributes.elevation | int < 4) %}true
          {% elif ( (states.sun.sun.attributes.elevation | int < 4.5) and (states.sensor.dark_sky_cloud_coverage.state | int > 100)) %}true
          {% elif ( (states.sun.sun.attributes.elevation | int < 6) and (states.sensor.dark_sky_cloud_coverage.state | int > 100)) %}true
          {% elif (states.sensor.dark_sky_cloud_coverage.state | int > 100) %}true
          {% else %} false {% endif %}

I am sorry, for not explaining my issue throughoutly. I do know when it’s dark etc. using a luminance sensor.

My question is how to make sure the automation is triggered when the light sensor never turns off before I need the interior light to turn on in the morning.

I turn off off light using an automation before I go to bed at night.

When I wake up, it’s still dark (but in the summer it’s only dark for 3 hours). When I go out of bed in the morning (workdays and non-working days, summer and winter) I am
Looking for a good way of triggering the the interior light automation.

This would be:

  • time of day e.g. “06:00:00” on working days and “08:00:00”
  • mobile phone not connected to charger
  • PIR sensor detecting when out of bed
  • a button to push in HA and physical Britton in bathroom.

All these would obviously have caveats.
What are your experience/advice.