-
Notifications
You must be signed in to change notification settings - Fork 0
Date Range Duration
Scott Gusler edited this page Feb 11, 2026
·
2 revisions
Measures the duration between two datetime entities.
A date range duration sensor calculates the difference between two datetimes and displays it in hours.
- Select "Date Range Duration"
- Configure:
- Calculation Name: A friendly name
- Start Datetime Entity: Start of the range
- End Datetime Entity: End of the range
- Icon: Optional custom icon
{
"type": "date_range",
"name": "Meeting Duration Hours",
"start_datetime_entity": "input_datetime.meeting_start",
"end_datetime_entity": "input_datetime.meeting_end"
}Result: Hours between meeting start and end
{
"type": "date_range",
"name": "Shift Hours",
"start_datetime_entity": "input_datetime.shift_start",
"end_datetime_entity": "input_datetime.shift_end"
}automation:
- alias: "Alert if event too long"
trigger:
platform: numeric_state
entity_id: sensor.meeting_duration_hours
above: 3
action:
service: notify.mobile_app
data:
message: "Meeting is running long!"Format the duration nicely:
{% set hours = states('sensor.shift_hours') | int(0) %}
{% set minutes = ((states('sensor.shift_hours') | float(0) - hours) * 60) | int %}
Shift: {{ hours }}h {{ minutes }}m