The Times of the Day integration provides a binary sensor that gets its values by checking if the current time is within defined time ranges.
Adding Times of the Day to your Home Assistant instance can be done via the user interface, by using this My button:
If the above My button doesn’t work, you can also perform the following steps manually:
Browse to your Home Assistant instance.
In the sidebar click on Settings.
From the configuration menu select: Devices & Services.
In top of the screen click the tab: Helpers.
In the bottom right, click on the Create helper button.
From the list, search and select “Times of the Day”.
Follow the instruction on screen to complete the set up.
Alternatlively, this integration can be configured and set up manually via YAML instead. This has some additional functionality over the UI version.
The time ranges can be provided as absolute local time or using the
sunset keyword calculated based on the sun position for location. The location must be provided in the configuration.
In addition for sun position based ranges, the negative or positive offset can be configured.
To enable the Times of Day binary sensor in your installation, add the
following to your
# Example configuration.yaml entry binary_sensor: - platform: tod name: Early Morning after: sunrise after_offset: "-02:00" before: "07:00" - platform: tod name: Late Morning after: "10:00" before: "12:00"
The absolute local time value or sun event for ending of the time range.
The absolute local time value or sun event for beginning of the time range.
The primary purpose of this sensor is to use a simple time range definition instead of creating a complex template with references to
sun.sun integration attributes.
The sensor state is ON when this condition
current time <
after time is later than
before then the next day is considered, i.e.:
binary_sensor: - platform: tod name: Night after: sunset before: sunrise
In the above example, the next day
sunrise is calculated as a time range end.