SUN : please add dawn and dusk as trigger options (next to sunrise/sunset)

My lights relate to the light “outside” and without (wanting to) install a light detector, I use the Sun sensor.
In summer the lights should actually go on at ‘dusk’ and not at sunset as it is still very light outside, similar is it when turning off lights…more related to dawn then to sunrise.
Of course one could template this with now()-dusk… or some hardcoded difference depending on the month but adding dawn/dusk as trigger options would be much nicer

You can use the sun elevation to achieve what you’re looking for (dusk and dawn are actually defined based upon the elevation).
That works whatever the season.

1 Like

Of course, there are three dawns and three dusks, Civil, Nautical and Astronomical. Using elevation as @koying says, that would be elevations of -3, -6 and -12, respectively. Depending on your location (on a hill or in a valley) and the degree of cloudiness, you may want to use different values.

1 Like

Won’t happen, because it was already a FeatureRequest and was rejected. :slight_smile:

But there is the community (@pnbruckner) to the rescue:

If you follow that thread, you’ll get the detailed description on the rejection. And if you use that component, you’ll be more than happy, with what it got to offer beside your wanted triggers. :slight_smile:

Well, that component doesn’t provide new triggers, does it?

And, as Tom pointed out, the desired effect might depend on environmental obstacles as well…

It does provide new triggers via the monitored_conditions. :slight_smile: And if you use the offset that is possible, you can easily setup an exact match for different times of the year. As LAT and LNG are as well part of the configuration, you can adjust everything to your needs.

In the end you get some sensors, that you can use as triggers for an automation. :slight_smile:

Thanks for this link… it is all I need :slight_smile:

1 Like

Great, thanks for posting this solution. I don’t need it today, but now that I know it exists, no doubt I’ll be back at some point!

One small detail is that it’s not just Latitude and Longitude, but also elevation which determines these times. Which I believe is also set when you configure HA. Just in case anyone needs that level of precision.

1 Like

It all depends on what you want to do with it. I would just like to switch on/off lights with the different lighting of the sun during the year and am already excluding cloudy/rainy/etc. factors.
If one needs to be exact then I agree it is different … and I would really be interested in learning of related use-cases wet home automation

EDIT: my solution is using the binary sensor that checks if the sun is above -6 degrees…when it switches to on: dawn, when it switches to off: dusk.

I’m fairly new to HA, and I’ve been trying to figure out how to use the elevation to do this or how to use sun2 and just use nautical_dusk and nautical_dawn.

Apparently, I have to add a binary_sensor, but I haven’t been able to find documentation on how to do specifics!

Can you post or point to configuration specifics for this?

Thanks …

you ‘have’ to start reading more into this and get your hand ‘dirty’ as this templating stuff will pop-up more
Binary Sensor - Home Assistant (home-assistant.io)

In my binary_sensor.yaml (which is referenced in configuration.yaml)

## binary_sensor.yaml
  - platform: sun2
    monitored_conditions:
      - elevation
      - elevation:
          above: -6
          name: dawndusk

in configyaml I have this…this allows to not add all these sensors into the configyaml file but nicely split them out

binary_sensor: !include binary_sensor.yaml

Splitting up the configuration - Home Assistant (home-assistant.io)

if all you’re doing is using elevation, why not just use the built in sun component for this?

what I’m thinking of doing is using nodered (specifically the sun-events node which I’m already using there for automations), and having that fire events based on whatever sun event is happening.

I’m using elevation and for whatever reason it doesn’t work the same between all seasons. I’m in Texas and in the winter, at a particular elevation, it is closer to what I consider “dusk” than it is in the summer. In other words, in the summer, my outside lights turn on when it’s brighter outside than I expect.

I need dusk & dawn so I can trigger outside lights based on the same amount of sunlight remaining (or not) regardless of the season.

Dusk and dawn are defined by elevation, so, whatever your issue with elevation is, this won’t help.

Reviving this … sure you could get technical about elevation of the sun and the various classifications of dawn,dusk but it seems more like its just not simple to use the information the default Sun integration provides. Most people I think quickly realize that just turning on your outside lights at sunset might not be exactly what you want. Then people go out and gather info regarding offset and then elevation to refine there automations. Its just weird that home assistant provides as a sensor the Next Dawn etc . I mean its right there all the work is done for you, or am I mistaken? Then you have to try and figure out an automation off of that which becomes I think a bit of a learning experience itself, or again am I mistaken? What is the most practical way to automate off of the sensor.sun_next_dawn , a state change? Am I missing something simple? Sure I could install a custom integration I guess. I mostly ask because it seems like a simple thing to operate lights when it Actually gets dark or light outside.

Not with just the “Sun” integration. Obstacles, weather, … will influence the “dark” subjective feeling.
Just use a zigbee light sensor and be done with it :wink:

1 Like

I’m also new to home assistant, and this is actually surprising to me as well. The default sun trigger only allows selecting on next rising of sun and next sun set, but this is also entirely different from what I want. I guess the first thing someone does when they are new to HA is exactly this, turn lights on and off.

I checked the dawn and dusk since I have another trigger for a motion sensor and that is precisely what I actually would want for lights as well. The correct setting for most people is dawn and dusk, not next sun rising and setting. I also think this should be an option on the sun settings trigger.

Can someone explain how to actually use the sun setting but with dusk and dawn, because I tried setting that directly in the YAML code, and it did not work.

Why can’t we just set something like:

platform: sun
event: sun_next_dusk
offset: 0

The setting does exist in Home Assistant because I use it with a motion sensor using state. That means it can already detect next dusk and dawn, but I’m baffled why this can’t be used with the sun trigger when this is clearly related to the sun.

platform: time
at: sensor.sun_next_dawn
4 Likes

@petro to the rescue again! I’m gonna use that one, thanks!

One thing to consider: dusk isn’t always a good one for turning lights on. Depending on trees, buildings, which side of the house the light is on, and especially, for lights inside a building on the East side, it gets dark enough to need a light long before dusk. I use something like this:

  trigger:
  - event: sunset
    platform: sun
    offset: -00:45:00

Even with this, I’ve been thinking about pulling information from a weather integration to turn it on even earlier if it’s cloudy.

I have a lux sensor in my garage (next to a window). I use the light levels on that to determine when to turn on the lights

2 Likes