Skip to content

Day and night

Diurnal Control

This does three things to support Automated Transitions:

  1. Re-evaluate the alarm state at sunrise
    • There's a earliest and latest cutoff option in the UI config to stop alarm being disarmed at 4am if you live far North, like Canada or Scotland.
    • The cutoffs for sunrise can be set to the same time to override the sun integration altogeher for sunsrise
  2. Re-evaluate the alarm state at sunset
    • There's a earliest and latest cutoff option in the UI config, which works identically to that for sunrise
  3. Provide a day and night value for conditions

These are in the Advanced - Diurnal section of the options, where morning is sunrise kept within its earliest and latest times, and evening is sunset kept within its own.

Day is from morning to evening, and night from evening to morning, for everything that works out the state, not only the triggers. So with an earliest morning of 06:30, someone arriving home at 05:00 in midsummer daylight still gets the state for the night.

Whether morning and evening re-evaluate the alarm state at all is set by their Triggers. Switching them off there doesn't change the day and night values, so these still choose between armed states whenever the state is worked out for some other reason.

The same section has the states for when someone is home:

Setting Default When
Occupied state between morning and evening disarmed Daytime
Occupied state between bedtime and morning armed_home The dark after a bedtime sensor turns off, until sunrise
Occupied state between evening and bedtime armed_home From sunset until bedtime

If nothing sets armed_night for bedtime that day, neither a bedtime sensor nor an armed_night calendar event, there's no bedtime to wait for and it's armed_night from evening.

Sunrise and sunset are acted on as day and night as they happen, without waiting for the sun entity to change state.

A sunrise before the earliest time is held back until then, and the latest time is morning even if the sun isn't up yet. Starting Home Assistant in between leaves it as night, with morning still to come at the earliest time.

A change held back like this, or by an occupancy or button delay, is shown as deferred from its source, such as deferred from sunrise, in the logbook and the Last calculation sensor.

Diurnal Overrides in Configuration

Standard Home Assistant Helpers

Info

Helpers are hidden away in the Settings at the end of the Integrations,Entities and Devices section, and offer reusable things like buttons, schedules etc that can be used across multiple integrations and use cases.

Times of the Day Control

A Times of the Day sensor can set an alarm state for the same period every day, without needing a recurring calendar event. For example, a Bedtime sensor that is on from 23:00 to 07:00 holds the alarm at armed_night, whatever time the sun sets or rises. See the Recommended Recipe for a complete setup with sunset and a vacation calendar.

  1. Create the sensor in Settings > Devices & Services > Helpers > Create Helper > Times of the Day, giving the times it turns on and off.
  2. In Settings > Devices & Services > Auto Arm > Configure, choose it as the Bedtime - Times of the Day Sensor or Schedule, or for any other alarm state, open the Advanced - Times of the Day Sensor or Schedule section and choose the sensor for the state it should set. More than one sensor can be chosen for a state. There's no choice for armed_vacation, as a daily period doesn't suit it.

While the sensor is on:

  • The alarm goes to the sensor's state when it turns on, including when Home Assistant starts part way through the period.
  • Automatic resets, such as sunrise or sunset, leave the state alone, along with any manual change made meanwhile. A reset button or the autoarm.reset_state action returns to the sensor's state.
  • If everyone is out, the alarm is armed_away instead, and goes to the sensor's state when someone comes home, and back to armed_away if they all leave again. This applies to the states chosen under Advanced - Occupancy in the options, which by default is all but armed_custom_bypass.
  • A live calendar event takes priority. The sensor turning on or off during the event changes nothing, and if the sensor is still on when the event ends, the alarm goes to the sensor's state. So there's no need to switch a bedtime sensor off for a vacation that's in the calendar.

When the sensor turns off, becomes unavailable or is removed, the period ends and the calendar event end settings decide the new state. Auto here means By occupancy, other than for a bedtime sensor, where it's worked out from occupancy and the sun.

Schedules

A Schedule can be chosen anywhere a Times of the Day sensor can, for a period that's different from day to day, such as a later bedtime at the weekend. It works in the same way while it's on and when it turns off. A Times of the Day sensor is the simpler choice if the times are the same every day.

For example, a Bedtime schedule could have:

Night Schedule
Sunday to Thursday 23:00 to 24:00, then 00:00 to 07:00 on the next day
Friday and Saturday 00:30 to 09:00 on the next day, so on Saturday and Sunday

Each day of a Schedule is separate, so a period that runs past midnight is entered as two, up to 24:00 on one day and from 00:00 on the next. Auto Arm sees these as a single period.

A Schedule can leave out days, unlike a Times of the Day sensor, so there could be nights with no bedtime. On those nights someone being home leaves the alarm at Occupied state between evening and bedtime, armed_home by default, all night. If the bedtime schedules leave more than 24 hours without a bedtime, Auto Arm raises a warning in Settings > System > Repairs. Ignore the warning there if the schedule is as you want it, such as for shift work. There's no warning if a Times of the Day sensor is chosen for bedtime as well. Changes to a Schedule are checked when it next turns on or off, or when Auto Arm is reloaded.

Bedtime

A sensor or Schedule chosen for armed_night is a bedtime sensor, and makes armed_night strictly for bedtime, whenever that is. It can be any time of day or night, such as for a shift worker, and there's nothing to choose about how it behaves:

When What happens
Bedtime starts, with someone home armed_night, whether or not the sun is up
Sunrise or sunset during bedtime Ignored
Bedtime ends with the sun up Worked out as usual from occupancy and the sun, so the daytime state
Bedtime ends in the dark The state for between bedtime and morning, and worked out again at sunrise
Everyone is out Bedtime is ignored, and the alarm stays armed_away
Someone comes home during bedtime armed_night, as if bedtime had just started
Everyone leaves during bedtime armed_away, until someone is back

None of this overrides a live calendar event. The states either side of bedtime are set in the Advanced - Diurnal section of the options, see Diurnal Control.

Whether the dark is before or after bedtime goes by whether a bedtime sensor has turned off since the sun last set. That isn't known after a restart, when the dark is taken to be before bedtime.

Changes made by a Times of the Day sensor or a Schedule have the tod source, for notification profiles and in the logbook, and are linked to its own state change.