3.0 KiB
title | description | ha_category | ha_release | ha_iot_class | ha_quality_scale | ha_config_flow | ha_domain | ha_platforms | ha_integration_type | |||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Times of the Day | Instructions on how to integrate Times of the Day binary sensors within Home Assistant. |
|
0.89 | Local Push | internal | true | tod |
|
helper |
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.
{% include integrations/config_flow.md %} {% configuration_basic %} Name: description: The name the binary sensor should have. This can be changed later. On time: description: The time when the sensor should turn on. Off time: description: The time when the sensor should turn off. {% endconfiguration_basic %}
YAML Configuration
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 sunrise
or 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 configuration.yaml
file:
# Example configuration.yaml entry
binary_sensor:
- platform: tod
name: Early Morning
after: sunrise
after_offset: "-02:00"
before: "07:00"
unique_id: early_morning_sensor
- platform: tod
name: Late Morning
after: "10:00"
before: "12:00"
unique_id: late_morning_sensor
{% configuration %} name: description: Name of the sensor. required: true type: string before: description: The absolute local time value or sun event for ending of the time range. required: true type: [string, time] before_offset: description: The time offset of the ending time range. required: false type: time after: description: The absolute local time value or sun event for beginning of the time range. required: true type: [string, time] after_offset: description: The time offset of the beginning time range. type: time required: false unique_id: description: An ID that uniquely identifies this sensor. This allows changing the name, icon, and entity_id from the web interface. type: string required: false {% endconfiguration %}
Considerations
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 after
+ after_offset
<= current time
< before
+ before_offset
.
If 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.