Newbee trying to use Weather as a trigger

I’m brand new at HA, having just installed the server yesterday. I am migrating from SmartThings and have most devices moved over.

I’m trying to set up an automation to turn on a light, based on the weather. If it’s sunny, turn on the light 30 minutes before sunset. If it’s cloudy, rainy or snowy, turn on the light 45 minutes before sunset.

I created the first automation, using the Time trigger, checking if the light is already on. But I don’t know how to use the forecast service to tell me if it’s cloudy, rainy or snowy.

Any suggestions?

I would start with this search, I don’t use the forecast but plenty of people have and got help with it.
https://community.home-assistant.io/search?q=weather%20forecast

Thanks.
I think I need a bit more hand holding. I’m in first grade and the posts are all from high school students.

Keep reading. It will start to make sense.

Is this any help?

I guess I was looking for the specific steps I should perform to create a trigger that fires when cloudy, rainy, snowy.
Thanks for your comments. I’ll spend more time looking through the Community Guide and posts and see if I can figure it out.

This is always a good place to find out how stuff works with HA.

When you have found out some stuff and tried a few things if it still doesn’t do what you want, post your automation yaml (correctly formatted) and you will get some answers.

You should probably go for triggers that fire 30 / 45 minutes before sundown and then add condition checks for sunny or cloudy

Or else trigger with light level. If you’re turning on lights, it’s light level that’s significant, not weather.

Yes! I needed a Condition. Thanks for this tip. I was having trouble looking for the cloudy state in Triggers but it’s simple in Conditions. I ran a test and that Condition works correctly.
Thanks for the pointer.

That’s an idea. I hadn’t thought of that. Where would I find light level?

A light sensor :slight_smile:

Yup. On my list.

Which weather integration you are using? The cloudy descriptions will be different from one weather integration to another, so for example mine also do “partially cloudy” , “scattered clouds” , “broken clouds” , “few clouds”…

But yes, you got it. For the kind of automation you want to do,

  • the trigger would be “when it is 30 minutes before sunset”, and
  • conditions would be to check weather conditions (or illuminance reading from the light sensor, or maybe some weather service would provide outdoor illuminance info),
  • and actions would be to turn on your lights

=== sidebar ===
For the little issue before you buy any outdoor light sensor, there is one more thing you can do without the sensor sensor: you can look into HACS and get that working, and then in HACS you can search for “Illuminance”, or essentially this one → pnbruckner/ha-illuminance: Home Assistant Illuminance Sensor to get a proxy of how bright it is outdoors at the time.
But yes, an good hardware lux sensor to detect the light conditions of exactly where you are is still more accurate than any simulated approach.

A couple of thoughts on light sensors.

Be careful of light sensors integrated in motion sensors, a good chunk of such sensors only send updates on the current light state when motion occurs, so you need to research to confirm the brand you are buying can be configured to send light updates even if no motion is detected.
Or you can buy a dedicated light sensor (not combined with a motion detector).


If you do have a good light sensor, it may dramatically simplify your automations, specifically you can probably ignore the weather forecast and simply create:

An automation that triggers 45 minutes before sunset.
With a condition to check if its too dark (read the light sensor).
And an action to turn on the lights.

A second automation that triggers at 30 minutes before sunset.
With a condition that the lights are not already on.
That also turns on the lights.

I had a similar issue not with lights but with curtains and blinds. I found the weather entities to be very unreliable especially for cloud cover as they forecast regions and and not what is happening right above my home.

This was a great source of frustration because Open weather maps would report 70%+ cloud cover, yet there was zero clouds and my curtains would remain open and heat up the house which I was trying to minimise using automations. Also not many weather integrations offer reporting on things like cloud cover.

Now I am not a developer but I do understand a bit of yaml and with the help of AI and other posts in the forum I came up with a working prototype (more works in progress) for a hyper local weather detection/observer system.

I have several cameras installed around the property including a doorbell camera which has a perfect view of the sky (Front of the house) and camera in the garden which has a partial view of the sky (Back of the house) and they are integrated into HA.

A while back I came across posts about people using the LLM vision integration with their cameras to have AI describe and report activities the cameras are seeing to HA. I thought to myself well if the camera using LLM vision can describe the person walking across the garden or at the entrance etc. then surely it will be able to look at the sky and describe the conditions.

At the moment the system uses the 2 cameras sending images every 5 minutes from sunrise to sunset and the it calculates the percentage of cloud cover for each camera and averages them to give me a realistic value that I use for trigger ranges in my automations.

Example close curtains if cloud cover falls below 40% if they are open and open if it goes above 60% if they are closed.

I found this to be so much better for my curtain automations than relying on the weather entities.

As a newbie this maybe be too advanced for you at this stage but the point is there are alternatives and relying on weather integrations will not always work.

However if you or others are interested, let me know and I can share and help out.

Absolutely. Philips Hue report light and movement independently, but they’re comparatively expensive.

Light sensors may come in unexpected places - I have an Ecowitt wind vane which has one - I use that to trigger most light related automations.

If you have cameras integrated in home assistant you can also look at this interesting project

https://github.com/markfrancisonly/ha-cameralux

" Camera Lux is a custom Home Assistant integration that utilizes a camera feed or direct image URL to estimate ambient light levels (lux) in your environment. By analyzing images from your cameras, cameralux provides virtual lux readings that can be used to automate lighting, monitor lighting conditions, and enhance your smart home setup."