I automated my porch lights using real-time weather, and it solved all the problems timers couldn’t fix


For a long time, the light on my porch was turned on based on sunset. When sunset arrived, the light would come on. While it worked okay, it was far from perfect, with the light sometimes coming on when it was still fairly bright, or not coming on despite it having gotten quite dark. Automating the light using the weather solved my problems.

Why time-based porch light automations can fail

Darkness isn’t solely determined by the time of day

Sunset at a beach with cattails in the foreground and mountains in the background. Credit: Patrick Campanale / How-To Geek

There are plenty of ways to create automations in Home Assistant to turn on your porch lights. You can use a timer to get your light to turn on at the same time each evening. The problem with this method is that the light levels at 7 PM in the winter and 7 PM in the summer can be very different.

A simple solution is to create an automation based on the sunset time. You can have the light turn on at the exact time of sunset each day, and this time will vary throughout the year. Using the exact sunset time isn’t always ideal, so you can use an adjustment to make the light turn on half an hour after sunset, or 20 minutes before.

The issue is that the sun isn’t the only thing that affects how dark it is. If there’s significant cloud cover, it can be much darker than when there are clear skies. If it’s raining heavily, it will be darker than when it’s sunny.

I wanted my porch light to turn on when it was dark enough to need it. Using a time-based automation, this wasn’t always happening; there were plenty of times when it started to get dark long before the light turned on.

Home Assistant Green

Dimensions (exterior)

4.41″L x 4.41″W x 1.26″H

Weight

12 Ounces

Home Assistant Green is a pre-built hub directly from the Home Assistant team. It’s a plug-and-play solution that comes with everything you need to set up Home Assistant in your home without needing to install the software yourself. 


Estimating outdoor brightness in Home Assistant

A custom integration can estimate outdoor brightness

A time-based automation can’t respond to actual light levels; it only knows what time it is. I wanted my porch light to turn on when it was dark enough to be needed, rather than at any specific time.

That’s when I discovered a custom integration for Home Assistant called Illuminance Sensor. As the name suggests, the integration creates a sensor entity that provides an estimate of the current illuminance in your location. It uses an algorithm developed by the United States Naval Observatory that produces an estimate of solar illuminance based on the elevation of the sun.

There’s also a simple mode that uses the time of day rather than sun elevation, but since I’d already tried time-based automations, I stuck to the default mode. You can install the Illuminance Sensor integration via HACS. It’s not part of the HACS library, so you’ll need to add it as a custom repository, download it via HACS, and then restart Home Assistant. You can then install it like any other integration.

Using the basic settings of the Illuminance Sensor integration, I got an initial illuminance value of around 74,000 lx. This is a reasonable value for full daylight in the summer, so it seemed like the integration was doing its job.


A lightning strike in an urban area.


5 wild smart home sensors you can integrate with Home Assistant

Great gifts for the smart home nerd in your life.

Adding weather data makes the results more accurate

Cloud cover and weather conditions can make it darker

The Home Assistant Illuminance Options dialog showing the Weather data source field with an arrow pointing to Cloud coverage from Front Porch OpenWeatherMap.

The problem with using the default settings is that they still don’t take into account the weather conditions, which is the whole reason I set up the integration in the first place. However, in the Illuminance Sensor configuration, you can provide the entity ID of a weather integration. Using a supported weather integration, the sensor can adjust the illuminance value based on the weather conditions and cloud cover.

The integration supports weather entities from AccuWeather, Buienradar, ecobee, Met.no, and OpenWeatherMap. If you’re using OpenWeatherMap, you can also use the openweathermap_cloud_coverage and openweathermap_condition sensors instead.

Using the OpenWeatherMap weather entity, the illuminance dropped to around 38,000 lx, which seemed more realistic based on the cloud cover at the time. Using the condition sensor, it gave a similar result of around 39,000 lx, but when I switched to the cloud_coverage sensor, the value rose to 47,000 lx.

This made sense to me; if the weather entity or condition sensor says that it’s cloudy, the integration will make the same adjustment, whether there’s 30% cloud cover or 70% cloud cover. Using the cloud coverage sensor, it gets a more specific measure of cloud cover, so the adjustment may be more accurate. I ended up sticking with the cloud coverage sensor, and it’s worked well for me so far.

The final step was to create an automation to turn on the porch light when the illuminance sensor fell below a set threshold. It took a bit of tweaking, but it’s now the case that my porch light is almost always on when it’s dark enough to warrant it.


You don’t always need to buy more hardware

You could use a lux sensor to measure the light levels directly, but I found that the lux reading in my motion sensors was capped at a maximum value of 1364 lx, so it was useless for my needs. I didn’t want to have to buy another sensor just for this purpose, and using this clever integration, there was no need to do so.



Source link

Leave a Reply

Subscribe to Our Newsletter

Get our latest articles delivered straight to your inbox. No spam, we promise.

Recent Reviews


U.S. CISA adds a flaw in Ivanti Endpoint Manager Mobile (EPMM) to its Known Exploited Vulnerabilities catalog

Pierluigi Paganini
May 07, 2026

The U.S. Cybersecurity and Infrastructure Security Agency (CISA) adds a flaw in Ivanti Endpoint Manager Mobile (EPMM) to its Known Exploited Vulnerabilities catalog

The U.S. Cybersecurity and Infrastructure Security Agency (CISA) added a flaw in the Ivanti Endpoint Manager Mobile (EPMM), tracked as CVE-2026-6973 (CVSS score of 7.1), to its Known Exploited Vulnerabilities (KEV) catalog.

Ivanti warns customers of a high‑severity zero‑day vulnerability, tracked as CVE‑2026‑6973, in Endpoint Manager Mobile that is already being exploited.

“At the time of disclosure, we are aware of very limited exploitation of CVE-2026-6973, which requires admin authentication for successful exploitation.” reads the advisory. “We are not aware of any customers being exploited by the other vulnerabilities disclosed today.”

The flaw, caused by improper input validation, allows attackers with admin privileges to execute arbitrary code on systems running EPMM 12.8.0.0 and earlier. Customers are urged to patch immediately to prevent compromise.

Ivanti EPMM 12.6.1.1, 12.7.0.1, and 12.8.0.1 address the vulnerability. The vulnerability doesn’t affect Ivanti Neurons for MDM, Ivanti’s cloud-based unified endpoint management solution, Ivanti EPM (a similarly named, but different product), Ivanti Sentry, or any other Ivanti products.

According to Binding Operational Directive (BOD) 22-01: Reducing the Significant Risk of Known Exploited Vulnerabilities, FCEB agencies have to address the identified vulnerabilities by the due date to protect their networks against attacks exploiting the flaws in the catalog.

Experts also recommend that private organizations review the Catalog and address the vulnerabilities in their infrastructure.

CISA orders federal agencies to fix the vulnerability by May 10, 2026.

Pierluigi Paganini

Follow me on Twitter: @securityaffairs and Facebook and Mastodon

(SecurityAffairs – hacking, US CISA Known Exploited Vulnerabilities catalog)







Source link