-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add template filter timedelta #39608
Add template filter timedelta #39608
Conversation
Can we accept all the units of time that time delta supports instead of creating a function that only works with seconds? |
@bdraco you mean just exposing |
Yes |
I'm happy to add all the timedelta kwargs if that's what we want. |
That seems the most future proof so we don't end up with a timedeta_minutes etc |
Based on comments from @bdraco I've change the code (but not yet the docs) to expose a raw |
Can be merged once docs updated 👍 |
Might be a good idea to change the name of the PR to
because the title isn't correct anymore and the release notes use the title (IIUC). |
Proposed change
Add template filter
timedelta
to create a timedelta object from seconds. This can be used when sensors report a duration and can be converted into readable text when combined withrelative_time()
, e.g.:Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: