Created
November 25, 2023 15:13
-
-
Save vladyspavlov/b64dff4a91a918be022b8965852bcb56 to your computer and use it in GitHub Desktop.
Home Assistant. Example of dividing time between entity last changes and converting to human readable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set td = trigger.to_state.last_changed - trigger.from_state.last_changed %} | |
{% set ts = td.total_seconds() | int %} | |
{% set hours, remainder = (ts // 3600, ts % 3600) %} | |
{% set minutes, seconds = (remainder // 60, remainder % 60) %} | |
Days: {{ td.days }}, hours: {{ hours }}, minutes: {{ minutes }}, seconds: {{ seconds }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment