When to turn on porch lights

It was more of a trial and error. Spend a few days of actually seeing how close the automation triggered to the actual light outside at the time.

2 Likes

Here is another I found awhile back when I want to turn on my living room lights at sunset but also depends on the cloud coverage outside. The sample uses Darksky which is now a paid subscription. Weatherbit is free.

is there a HA integration for that? I didn’t see it in the official list.

is it available for the US?

yes, it’s in HACS. You can following this project on how to install and setup.

That’s wonderful. From the sensor code, I don’t see anywhere to specify the region?

The region is where you are running HA. No need to set anything for that.

1 Like

I just have an event on sunset or sunrise and I add an offset for what I feel is comfortable for my area. In my case I like the lights on 30min BEFORE sunset.

alias: 'Lights: turn on outdoor lights when the sun sets'
trigger:
  - event: sunset
    offset: '-00:30:00'
    platform: sun
condition: []
action:
  - device_id: xxxxx
    domain: switch
    entity_id: switch.switch_3
    type: turn_on
  - device_id: xxxxx
    domain: switch
    entity_id: switch.switch_2
    type: turn_on
initial_state: 'on'
mode: single

More on the sun and offsets

1 Like

Configuration --> General

The time zone and location on the map set for Home will be used to figure out when sunset and sunrise are.

1 Like

Deploy a light sensor outside. Outdoor light during twilight time varies much more than I realized until comparing Lux readings against astronomical calculations (e.g. civil twilight). This is especially true if you’re in northern latitudes (I’m close to 48 degs N).

I use an XBee3 ZigBee module (which can do I2C) and a TSL2591 light sensor (it’s part of my weather station). Use a moving average of Lux readings to smooth variations and outliers as last light approaches.

Works perfectly. Sometimes DIY is the best choice :slight_smile:

1 Like

Exactly this was gonna be my suggestion. I originally did this with sunset ending up in the same problem where it would need changing. Then I tried using info from weather but was also not as accurate. The best solution I ended up with was a lux sensor. It is way more close to what is actually happening outside.

The offset of the sun is based on geographic location and the time of year. It should be accurate regardless of time of year and latitude that is the entire point as long as your “Home” is set correctly.

I am at 49 degrees N, and have been fine year round with 30min before sunset for a few years now even with our dark short overcast days in winter and long summer days.

I am curious how “spot on” you are trying to be I find that 30 min window somewhat covers any variance however I am trying to have the lights on BEFORE it gets dark.

I even use it with my Christmas lights and have them come on in the morning but ONLY if it is dark during the normal hours people get up for work.

I checked the sun elevation when I think it is best time to turn on the light, it is showing -36.6 for me. Will continue experiment this.

Sure yes I used that too and works fine. It is just curiosity and more fine optimization if possible.

Thanks for the suggestion. I have not tried any light sensor yet. May consider adding in the future.

an elevation of -36 is pretty much pitch black out, I think you are reading the wrong value

1 Like

I posted work I did developing a simple model in this thread:

I am still working on it, I need to get data now that the snow is gone, and in 2 days when it is raining to adapt the final formulas, then in the summer sort out my surface reflectivity value

I got it working exceptionally well during winter as long as it was not actively snowing, but I figure the adjusted compensation due to rain will be sufficient.

1 Like

I was wondering too. Seems not correct. I was reading elevation value from sun.sun. In config->general, I’ve set the correct time zone (-5 timezone)

From the history of this value, it seems it is based on UTC time? I’m in -5 timezone, the sun.sun elevation value was peak 38.66 6:55am(-5 timezone).

Is there any other settings I need to make in HASS?

quickly checked and this is amazing, using weather info instead of light sensor! will try it out. thanks!

Time zone is only part of the story.
That same time zone will run at all latitudes from the north pole to the south. Time zones are based generally on longitude and geopolitical basis.
Sun elevation is determined by your exact location.
On this page Open your Home Assistant instance and show your general Home Assistant settings.
Is your location set correctly on the map?

1 Like

Thanks! I was using some config in yaml file and so disabled from the UI. Now I have updated and should be good.