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


If you are a book purist, you might scoff when I recommend an e-reader instead of buying physical books, and I won’t blame you. The allure of the smell of pages, the weight of the book in my hands, the whole ritual, is hard to resist. 

However, if you allow me some leeway to convince you, there’s a strong argument to be made against physical books and in favor of using e-readers. So let me make the case for e-readers, because once you understand what you’ve been missing, it’s hard to go back.

Your entire library fits in your bag

This is the most obvious advantage, but it doesn’t get enough credit. I always read more than one book at a time, and carrying two or three physical books around is not realistic. Thick books alone are a chore to carry.

With an e-reader, you carry hundreds of books in a slim package. Switching between titles takes a second. If you travel frequently, this alone is reason enough to make the switch.

A thousand-page hardcover is great for your bookshelf but terrible for your commute.

Fat books are a workout, not a reading experience

If, like me, you are into fantasy books, you know they can be a behemoth to handle. You have to constantly shift how you’re holding it, find a way to keep it open, and somehow also stay comfortable. Thin books are fine, but the moment a book crosses a certain thickness, it starts working against you.

An e-reader weighs the same regardless of whether you’re reading a short novel or a massive fantasy series. That’s it. Whether I am reading The Count of Monte Cristo or the next book in Brandon Sanderson’s The Stormlight Archive series, my Supernote Nomad remains the same. 

Reading at night without waking anyone up

I do a lot of my reading at night, and this is where physical books completely fall apart for me. Lamps and book lights never feel comfortable. The light is never quite right, and if you share a room with someone, the whole setup becomes a problem.

Most e-readers, including Kindles, have a built-in backlight that you can dim to whatever level feels right. You can even switch to warm light mode, making it easier on your eyes. 

I’ve read at 3 AM with the brightness all the way down, and it felt completely natural. No lamp and no squinting required. 

Look up any word without losing your place

English is not my first language, and even for native speakers, encountering an unfamiliar word in the middle of a chapter is common. With a physical book, your options are to grab your phone and look it up, which almost always leads to distraction, or skip it and lose a bit of meaning.

On a Kindle or most other e-readers, you tap the word and the definition appears instantly. You can translate it, add it to a vocabulary list, and get back to reading in seconds. I look up far more words now than I ever did with physical books, and my reading comprehension is genuinely better for it.

Taking notes you’ll actually use later

I used to annotate physical books with a pen, and those notes would just sit there on the page, never to be seen again. Transferring them somewhere useful took more effort than I was ever willing to put in.

With my Supernote Nomad, I can use its Digest feature to clip what I am reading and quickly add any additional handwritten notes. I can then export those notes to Obsidian and process them. 

If you use any e-reader, highlighting a passage and adding a note will take a couple of seconds. Most e-readers also aggregate all your highlights and notes in one place, allowing you to quickly riffle through your notes without flipping pages. 

With physical books, my notes died on the page. With an e-reader, they became something I actually use.

Since these are digital notes, you can process them into your note-taking app to further digest the material.

Books are cheaper and easier to buy

Buying physical books is always more expensive than getting the digital version. Also, since most publishers are phasing out mass-market paperbacks, we are left with trade paperback and hardcover options, which may look better but also cost significantly more.

E-books don’t have that problem. I have purchased several books at less than half the price I would have paid for a physical version. Also, most of the time, e-books are on sale, making them even more affordable. 

And when you find a book you want to read at midnight, you don’t have to wait for a delivery or drive to a store. You buy it and start reading immediately. The convenience is hard to overstate once you get used to it.

Should you switch?

If you love the experience of physical books, the covers, the smell, the shelf aesthetic, that’s a completely valid reason to stick with them. There’s nothing wrong with it. I myself am curating my own bookshelf, and there will always be a place for those special books. 

But for convenience and ease of discovery and reading, I recommend you at least invest in one e-reader. It’s also one of the best times to buy them, as you can get good options around $100

Since these are e-readers, you don’t even need to upgrade them as often as your phone. If you don’t accidentally break them, they can easily last 5-6 years, making them worth the investment.



Source link