Is it possible to save / alias triggers

i’m in the process of migrating from openhab to HA, and i have a few rules that use civil dusk. i have a trigger set up that turns lights on when the sun is 6 degrees below the horizon, and it seems to be working so far…but is there a way i can alias it so i can include it in other automations via one or two lines rather than typing the entire trigger out every time?

I’ve been using an input slider to manage this. I use the sun’s elevation as well as darksky’s cloudiness and whether it’s raining to set the value for a “darkness” slider (from 1 to 10: 1 Means Daytime, 10 Means Night, Cloudy, and Raining). And then I base all my lighting automations upon my input_slider.darkness value.

It’s been working great so far, and I like that I can tweak the algo for the “darkness” value without having to mess with all the automations based upon it. The added benefit is that I can see the slider in the interface to get an idea of what the value is, and even adjust it to test different light settings.

1 Like

I like your idea! I’ve been looking for something like that to trigger my afternoon lights, now based on sun elevation only, but having also de “outside” light would be great.
Do you mind sharing your algo?

1 Like

After writing this whole thing out here, I ended up making a couple changes (using a sensor to track “darkness” rather than doing it in the automation). And instead of keeping this post up to date, I just moved the explanation to my github repo. Here it is:


This is great. Thanks for posting. I had built a “gloomy” sensor that looked at cloudiness and precipitation, but I like that this rolls-in the sun angle.

unless i’m missing something, this is a cool solution but doesn’t actually answer my question. i just want to be able to save civil dusk as a trigger and use that elsewhere…i.e. instead of typing:

    platform: numeric_state
    entity_id: sun.sun
    value_template: '{{ state.attributes.elevation }}'
    below: -6.0

i just want to type:

trigger: civilDusk

which then refers to the saved trigger that fires when the sun gets to 6 degrees below the horizon (which is civil dusk)…

The short answer is “no”. You could create a binary sensor that was true when it was civil dusk, but the code for the trigger would be similar in length, so probably not worth it.

Hmmm. Looks like precip intensity in DarkSky is measured in inches. It’s raining pretty well today - strong at times - and my value stays below .24 Could that be inches/hr?

Do you want precip probability?

You’re right! Updated. Thanks!

I misunderstood exactly what you were asking. Thanks for clarifying.

Unfortunately I don’t think trigger combinations can be saved and reused exactly like that. My way of working around that has been to maintain values in inputs and use those inputs as the triggers for other automations. It’s not as ideal as your example, but it’s worked out similarly.