If it's still dark out turn on lights if not don't

We get up every (week)day at 6:45 (limburg, netherlands). “Ok Google goodmorning” routine gives us the news, starts playing music, broadcasts a wakeupcall etc. It also turns on several lights.

This turning on the lights is not always necessary. Only if it is still (to) dark outside.

How could i manage to only turn lights on when needed using home assistant?

Thx for any help.

(New to home assistant and its forum if rules or regulations are not met its not intentional)

What are you using to detect if it is dark outside? Are you using: the time; the position of the sun; or a lux sensor?

Thx for the reply.

Not using anything now, as said lights always turn on.

Sunrise time would be an option (lux meter maybe later on)

For now it’s a way to learn about programming routines in home assistant and using google to start them.
In any case i figure programming needs an AND THEN in any solution.

Something like WHEN “goodmorning” AND “sunrise is 1 hour earlier” THEN “turn on lights”

I just have no idea how to set it up…

I’m not sure where you are on your Home Assistant journey but I think you need to do something like the following:

You need to have Google Home connected to HA. I’d recommend a Nabu Casa (Home Assistant Cloud) subscription.

You need to have a script in HA (Settings > Automations and Scenes > Scripts > New Script)

Switch to Yaml mode and paste in this:

alias: Turn on lights if dark
  - if:
      - condition: state
        entity_id: sun.sun
        state: below_horizon
      - service: light.turn_on
        data: {}
          entity_id: light.bedroom_2_ceiling_light_level_on_off
mode: single

You can then switch back to the visual editor and amend (with a light you have).

You’ll need to expose the script to Google Home (Settings > Voice Assistant > Expose)

I’m not familiar with Google Home but I’m assuming you can then activate this script for there.

Thx! I will have a go at that!

(I have NabuCasa, needed it to be able to turn ambilight on and of on a philips tv, so the google part should be ok)